mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 10:42:41 +01:00
Implement remarkup custom control
Summary: Ref T2575. Adds "remarkup" control, which displays a remarkup control and uses the remarkup cache. Grants fields access to remarkup pipeline. Test Plan: {F35067} {F35068} Used DarkConsole to verify cache interaction with services. Reviewers: hach-que, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2575 Differential Revision: https://secure.phabricator.com/D5286
This commit is contained in:
parent
3f56ca681f
commit
30d6cd91da
5 changed files with 91 additions and 13 deletions
|
@ -2084,6 +2084,7 @@ phutil_register_library_map(array(
|
||||||
'LiskMigrationIterator' => 'PhutilBufferedIterator',
|
'LiskMigrationIterator' => 'PhutilBufferedIterator',
|
||||||
'ManiphestAction' => 'ManiphestConstants',
|
'ManiphestAction' => 'ManiphestConstants',
|
||||||
'ManiphestAuxiliaryFieldDefaultSpecification' => 'ManiphestAuxiliaryFieldSpecification',
|
'ManiphestAuxiliaryFieldDefaultSpecification' => 'ManiphestAuxiliaryFieldSpecification',
|
||||||
|
'ManiphestAuxiliaryFieldSpecification' => 'PhabricatorMarkupInterface',
|
||||||
'ManiphestAuxiliaryFieldTypeException' => 'Exception',
|
'ManiphestAuxiliaryFieldTypeException' => 'Exception',
|
||||||
'ManiphestAuxiliaryFieldValidationException' => 'Exception',
|
'ManiphestAuxiliaryFieldValidationException' => 'Exception',
|
||||||
'ManiphestBatchEditController' => 'ManiphestController',
|
'ManiphestBatchEditController' => 'ManiphestController',
|
||||||
|
|
|
@ -15,11 +15,12 @@ class ManiphestAuxiliaryFieldDefaultSpecification
|
||||||
private $error;
|
private $error;
|
||||||
private $shouldCopyWhenCreatingSimilarTask;
|
private $shouldCopyWhenCreatingSimilarTask;
|
||||||
|
|
||||||
const TYPE_SELECT = 'select';
|
const TYPE_SELECT = 'select';
|
||||||
const TYPE_STRING = 'string';
|
const TYPE_STRING = 'string';
|
||||||
const TYPE_INT = 'int';
|
const TYPE_INT = 'int';
|
||||||
const TYPE_BOOL = 'bool';
|
const TYPE_BOOL = 'bool';
|
||||||
const TYPE_DATE = 'date';
|
const TYPE_DATE = 'date';
|
||||||
|
const TYPE_REMARKUP = 'remarkup';
|
||||||
|
|
||||||
public function getFieldType() {
|
public function getFieldType() {
|
||||||
return $this->fieldType;
|
return $this->fieldType;
|
||||||
|
@ -97,6 +98,10 @@ class ManiphestAuxiliaryFieldDefaultSpecification
|
||||||
$control = new AphrontFormDateControl();
|
$control = new AphrontFormDateControl();
|
||||||
$control->setUser($this->getUser());
|
$control->setUser($this->getUser());
|
||||||
break;
|
break;
|
||||||
|
case self::TYPE_REMARKUP:
|
||||||
|
$control = new PhabricatorRemarkupControl();
|
||||||
|
$control->setUser($this->getUser());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$label = $this->getLabel();
|
$label = $this->getLabel();
|
||||||
throw new ManiphestAuxiliaryFieldTypeException(
|
throw new ManiphestAuxiliaryFieldTypeException(
|
||||||
|
@ -193,6 +198,14 @@ class ManiphestAuxiliaryFieldDefaultSpecification
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMarkupFields() {
|
||||||
|
switch ($this->getFieldType()) {
|
||||||
|
case self::TYPE_REMARKUP:
|
||||||
|
return array('default');
|
||||||
|
}
|
||||||
|
return parent::getMarkupFields();
|
||||||
|
}
|
||||||
|
|
||||||
public function renderForDetailView() {
|
public function renderForDetailView() {
|
||||||
switch ($this->getFieldType()) {
|
switch ($this->getFieldType()) {
|
||||||
case self::TYPE_BOOL:
|
case self::TYPE_BOOL:
|
||||||
|
@ -202,11 +215,13 @@ class ManiphestAuxiliaryFieldDefaultSpecification
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
case self::TYPE_SELECT:
|
case self::TYPE_SELECT:
|
||||||
$display = idx($this->getSelectOptions(), $this->getValue());
|
return idx($this->getSelectOptions(), $this->getValue());
|
||||||
return $display;
|
|
||||||
case self::TYPE_DATE:
|
case self::TYPE_DATE:
|
||||||
$display = phabricator_datetime($this->getValue(), $this->getUser());
|
return phabricator_datetime($this->getValue(), $this->getUser());
|
||||||
return $display;
|
case self::TYPE_REMARKUP:
|
||||||
|
return $this->getMarkupEngine()->getOutput(
|
||||||
|
$this,
|
||||||
|
'default');
|
||||||
}
|
}
|
||||||
return parent::renderForDetailView();
|
return parent::renderForDetailView();
|
||||||
}
|
}
|
||||||
|
@ -247,6 +262,10 @@ class ManiphestAuxiliaryFieldDefaultSpecification
|
||||||
"from '{$old_display}' to '{$new_display}'";
|
"from '{$old_display}' to '{$new_display}'";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case self::TYPE_REMARKUP:
|
||||||
|
// TODO: After we get ApplicationTransactions, straighten this out.
|
||||||
|
$desc = "updated field '{$label}'";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (!strlen($old)) {
|
if (!strlen($old)) {
|
||||||
if (!strlen($new)) {
|
if (!strlen($new)) {
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* @group maniphest
|
* @group maniphest
|
||||||
*/
|
*/
|
||||||
abstract class ManiphestAuxiliaryFieldSpecification {
|
abstract class ManiphestAuxiliaryFieldSpecification
|
||||||
|
implements PhabricatorMarkupInterface {
|
||||||
|
|
||||||
const RENDER_TARGET_HTML = 'html';
|
const RENDER_TARGET_HTML = 'html';
|
||||||
const RENDER_TARGET_TEXT = 'text';
|
const RENDER_TARGET_TEXT = 'text';
|
||||||
|
@ -14,6 +15,7 @@ abstract class ManiphestAuxiliaryFieldSpecification {
|
||||||
private $value;
|
private $value;
|
||||||
private $user;
|
private $user;
|
||||||
private $task;
|
private $task;
|
||||||
|
private $markupEngine;
|
||||||
|
|
||||||
public function setTask(ManiphestTask $task) {
|
public function setTask(ManiphestTask $task) {
|
||||||
$this->task = $task;
|
$this->task = $task;
|
||||||
|
@ -158,4 +160,52 @@ abstract class ManiphestAuxiliaryFieldSpecification {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getMarkupFields() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMarkupEngine(PhabricatorMarkupEngine $engine) {
|
||||||
|
$this->markupEngine = $engine;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMarkupEngine() {
|
||||||
|
return $this->markupEngine;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorMarkupInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
public function getMarkupFieldKey($field) {
|
||||||
|
$hash = PhabricatorHash::digestForIndex($this->getMarkupText($field));
|
||||||
|
return 'maux:'.$this->getAuxiliaryKey().':'.$hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function newMarkupEngine($field) {
|
||||||
|
return PhabricatorMarkupEngine::newManiphestMarkupEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getMarkupText($field) {
|
||||||
|
return $this->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function didMarkupText(
|
||||||
|
$field,
|
||||||
|
$output,
|
||||||
|
PhutilMarkupEngine $engine) {
|
||||||
|
return phutil_tag(
|
||||||
|
'div',
|
||||||
|
array(
|
||||||
|
'class' => 'phabricator-remarkup',
|
||||||
|
),
|
||||||
|
$output);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function shouldUseMarkupCache($field) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,11 +126,19 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
||||||
$engine->addObject($xaction, ManiphestTransaction::MARKUP_FIELD_BODY);
|
$engine->addObject($xaction, ManiphestTransaction::MARKUP_FIELD_BODY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$engine->process();
|
|
||||||
|
|
||||||
$extensions = ManiphestTaskExtensions::newExtensions();
|
$extensions = ManiphestTaskExtensions::newExtensions();
|
||||||
$aux_fields = $extensions->loadFields($task, $user);
|
$aux_fields = $extensions->loadFields($task, $user);
|
||||||
|
|
||||||
|
foreach ($aux_fields as $aux_field) {
|
||||||
|
foreach ($aux_field->getMarkupFields() as $markup_field) {
|
||||||
|
$engine->addObject($aux_field, $markup_field);
|
||||||
|
$aux_field->setMarkupEngine($engine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$engine->process();
|
||||||
|
|
||||||
$transaction_types = ManiphestTransactionType::getTransactionTypeMap();
|
$transaction_types = ManiphestTransactionType::getTransactionTypeMap();
|
||||||
$resolution_types = ManiphestTaskStatus::getTaskStatusMap();
|
$resolution_types = ManiphestTaskStatus::getTaskStatusMap();
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,8 @@ Each array key must be unique, and is used to organize the internal storage of
|
||||||
the field. These options are available:
|
the field. These options are available:
|
||||||
|
|
||||||
- **label**: Display label for the field on the edit and detail interfaces.
|
- **label**: Display label for the field on the edit and detail interfaces.
|
||||||
- **type**: Field type, one of **int**, **string**, **bool**, **select** or
|
- **type**: Field type, one of **int**, **string**, **bool**, **select**,
|
||||||
**date**.
|
**remarkup**, or **date**.
|
||||||
- **caption**: A caption to display underneath the field (optional).
|
- **caption**: A caption to display underneath the field (optional).
|
||||||
- **required**: True if the user should be required to provide a value.
|
- **required**: True if the user should be required to provide a value.
|
||||||
- **options**: If type is set to **select**, provide options for the dropdown
|
- **options**: If type is set to **select**, provide options for the dropdown
|
||||||
|
|
Loading…
Reference in a new issue