diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1440,7 +1440,9 @@ 'PhabricatorDashboardPHIDTypeDashboard' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php', 'PhabricatorDashboardPHIDTypePanel' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php', 'PhabricatorDashboardPanel' => 'applications/dashboard/storage/PhabricatorDashboardPanel.php', + 'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php', 'PhabricatorDashboardPanelCreateController' => 'applications/dashboard/controller/PhabricatorDashboardPanelCreateController.php', + 'PhabricatorDashboardPanelCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php', 'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php', 'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php', 'PhabricatorDashboardPanelQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelQuery.php', @@ -4249,8 +4251,15 @@ array( 0 => 'PhabricatorDashboardDAO', 1 => 'PhabricatorPolicyInterface', + 2 => 'PhabricatorCustomFieldInterface', + ), + 'PhabricatorDashboardPanelCoreCustomField' => + array( + 0 => 'PhabricatorDashboardPanelCustomField', + 1 => 'PhabricatorStandardCustomFieldInterface', ), 'PhabricatorDashboardPanelCreateController' => 'PhabricatorDashboardController', + 'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField', 'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController', 'PhabricatorDashboardPanelListController' => array( diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php --- a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php @@ -58,6 +58,13 @@ $v_name = $panel->getName(); $e_name = true; + $field_list = PhabricatorCustomField::getObjectFields( + $panel, + PhabricatorCustomField::ROLE_EDIT); + $field_list + ->setViewer($viewer) + ->readFieldsFromStorage($panel); + $validation_exception = null; if ($request->isFormPost()) { $v_name = $request->getStr('name'); @@ -65,11 +72,15 @@ $xactions = array(); $type_name = PhabricatorDashboardPanelTransaction::TYPE_NAME; - $xactions[] = id(new PhabricatorDashboardPanelTransaction()) ->setTransactionType($type_name) ->setNewValue($v_name); + $field_xactions = $field_list->buildFieldTransactionsFromRequest( + new PhabricatorDashboardPanelTransaction(), + $request); + $xactions = array_merge($xactions, $field_xactions); + try { $editor = id(new PhabricatorDashboardPanelTransactionEditor()) ->setActor($viewer) @@ -93,7 +104,11 @@ ->setLabel(pht('Name')) ->setName('name') ->setValue($v_name) - ->setError($e_name)) + ->setError($e_name)); + + $field_list->appendFieldsToForm($form); + + $form ->appendChild( id(new AphrontFormSubmitControl()) ->setValue($button) diff --git a/src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php b/src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php new file mode 100644 --- /dev/null +++ b/src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php @@ -0,0 +1,42 @@ +requireImplementation(); + $specs = $impl->getFieldSpecifications(); + return PhabricatorStandardCustomField::buildStandardFields($this, $specs); + } + + public function shouldUseStorage() { + return false; + } + + public function readValueFromObject(PhabricatorCustomFieldInterface $object) { + $key = $this->getProxy()->getRawStandardFieldKey(); + $this->setValueFromStorage($object->getProperty($key)); + } + + public function applyApplicationTransactionInternalEffects( + PhabricatorApplicationTransaction $xaction) { + $object = $this->getObject(); + $key = $this->getProxy()->getRawStandardFieldKey(); + + $this->setValueFromApplicationTransactions($xaction->getNewValue()); + $value = $this->getValueForStorage(); + + $object->setProperty($key, $value); + } + + public function applyApplicationTransactionExternalEffects( + PhabricatorApplicationTransaction $xaction) { + return; + } + +} diff --git a/src/applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php b/src/applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php new file mode 100644 --- /dev/null +++ b/src/applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php @@ -0,0 +1,6 @@ +renderPanelContent($viewer, $panel); + return id(new PHUIObjectBoxView()) ->setHeaderText($panel->getName()) - ->appendChild(pht('TODO: Panel content goes here.')); + ->appendChild($content); + } + + protected function renderPanelContent( + PhabricatorUser $viewer, + PhabricatorDashboardPanel $panel) { + return pht('TODO: Panel content goes here.'); } public function shouldRenderAsync() { diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php --- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php +++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php @@ -17,4 +17,28 @@ 'provide instructions or context.'); } + public function getFieldSpecifications() { + return array( + 'text' => array( + 'name' => pht('Text'), + 'type' => 'remarkup', + ), + ); + } + + protected function renderPanelContent( + PhabricatorUser $viewer, + PhabricatorDashboardPanel $panel) { + + $text = $panel->getProperty('text', ''); + + $text_content = PhabricatorMarkupEngine::renderOneObject( + id(new PhabricatorMarkupOneOff())->setContent($text), + 'default', + $viewer); + + return id(new PHUIPropertyListView()) + ->addTextContent($text_content); + } + } diff --git a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php --- a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php +++ b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php @@ -5,7 +5,9 @@ */ final class PhabricatorDashboardPanel extends PhabricatorDashboardDAO - implements PhabricatorPolicyInterface { + implements + PhabricatorPolicyInterface, + PhabricatorCustomFieldInterface { protected $name; protected $panelType; @@ -13,6 +15,8 @@ protected $editPolicy; protected $properties = array(); + private $customFields = self::ATTACHABLE; + public static function initializeNewPanel(PhabricatorUser $actor) { return id(new PhabricatorDashboardPanel()) ->setName('') @@ -94,4 +98,25 @@ return null; } + +/* -( PhabricatorCustomFieldInterface )------------------------------------ */ + + + public function getCustomFieldSpecificationForRole($role) { + return array(); + } + + public function getCustomFieldBaseClass() { + return 'PhabricatorDashboardPanelCustomField'; + } + + public function getCustomFields() { + return $this->assertAttached($this->customFields); + } + + public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { + $this->customFields = $fields; + return $this; + } + } diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php --- a/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php +++ b/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php @@ -83,8 +83,10 @@ return pht('A build step has the same policies as its build plan.'); } + /* -( PhabricatorCustomFieldInterface )------------------------------------ */ + public function getCustomFieldSpecificationForRole($role) { return array(); }