Page MenuHomePhorge

No OneTemporary

diff --git a/src/applications/project/controller/PhabricatorProjectEditDetailsController.php b/src/applications/project/controller/PhabricatorProjectEditDetailsController.php
index 6e67c6332f..f4cb1894df 100644
--- a/src/applications/project/controller/PhabricatorProjectEditDetailsController.php
+++ b/src/applications/project/controller/PhabricatorProjectEditDetailsController.php
@@ -1,195 +1,214 @@
<?php
final class PhabricatorProjectEditDetailsController
extends PhabricatorProjectController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$project = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->needSlugs(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$project) {
return new Aphront404Response();
}
$field_list = PhabricatorCustomField::getObjectFields(
$project,
PhabricatorCustomField::ROLE_EDIT);
$field_list
->setViewer($viewer)
->readFieldsFromStorage($project);
$view_uri = $this->getApplicationURI('view/'.$project->getID().'/');
$edit_uri = $this->getApplicationURI('edit/'.$project->getID().'/');
$e_name = true;
$e_slugs = false;
$e_edit = null;
$v_name = $project->getName();
$project_slugs = $project->getSlugs();
$project_slugs = mpull($project_slugs, 'getSlug', 'getSlug');
$v_primary_slug = $project->getPrimarySlug();
unset($project_slugs[$v_primary_slug]);
$v_slugs = $project_slugs;
+ $v_color = $project->getColor();
$validation_exception = null;
if ($request->isFormPost()) {
$e_name = null;
$e_slugs = null;
$v_name = $request->getStr('name');
$v_slugs = $request->getStrList('slugs');
$v_view = $request->getStr('can_view');
$v_edit = $request->getStr('can_edit');
$v_join = $request->getStr('can_join');
+ $v_color = $request->getStr('color');
$xactions = $field_list->buildFieldTransactionsFromRequest(
new PhabricatorProjectTransaction(),
$request);
$type_name = PhabricatorProjectTransaction::TYPE_NAME;
$type_slugs = PhabricatorProjectTransaction::TYPE_SLUGS;
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
+ $type_color = PhabricatorProjectTransaction::TYPE_COLOR;
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType($type_name)
->setNewValue($v_name);
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType($type_slugs)
->setNewValue($v_slugs);
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
->setNewValue($v_view);
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType($type_edit)
->setNewValue($v_edit);
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY)
->setNewValue($v_join);
+ $xactions[] = id(new PhabricatorProjectTransaction())
+ ->setTransactionType($type_color)
+ ->setNewValue($v_color);
+
$editor = id(new PhabricatorProjectTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true);
try {
$editor->applyTransactions($project, $xactions);
return id(new AphrontRedirectResponse())->setURI($edit_uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
$e_name = $ex->getShortMessage($type_name);
$e_slugs = $ex->getShortMessage($type_slugs);
$e_edit = $ex->getShortMessage($type_edit);
$project->setViewPolicy($v_view);
$project->setEditPolicy($v_edit);
$project->setJoinPolicy($v_join);
}
}
$header_name = pht('Edit Project');
$title = pht('Edit Project');
$policies = id(new PhabricatorPolicyQuery())
->setViewer($viewer)
->setObject($project)
->execute();
$v_slugs = implode(', ', $v_slugs);
$form = new AphrontFormView();
$form
->setUser($viewer)
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Name'))
->setName('name')
->setValue($v_name)
->setError($e_name));
$field_list->appendFieldsToForm($form);
+ $shades = PHUITagView::getShadeMap();
+ $shades = array_select_keys(
+ $shades,
+ array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
+ unset($shades[PHUITagView::COLOR_DISABLED]);
+
$form
+ ->appendChild(
+ id(new AphrontFormSelectControl())
+ ->setLabel(pht('Color'))
+ ->setName('color')
+ ->setValue($v_color)
+ ->setOptions($shades))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel(pht('Primary Hashtag'))
->setCaption(pht('The primary hashtag is derived from the name.'))
->setValue($v_primary_slug))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Additional Hashtags'))
->setCaption(pht(
'Specify a comma-separated list of additional hashtags.'))
->setName('slugs')
->setValue($v_slugs)
->setError($e_slugs))
->appendChild(
id(new AphrontFormPolicyControl())
->setUser($viewer)
->setName('can_view')
->setPolicyObject($project)
->setPolicies($policies)
->setCapability(PhabricatorPolicyCapability::CAN_VIEW))
->appendChild(
id(new AphrontFormPolicyControl())
->setUser($viewer)
->setName('can_edit')
->setPolicyObject($project)
->setPolicies($policies)
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
->setError($e_edit))
->appendChild(
id(new AphrontFormPolicyControl())
->setUser($viewer)
->setName('can_join')
->setCaption(
pht('Users who can edit a project can always join a project.'))
->setPolicyObject($project)
->setPolicies($policies)
->setCapability(PhabricatorPolicyCapability::CAN_JOIN))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($edit_uri)
->setValue(pht('Save')));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText($title)
->setValidationException($validation_exception)
->setForm($form);
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView())
->addTextCrumb($project->getName(), $view_uri)
->addTextCrumb(pht('Edit'), $edit_uri)
->addTextCrumb(pht('Details'));
return $this->buildApplicationPage(
array(
$crumbs,
$form_box,
),
array(
'title' => $title,
));
}
}
diff --git a/src/applications/project/controller/PhabricatorProjectEditIconController.php b/src/applications/project/controller/PhabricatorProjectEditIconController.php
index 885ec5033f..6b4f2abf41 100644
--- a/src/applications/project/controller/PhabricatorProjectEditIconController.php
+++ b/src/applications/project/controller/PhabricatorProjectEditIconController.php
@@ -1,134 +1,109 @@
<?php
final class PhabricatorProjectEditIconController
extends PhabricatorProjectController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$project = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$project) {
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');
- $v_icon_color = $request->getStr('color');
$type_icon = PhabricatorProjectTransaction::TYPE_ICON;
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType($type_icon)
->setNewValue($v_icon);
- $type_icon_color = PhabricatorProjectTransaction::TYPE_COLOR;
- $xactions[] = id(new PhabricatorProjectTransaction())
- ->setTransactionType($type_icon_color)
- ->setNewValue($v_icon_color);
-
$editor = id(new PhabricatorProjectTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($project, $xactions);
return id(new AphrontReloadResponse())->setURI($edit_uri);
}
- $shades = PHUITagView::getShadeMap();
- $shades = array_select_keys(
- $shades,
- array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
- unset($shades[PHUITagView::COLOR_DISABLED]);
-
- $color_form = id(new AphrontFormView())
- ->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel(pht('Color'))
- ->setName('color')
- ->setValue($project->getColor())
- ->setOptions($shades));
-
require_celerity_resource('project-icon-css');
Javelin::initBehavior('phabricator-tooltips');
$project_icons = PhabricatorProjectIcon::getIconMap();
$ii = 0;
$buttons = array();
foreach ($project_icons as $icon => $label) {
$view = id(new PHUIIconView())
->setIconFont($icon);
$aural = javelin_tag(
'span',
array(
'aural' => true,
),
pht('Choose "%s" Icon', $label));
if ($icon == $project->getIcon()) {
$class_extra = ' selected';
} else {
$class_extra = null;
}
$buttons[] = javelin_tag(
'button',
array(
'class' => 'icon-button'.$class_extra,
'name' => 'icon',
'value' => $icon,
'type' => 'submit',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $label,
)
),
array(
$aural,
$view,
));
if ((++$ii % 4) == 0) {
$buttons[] = phutil_tag('br');
}
}
$buttons = phutil_tag(
'div',
array(
'class' => 'icon-grid',
),
$buttons);
- $color_form->appendChild(
- id(new AphrontFormMarkupControl())
- ->setLabel(pht('Icon'))
- ->setValue($buttons));
-
return $this->newDialog()
->setTitle(pht('Choose Project Icon'))
- ->appendChild($color_form->buildLayoutView())
+ ->appendChild($buttons)
->addCancelButton($edit_uri);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 13:53 (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1125253
Default Alt Text
(11 KB)

Event Timeline