Differential D14675 Diff 35496 src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
| Show First 20 Lines • Show All 198 Lines • ▼ Show 20 Lines | $form = id(new AphrontFormView()) | ||||
| ->setID($this->getFormID()) | ->setID($this->getFormID()) | ||||
| ->addHiddenInput('__draft__', $draft_key) | ->addHiddenInput('__draft__', $draft_key) | ||||
| ->addHiddenInput($version_key, $version_value); | ->addHiddenInput($version_key, $version_value); | ||||
| $edit_types = $this->getEditTypes(); | $edit_types = $this->getEditTypes(); | ||||
| if ($edit_types) { | if ($edit_types) { | ||||
| $action_map = array(); | $action_map = array(); | ||||
| $type_map = array(); | |||||
| foreach ($edit_types as $edit_type) { | foreach ($edit_types as $edit_type) { | ||||
| $key = $edit_type->getEditType(); | $key = $edit_type->getEditType(); | ||||
| $action_map[$key] = array( | $action_map[$key] = array( | ||||
| 'key' => $key, | 'key' => $key, | ||||
| 'label' => $edit_type->getLabel(), | 'label' => $edit_type->getLabel(), | ||||
| 'type' => $edit_type->getPHUIXControlType(), | 'type' => $edit_type->getPHUIXControlType(), | ||||
| 'spec' => $edit_type->getPHUIXControlSpecification(), | 'spec' => $edit_type->getPHUIXControlSpecification(), | ||||
| ); | ); | ||||
| $type_map[$key] = $edit_type; | |||||
| } | } | ||||
| $options = array(); | $options = array(); | ||||
| $options['+'] = pht('Add Action...'); | $options['+'] = pht('Add Action...'); | ||||
| foreach ($action_map as $key => $item) { | foreach ($action_map as $key => $item) { | ||||
| $options[$key] = $item['label']; | $options[$key] = $item['label']; | ||||
| } | } | ||||
| Show All 20 Lines | if ($edit_types) { | ||||
| // new actions. | // new actions. | ||||
| $form->appendChild( | $form->appendChild( | ||||
| phutil_tag( | phutil_tag( | ||||
| 'div', | 'div', | ||||
| array( | array( | ||||
| 'id' => $place_id, | 'id' => $place_id, | ||||
| ))); | ))); | ||||
| $draft_actions = array(); | |||||
| if ($versioned_draft) { | |||||
| $draft_actions = $versioned_draft->getProperty('actions', array()); | |||||
| foreach ($draft_actions as $key => $action) { | |||||
| $type = idx($action, 'type'); | |||||
| if (!$type) { | |||||
| unset($draft_actions[$key]); | |||||
| continue; | |||||
| } | |||||
| $edit_type = idx($type_map, $type); | |||||
| if (!$edit_type) { | |||||
| unset($draft_actions[$key]); | |||||
| continue; | |||||
| } | |||||
| $value = idx($action, 'value'); | |||||
| $value = $edit_type->getCommentActionValueFromDraftValue($value); | |||||
| $draft_actions[$key]['value'] = $value; | |||||
| } | |||||
| } | |||||
| Javelin::initBehavior( | Javelin::initBehavior( | ||||
| 'comment-actions', | 'comment-actions', | ||||
| array( | array( | ||||
| 'actionID' => $action_id, | 'actionID' => $action_id, | ||||
| 'inputID' => $input_id, | 'inputID' => $input_id, | ||||
| 'formID' => $this->getFormID(), | 'formID' => $this->getFormID(), | ||||
| 'placeID' => $place_id, | 'placeID' => $place_id, | ||||
| 'panelID' => $this->getPreviewPanelID(), | 'panelID' => $this->getPreviewPanelID(), | ||||
| 'timelineID' => $this->getPreviewTimelineID(), | 'timelineID' => $this->getPreviewTimelineID(), | ||||
| 'actions' => $action_map, | 'actions' => $action_map, | ||||
| 'showPreview' => $this->getShowPreview(), | 'showPreview' => $this->getShowPreview(), | ||||
| 'actionURI' => $this->getAction(), | 'actionURI' => $this->getAction(), | ||||
| 'drafts' => $draft_actions, | |||||
| )); | )); | ||||
| } | } | ||||
| $form | $form | ||||
| ->appendChild( | ->appendChild( | ||||
| id(new PhabricatorRemarkupControl()) | id(new PhabricatorRemarkupControl()) | ||||
| ->setID($this->getCommentID()) | ->setID($this->getCommentID()) | ||||
| ->setName('comment') | ->setName('comment') | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||