mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-01 02:10:59 +01:00
Adding the create flow for Project Board (Workphlow) columns.
Summary: This adds in the create flow for the Project board columns on the super secret board page which totally doesn't do anything right now. Test Plan: 1. Apply diff. 2. Go to super secret page. 3. Click link close to top with a way too long name. 4. Enter a name for the column. 5. Enjoy a new column briefly before realising you cannot remove it. 6. Stay happy! Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: tmaroschik, Korvin, epriestley, aran Differential Revision: https://secure.phabricator.com/D7925
This commit is contained in:
parent
efe187d5be
commit
5417f91b77
4 changed files with 123 additions and 0 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_project.project_column
|
||||||
|
ADD dateCreated INT UNSIGNED NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE {$NAMESPACE}_project.project_column
|
||||||
|
ADD dateModified INT UNSIGNED NOT NULL;
|
|
@ -1753,6 +1753,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php',
|
'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php',
|
||||||
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
|
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
|
||||||
'PhabricatorProjectBoardController' => 'applications/project/controller/PhabricatorProjectBoardController.php',
|
'PhabricatorProjectBoardController' => 'applications/project/controller/PhabricatorProjectBoardController.php',
|
||||||
|
'PhabricatorProjectBoardEditController' => 'applications/project/controller/PhabricatorProjectBoardEditController.php',
|
||||||
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
|
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
|
||||||
'PhabricatorProjectColumnQuery' => 'applications/project/query/PhabricatorProjectColumnQuery.php',
|
'PhabricatorProjectColumnQuery' => 'applications/project/query/PhabricatorProjectColumnQuery.php',
|
||||||
'PhabricatorProjectConstants' => 'applications/project/constants/PhabricatorProjectConstants.php',
|
'PhabricatorProjectConstants' => 'applications/project/constants/PhabricatorProjectConstants.php',
|
||||||
|
@ -4362,6 +4363,7 @@ phutil_register_library_map(array(
|
||||||
2 => 'PhabricatorPolicyInterface',
|
2 => 'PhabricatorPolicyInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
|
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
|
||||||
|
'PhabricatorProjectBoardEditController' => 'PhabricatorProjectController',
|
||||||
'PhabricatorProjectColumn' =>
|
'PhabricatorProjectColumn' =>
|
||||||
array(
|
array(
|
||||||
0 => 'PhabricatorProjectDAO',
|
0 => 'PhabricatorProjectDAO',
|
||||||
|
|
|
@ -46,6 +46,8 @@ final class PhabricatorApplicationProject extends PhabricatorApplication {
|
||||||
'PhabricatorProjectProfilePictureController',
|
'PhabricatorProjectProfilePictureController',
|
||||||
'create/' => 'PhabricatorProjectCreateController',
|
'create/' => 'PhabricatorProjectCreateController',
|
||||||
'board/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectBoardController',
|
'board/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectBoardController',
|
||||||
|
'board/(?P<projectID>[1-9]\d*)/edit/(?:(?P<id>\d+)/)?'
|
||||||
|
=> 'PhabricatorProjectBoardEditController',
|
||||||
'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/'
|
'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/'
|
||||||
=> 'PhabricatorProjectUpdateController',
|
=> 'PhabricatorProjectUpdateController',
|
||||||
'history/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectHistoryController',
|
'history/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectHistoryController',
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorProjectBoardEditController
|
||||||
|
extends PhabricatorProjectController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
private $projectID;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->projectID = $data['projectID'];
|
||||||
|
$this->id = idx($data, 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
|
$project = id(new PhabricatorProjectQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->requireCapabilities(
|
||||||
|
array(
|
||||||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||||||
|
))
|
||||||
|
->withIDs(array($this->projectID))
|
||||||
|
->executeOne();
|
||||||
|
|
||||||
|
if (!$project) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$is_new = ($this->id ? false : true);
|
||||||
|
|
||||||
|
if (!$is_new) {
|
||||||
|
// TODO: LATER!
|
||||||
|
throw new Exception("When I'm ready!");
|
||||||
|
} else {
|
||||||
|
$column = new PhabricatorProjectColumn();
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = array();
|
||||||
|
$e_name = true;
|
||||||
|
$error_view = null;
|
||||||
|
$view_uri = $this->getApplicationURI('/board/'.$this->projectID.'/');
|
||||||
|
|
||||||
|
if ($request->isFormPost()) {
|
||||||
|
$new_name = $request->getStr('name');
|
||||||
|
$column->setName($new_name);
|
||||||
|
|
||||||
|
if (!strlen($column->getName())) {
|
||||||
|
$errors[] = pht('Column name is required.');
|
||||||
|
$e_name = pht('Required');
|
||||||
|
} else {
|
||||||
|
$e_name = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$column->setProjectPHID($project->getPHID());
|
||||||
|
$column->attachProject($project);
|
||||||
|
$column->setSequence(0);
|
||||||
|
|
||||||
|
if (!$errors) {
|
||||||
|
$column->save();
|
||||||
|
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($errors) {
|
||||||
|
$error_view = new AphrontErrorView();
|
||||||
|
$error_view->setTitle(pht('Form Errors'));
|
||||||
|
$error_view->setErrors($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = new AphrontFormView();
|
||||||
|
$form->setUser($request->getUser())
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTextControl())
|
||||||
|
->setValue($column->getName())
|
||||||
|
->setLabel(pht('Name'))
|
||||||
|
->setName('name')
|
||||||
|
->setError($e_name)
|
||||||
|
->setCaption(
|
||||||
|
pht('This will be displayed as the header of the column.')));
|
||||||
|
|
||||||
|
if ($is_new) {
|
||||||
|
$title = pht('Create Column');
|
||||||
|
$submit = pht('Create Column');
|
||||||
|
} else {
|
||||||
|
$title = pht('Edit %s', $column->getName());
|
||||||
|
$submit = pht('Save Column');
|
||||||
|
}
|
||||||
|
|
||||||
|
$form->appendChild(
|
||||||
|
id(new AphrontFormSubmitControl())
|
||||||
|
->setValue($submit)
|
||||||
|
->addCancelButton($view_uri));
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
$crumbs->addTextCrumb($title);
|
||||||
|
|
||||||
|
$form_box = id(new PHUIObjectBoxView())
|
||||||
|
->setHeaderText($title)
|
||||||
|
->setFormError($errors)
|
||||||
|
->setForm($form);
|
||||||
|
|
||||||
|
return $this->buildApplicationPage(
|
||||||
|
array(
|
||||||
|
$crumbs,
|
||||||
|
$form_box,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'title' => $title,
|
||||||
|
'device' => true,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue