Move project icon editing into "Edit Details"
Summary: Ref T5482. Instead of editing icons and details seaparetly, use a bunch of Javascript to pop a dialog instead.
Test Plan: {F170528}
Reviewers: chad
Reviewed By: chad
Subscribers: epriestley
Maniphest Tasks: T5482
Differential Revision: https://secure.phabricator.com/D9743
This commit is contained in:
@@ -30,6 +30,7 @@ phutil_register_library_map(array(
|
||||
'AphrontException' => 'aphront/exception/AphrontException.php',
|
||||
'AphrontFileResponse' => 'aphront/response/AphrontFileResponse.php',
|
||||
'AphrontFormCheckboxControl' => 'view/form/control/AphrontFormCheckboxControl.php',
|
||||
'AphrontFormChooseButtonControl' => 'view/form/control/AphrontFormChooseButtonControl.php',
|
||||
'AphrontFormControl' => 'view/form/control/AphrontFormControl.php',
|
||||
'AphrontFormCropControl' => 'view/form/control/AphrontFormCropControl.php',
|
||||
'AphrontFormDateControl' => 'view/form/control/AphrontFormDateControl.php',
|
||||
@@ -2731,6 +2732,7 @@ phutil_register_library_map(array(
|
||||
'AphrontException' => 'Exception',
|
||||
'AphrontFileResponse' => 'AphrontResponse',
|
||||
'AphrontFormCheckboxControl' => 'AphrontFormControl',
|
||||
'AphrontFormChooseButtonControl' => 'AphrontFormControl',
|
||||
'AphrontFormControl' => 'AphrontView',
|
||||
'AphrontFormCropControl' => 'AphrontFormControl',
|
||||
'AphrontFormDateControl' => 'AphrontFormControl',
|
||||
|
||||
@@ -48,6 +48,7 @@ final class PhabricatorProjectEditDetailsController
|
||||
unset($project_slugs[$v_primary_slug]);
|
||||
$v_slugs = $project_slugs;
|
||||
$v_color = $project->getColor();
|
||||
$v_icon = $project->getIcon();
|
||||
|
||||
$validation_exception = null;
|
||||
|
||||
@@ -61,6 +62,7 @@ final class PhabricatorProjectEditDetailsController
|
||||
$v_edit = $request->getStr('can_edit');
|
||||
$v_join = $request->getStr('can_join');
|
||||
$v_color = $request->getStr('color');
|
||||
$v_icon = $request->getStr('icon');
|
||||
|
||||
$xactions = $field_list->buildFieldTransactionsFromRequest(
|
||||
new PhabricatorProjectTransaction(),
|
||||
@@ -69,6 +71,7 @@ final class PhabricatorProjectEditDetailsController
|
||||
$type_name = PhabricatorProjectTransaction::TYPE_NAME;
|
||||
$type_slugs = PhabricatorProjectTransaction::TYPE_SLUGS;
|
||||
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
$type_icon = PhabricatorProjectTransaction::TYPE_ICON;
|
||||
$type_color = PhabricatorProjectTransaction::TYPE_COLOR;
|
||||
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
@@ -91,6 +94,10 @@ final class PhabricatorProjectEditDetailsController
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)
|
||||
->setNewValue($v_join);
|
||||
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->setTransactionType($type_icon)
|
||||
->setNewValue($v_icon);
|
||||
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->setTransactionType($type_color)
|
||||
->setNewValue($v_color);
|
||||
@@ -143,7 +150,18 @@ final class PhabricatorProjectEditDetailsController
|
||||
array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
|
||||
unset($shades[PHUITagView::COLOR_DISABLED]);
|
||||
|
||||
$icon_uri = $this->getApplicationURI('icon/'.$project->getID().'/');
|
||||
$icon_display = PhabricatorProjectIcon::renderIconForChooser($v_icon);
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormChooseButtonControl())
|
||||
->setLabel(pht('Icon'))
|
||||
->setName('icon')
|
||||
->setDisplayValue($icon_display)
|
||||
->setButtonText(pht('Choose Icon...'))
|
||||
->setChooseURI($icon_uri)
|
||||
->setValue($v_icon))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Color'))
|
||||
|
||||
@@ -26,34 +26,22 @@ final class PhabricatorProjectEditIconController
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$view_uri = '/tag/'.$project->getPrimarySlug().'/';
|
||||
$edit_uri = $this->getApplicationURI('edit/'.$project->getID().'/');
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$xactions = array();
|
||||
|
||||
$v_icon = $request->getStr('icon');
|
||||
|
||||
$type_icon = PhabricatorProjectTransaction::TYPE_ICON;
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->setTransactionType($type_icon)
|
||||
->setNewValue($v_icon);
|
||||
|
||||
$editor = id(new PhabricatorProjectTransactionEditor())
|
||||
->setActor($viewer)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setContinueOnMissingFields(true)
|
||||
->setContinueOnNoEffect(true);
|
||||
|
||||
$editor->applyTransactions($project, $xactions);
|
||||
|
||||
return id(new AphrontReloadResponse())->setURI($edit_uri);
|
||||
}
|
||||
|
||||
require_celerity_resource('project-icon-css');
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$project_icons = PhabricatorProjectIcon::getIconMap();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$v_icon = $request->getStr('icon');
|
||||
|
||||
return id(new AphrontAjaxResponse())->setContent(
|
||||
array(
|
||||
'value' => $v_icon,
|
||||
'display' => PhabricatorProjectIcon::renderIconForChooser($v_icon),
|
||||
));
|
||||
}
|
||||
|
||||
$ii = 0;
|
||||
$buttons = array();
|
||||
foreach ($project_icons as $icon => $label) {
|
||||
|
||||
@@ -93,14 +93,6 @@ final class PhabricatorProjectEditMainController
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Edit Icon'))
|
||||
->setIcon($project->getIcon())
|
||||
->setHref($this->getApplicationURI("icon/{$id}/"))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(true));
|
||||
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Edit Picture'))
|
||||
|
||||
@@ -24,4 +24,18 @@ final class PhabricatorProjectIcon extends Phobject {
|
||||
$map = self::getIconMap();
|
||||
return $map[$key];
|
||||
}
|
||||
|
||||
public static function renderIconForChooser($icon) {
|
||||
$project_icons = PhabricatorProjectIcon::getIconMap();
|
||||
|
||||
return phutil_tag(
|
||||
'span',
|
||||
array(),
|
||||
array(
|
||||
id(new PHUIIconView())->setIconFont($icon),
|
||||
' ',
|
||||
idx($project_icons, $icon, pht('Unknown Icon')),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
96
src/view/form/control/AphrontFormChooseButtonControl.php
Normal file
96
src/view/form/control/AphrontFormChooseButtonControl.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
final class AphrontFormChooseButtonControl extends AphrontFormControl {
|
||||
|
||||
private $displayValue;
|
||||
private $buttonText;
|
||||
private $chooseURI;
|
||||
|
||||
public function setDisplayValue($display_value) {
|
||||
$this->displayValue = $display_value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDisplayValue() {
|
||||
return $this->displayValue;
|
||||
}
|
||||
|
||||
public function setButtonText($text) {
|
||||
$this->buttonText = $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setChooseURI($choose_uri) {
|
||||
$this->chooseURI = $choose_uri;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function getCustomControlClass() {
|
||||
return 'aphront-form-control-choose-button';
|
||||
}
|
||||
|
||||
protected function renderInput() {
|
||||
Javelin::initBehavior('choose-control');
|
||||
|
||||
$input_id = celerity_generate_unique_node_id();
|
||||
$display_id = celerity_generate_unique_node_id();
|
||||
|
||||
$display_value = $this->displayValue;
|
||||
$button = javelin_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '#',
|
||||
'class' => 'button grey',
|
||||
'sigil' => 'aphront-form-choose-button',
|
||||
),
|
||||
nonempty($this->buttonText, pht('Choose...')));
|
||||
|
||||
$display_cell = phutil_tag(
|
||||
'td',
|
||||
array(
|
||||
'class' => 'aphront-form-choose-display-cell',
|
||||
'id' => $display_id,
|
||||
),
|
||||
$display_value);
|
||||
|
||||
$button_cell = phutil_tag(
|
||||
'td',
|
||||
array(
|
||||
'class' => 'aphront-form-choose-button-cell',
|
||||
),
|
||||
$button);
|
||||
|
||||
$row = phutil_tag(
|
||||
'tr',
|
||||
array(),
|
||||
array($display_cell, $button_cell));
|
||||
|
||||
$layout = javelin_tag(
|
||||
'table',
|
||||
array(
|
||||
'class' => 'aphront-form-choose-table',
|
||||
'sigil' => 'aphront-form-choose',
|
||||
'meta' => array(
|
||||
'uri' => $this->chooseURI,
|
||||
'inputID' => $input_id,
|
||||
'displayID' => $display_id,
|
||||
),
|
||||
),
|
||||
$row);
|
||||
|
||||
$hidden_input = phutil_tag(
|
||||
'input',
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => $this->getName(),
|
||||
'value' => $this->getValue(),
|
||||
'id' => $input_id,
|
||||
));
|
||||
|
||||
return array(
|
||||
$hidden_input,
|
||||
$layout,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user