1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Support field previews in EditEngine

Summary: Ref T10004. This primarily supports moving Phame to EditEngine.

Test Plan: {F1045166}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10004

Differential Revision: https://secure.phabricator.com/D14887
This commit is contained in:
epriestley 2015-12-26 13:00:01 -08:00
parent 367955f3fd
commit aa2089ba68
8 changed files with 85 additions and 34 deletions

View file

@ -8,7 +8,7 @@
return array( return array(
'names' => array( 'names' => array(
'core.pkg.css' => 'a419cf4b', 'core.pkg.css' => 'a419cf4b',
'core.pkg.js' => '400453e4', 'core.pkg.js' => '57dff7df',
'darkconsole.pkg.js' => 'e7393ebb', 'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '2de124c9', 'differential.pkg.css' => '2de124c9',
'differential.pkg.js' => '64e69521', 'differential.pkg.js' => '64e69521',
@ -487,9 +487,9 @@ return array(
'rsrc/js/core/behavior-object-selector.js' => '49b73b36', 'rsrc/js/core/behavior-object-selector.js' => '49b73b36',
'rsrc/js/core/behavior-oncopy.js' => '2926fff2', 'rsrc/js/core/behavior-oncopy.js' => '2926fff2',
'rsrc/js/core/behavior-phabricator-nav.js' => '56a1ca03', 'rsrc/js/core/behavior-phabricator-nav.js' => '56a1ca03',
'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => 'ecddcbe2', 'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => 'b60b6d9b',
'rsrc/js/core/behavior-refresh-csrf.js' => 'ab2f381b', 'rsrc/js/core/behavior-refresh-csrf.js' => 'ab2f381b',
'rsrc/js/core/behavior-remarkup-preview.js' => 'f7379f45', 'rsrc/js/core/behavior-remarkup-preview.js' => '4b700e9e',
'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e', 'rsrc/js/core/behavior-reorder-applications.js' => '76b9fc3e',
'rsrc/js/core/behavior-reveal-content.js' => '60821bc7', 'rsrc/js/core/behavior-reveal-content.js' => '60821bc7',
'rsrc/js/core/behavior-scrollbar.js' => '834a1173', 'rsrc/js/core/behavior-scrollbar.js' => '834a1173',
@ -640,7 +640,7 @@ return array(
'javelin-behavior-phabricator-notification-example' => '8ce821c5', 'javelin-behavior-phabricator-notification-example' => '8ce821c5',
'javelin-behavior-phabricator-object-selector' => '49b73b36', 'javelin-behavior-phabricator-object-selector' => '49b73b36',
'javelin-behavior-phabricator-oncopy' => '2926fff2', 'javelin-behavior-phabricator-oncopy' => '2926fff2',
'javelin-behavior-phabricator-remarkup-assist' => 'ecddcbe2', 'javelin-behavior-phabricator-remarkup-assist' => 'b60b6d9b',
'javelin-behavior-phabricator-reveal-content' => '60821bc7', 'javelin-behavior-phabricator-reveal-content' => '60821bc7',
'javelin-behavior-phabricator-search-typeahead' => '048330fa', 'javelin-behavior-phabricator-search-typeahead' => '048330fa',
'javelin-behavior-phabricator-show-older-transactions' => 'dbbf48b6', 'javelin-behavior-phabricator-show-older-transactions' => 'dbbf48b6',
@ -662,7 +662,7 @@ return array(
'javelin-behavior-releeph-preview-branch' => 'b2b4fbaf', 'javelin-behavior-releeph-preview-branch' => 'b2b4fbaf',
'javelin-behavior-releeph-request-state-change' => 'a0b57eb8', 'javelin-behavior-releeph-request-state-change' => 'a0b57eb8',
'javelin-behavior-releeph-request-typeahead' => 'de2e896f', 'javelin-behavior-releeph-request-typeahead' => 'de2e896f',
'javelin-behavior-remarkup-preview' => 'f7379f45', 'javelin-behavior-remarkup-preview' => '4b700e9e',
'javelin-behavior-reorder-applications' => '76b9fc3e', 'javelin-behavior-reorder-applications' => '76b9fc3e',
'javelin-behavior-reorder-columns' => 'e1d25dfb', 'javelin-behavior-reorder-columns' => 'e1d25dfb',
'javelin-behavior-repository-crossreference' => 'e5339c43', 'javelin-behavior-repository-crossreference' => 'e5339c43',
@ -1125,6 +1125,12 @@ return array(
'javelin-request', 'javelin-request',
'javelin-util', 'javelin-util',
), ),
'4b700e9e' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'phabricator-shaped-request',
),
'4e3e79a6' => array( '4e3e79a6' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',
@ -1721,6 +1727,15 @@ return array(
'javelin-dom', 'javelin-dom',
'javelin-util', 'javelin-util',
), ),
'b60b6d9b' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-phtize',
'phabricator-textareautils',
'javelin-workflow',
'javelin-vector',
),
'b65559c0' => array( 'b65559c0' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',
@ -1960,15 +1975,6 @@ return array(
'phabricator-phtize', 'phabricator-phtize',
'javelin-dom', 'javelin-dom',
), ),
'ecddcbe2' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-phtize',
'phabricator-textareautils',
'javelin-workflow',
'javelin-vector',
),
'edd1ba66' => array( 'edd1ba66' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',
@ -2005,12 +2011,6 @@ return array(
'javelin-util', 'javelin-util',
'javelin-reactor', 'javelin-reactor',
), ),
'f7379f45' => array(
'javelin-behavior',
'javelin-dom',
'javelin-util',
'phabricator-shaped-request',
),
'f7fc67ec' => array( 'f7fc67ec' => array(
'javelin-install', 'javelin-install',
'javelin-typeahead', 'javelin-typeahead',

View file

@ -52,13 +52,6 @@ final class PhabricatorManiphestApplication extends PhabricatorApplication {
'task/' => array( 'task/' => array(
$this->getEditRoutePattern('edit/') $this->getEditRoutePattern('edit/')
=> 'ManiphestTaskEditController', => 'ManiphestTaskEditController',
'descriptionpreview/'
=> 'PhabricatorMarkupPreviewController',
),
'transaction/' => array(
'save/' => 'ManiphestTransactionSaveController',
'preview/(?P<id>[1-9]\d*)/'
=> 'ManiphestTransactionPreviewController',
), ),
'export/(?P<key>[^/]+)/' => 'ManiphestExportController', 'export/(?P<key>[^/]+)/' => 'ManiphestExportController',
'subpriority/' => 'ManiphestSubpriorityController', 'subpriority/' => 'ManiphestSubpriorityController',

View file

@ -156,7 +156,10 @@ final class ManiphestEditEngine
->setConduitDescription(pht('Update the task description.')) ->setConduitDescription(pht('Update the task description.'))
->setConduitTypeDescription(pht('New task description.')) ->setConduitTypeDescription(pht('New task description.'))
->setTransactionType(ManiphestTransaction::TYPE_DESCRIPTION) ->setTransactionType(ManiphestTransaction::TYPE_DESCRIPTION)
->setValue($object->getDescription()), ->setValue($object->getDescription())
->setPreviewPanel(
id(new PHUIRemarkupPreviewPanel())
->setHeader(pht('Description Preview'))),
); );
} }

View file

@ -10,9 +10,9 @@ final class PhabricatorApplicationTransactionRemarkupPreviewController
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$corpus = $request->getStr('corpus'); $text = $request->getStr('text');
$remarkup = new PHUIRemarkupView($viewer, $corpus); $remarkup = new PHUIRemarkupView($viewer, $text);
$content = array( $content = array(
'content' => hsprintf('%s', $remarkup), 'content' => hsprintf('%s', $remarkup),

View file

@ -962,6 +962,28 @@ abstract class PhabricatorEditEngine
$header_text = $this->getObjectEditTitleText($object); $header_text = $this->getObjectEditTitleText($object);
} }
$show_preview = !$request->isAjax();
if ($show_preview) {
$previews = array();
foreach ($fields as $field) {
$preview = $field->getPreviewPanel();
if (!$preview) {
continue;
}
$control_id = $field->getControlID();
$preview
->setControlID($control_id)
->setPreviewURI('/transactions/remarkuppreview/');
$previews[] = $preview;
}
} else {
$previews = array();
}
$form = $this->buildEditForm($object, $fields); $form = $this->buildEditForm($object, $fields);
if ($request->isAjax()) { if ($request->isAjax()) {
@ -998,7 +1020,8 @@ abstract class PhabricatorEditEngine
return $controller->newPage() return $controller->newPage()
->setTitle($header_text) ->setTitle($header_text)
->setCrumbs($crumbs) ->setCrumbs($crumbs)
->appendChild($box); ->appendChild($box)
->appendChild($previews);
} }
protected function newEditResponse( protected function newEditResponse(

View file

@ -14,6 +14,8 @@ abstract class PhabricatorEditField extends Phobject {
private $metadata = array(); private $metadata = array();
private $editTypeKey; private $editTypeKey;
private $isRequired; private $isRequired;
private $previewPanel;
private $controlID;
private $description; private $description;
private $conduitDescription; private $conduitDescription;
@ -251,6 +253,15 @@ abstract class PhabricatorEditField extends Phobject {
return $this->commentActionValue; return $this->commentActionValue;
} }
public function setPreviewPanel(PHUIRemarkupPreviewPanel $preview_panel) {
$this->previewPanel = $preview_panel;
return $this;
}
public function getPreviewPanel() {
return $this->previewPanel;
}
protected function newControl() { protected function newControl() {
throw new PhutilMethodNotImplementedException(); throw new PhutilMethodNotImplementedException();
} }
@ -285,6 +296,13 @@ abstract class PhabricatorEditField extends Phobject {
return $control; return $control;
} }
public function getControlID() {
if (!$this->controlID) {
$this->controlID = celerity_generate_unique_node_id();
}
return $this->controlID;
}
protected function renderControl() { protected function renderControl() {
$control = $this->buildControl(); $control = $this->buildControl();
if ($control === null) { if ($control === null) {
@ -308,6 +326,10 @@ abstract class PhabricatorEditField extends Phobject {
$control->setDisabled($disabled); $control->setDisabled($disabled);
if ($this->controlID) {
$control->setID($this->controlID);
}
return $control; return $control;
} }

View file

@ -254,7 +254,7 @@ JX.behavior('phabricator-remarkup-assist', function(config) {
var value = area.value; var value = area.value;
var data = { var data = {
corpus: value text: value
}; };
var onupdate = function(r) { var onupdate = function(r) {

View file

@ -8,16 +8,26 @@
JX.behavior('remarkup-preview', function(config) { JX.behavior('remarkup-preview', function(config) {
// Don't bother with any of this on mobile.
if (JX.Device.getDevice() !== 'desktop') {
return;
}
var preview = JX.$(config.previewID); var preview = JX.$(config.previewID);
var control = JX.$(config.controlID); var control = JX.$(config.controlID);
var callback = function(r) { var callback = function(r) {
JX.DOM.setContent(preview, JX.$H(r)); // This currently accepts responses from two controllers:
// Old: PhabricatorMarkupPreviewController
// New: PhabricatorApplicationTransactionRemarkupPreviewController
// TODO: Swap everything to just the new controller.
JX.DOM.setContent(preview, JX.$H(r.content || r));
}; };
var getdata = function() { var getdata = function() {
return { return {
text : control.value text: control.value
}; };
}; };