Differential D13006 Diff 31364 src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/customfield/config/PhabricatorCustomFieldConfigOptionType.php
| Show All 28 Lines | public function renderControl( | ||||
| $field_base_class = $option->getCustomData(); | $field_base_class = $option->getCustomData(); | ||||
| $field_spec = $display_value; | $field_spec = $display_value; | ||||
| if (!is_array($field_spec)) { | if (!is_array($field_spec)) { | ||||
| $field_spec = PhabricatorEnv::getEnvConfig($option->getKey()); | $field_spec = PhabricatorEnv::getEnvConfig($option->getKey()); | ||||
| } | } | ||||
| // Get all of the fields (including disabled fields) by querying for them | |||||
| // with a faux spec where no fields are disabled. | |||||
| $faux_spec = $field_spec; | |||||
| foreach ($faux_spec as $key => $spec) { | |||||
| unset($faux_spec[$key]['disabled']); | |||||
| } | |||||
| // TODO: We might need to build a real object here eventually. | // TODO: We might need to build a real object here eventually. | ||||
| $faux_object = null; | $faux_object = null; | ||||
| $fields = PhabricatorCustomField::buildFieldList( | $fields = PhabricatorCustomField::buildFieldList( | ||||
| $field_base_class, | $field_base_class, | ||||
| $faux_spec, | $field_spec, | ||||
| $faux_object); | $faux_object, | ||||
| array( | |||||
| 'withDisabled' => true, | |||||
| )); | |||||
| $list_id = celerity_generate_unique_node_id(); | $list_id = celerity_generate_unique_node_id(); | ||||
| $input_id = celerity_generate_unique_node_id(); | $input_id = celerity_generate_unique_node_id(); | ||||
| $list = id(new PHUIObjectItemListView()) | $list = id(new PHUIObjectItemListView()) | ||||
| ->setFlush(true) | ->setFlush(true) | ||||
| ->setID($list_id); | ->setID($list_id); | ||||
| foreach ($fields as $key => $field) { | foreach ($fields as $key => $field) { | ||||
| $item = id(new PHUIObjectItemView()) | $item = id(new PHUIObjectItemView()) | ||||
| ->addSigil('field-spec') | ->addSigil('field-spec') | ||||
| ->setMetadata(array('fieldKey' => $key)) | ->setMetadata(array('fieldKey' => $key)) | ||||
| ->setGrippable(true) | ->setGrippable(true) | ||||
| ->addAttribute($field->getFieldDescription()) | ->addAttribute($field->getFieldDescription()) | ||||
| ->setHeader($field->getFieldName()); | ->setHeader($field->getFieldName()); | ||||
| $is_disabled = !empty($field_spec[$key]['disabled']); | $spec = idx($field_spec, $key, array()); | ||||
| $is_disabled = idx($spec, 'disabled', $field->shouldDisableByDefault()); | |||||
| $disabled_item = clone $item; | $disabled_item = clone $item; | ||||
| $enabled_item = clone $item; | $enabled_item = clone $item; | ||||
| if ($is_disabled) { | if ($is_disabled) { | ||||
| $list->addItem($disabled_item); | $list->addItem($disabled_item); | ||||
| } else { | } else { | ||||
| $list->addItem($enabled_item); | $list->addItem($enabled_item); | ||||
| ▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines | |||||