Skip to content

Commit 5417f91

Browse files
miknepriestley
authored andcommitted
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
1 parent efe187d commit 5417f91

File tree

4 files changed

+123
-0
lines changed

4 files changed

+123
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE {$NAMESPACE}_project.project_column
2+
ADD dateCreated INT UNSIGNED NOT NULL;
3+
4+
ALTER TABLE {$NAMESPACE}_project.project_column
5+
ADD dateModified INT UNSIGNED NOT NULL;

src/__phutil_library_map__.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,7 @@
17531753
'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php',
17541754
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
17551755
'PhabricatorProjectBoardController' => 'applications/project/controller/PhabricatorProjectBoardController.php',
1756+
'PhabricatorProjectBoardEditController' => 'applications/project/controller/PhabricatorProjectBoardEditController.php',
17561757
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
17571758
'PhabricatorProjectColumnQuery' => 'applications/project/query/PhabricatorProjectColumnQuery.php',
17581759
'PhabricatorProjectConstants' => 'applications/project/constants/PhabricatorProjectConstants.php',
@@ -4362,6 +4363,7 @@
43624363
2 => 'PhabricatorPolicyInterface',
43634364
),
43644365
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
4366+
'PhabricatorProjectBoardEditController' => 'PhabricatorProjectController',
43654367
'PhabricatorProjectColumn' =>
43664368
array(
43674369
0 => 'PhabricatorProjectDAO',

src/applications/project/application/PhabricatorApplicationProject.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public function getRoutes() {
4646
'PhabricatorProjectProfilePictureController',
4747
'create/' => 'PhabricatorProjectCreateController',
4848
'board/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectBoardController',
49+
'board/(?P<projectID>[1-9]\d*)/edit/(?:(?P<id>\d+)/)?'
50+
=> 'PhabricatorProjectBoardEditController',
4951
'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/'
5052
=> 'PhabricatorProjectUpdateController',
5153
'history/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectHistoryController',
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
3+
final class PhabricatorProjectBoardEditController
4+
extends PhabricatorProjectController {
5+
6+
private $id;
7+
private $projectID;
8+
9+
public function willProcessRequest(array $data) {
10+
$this->projectID = $data['projectID'];
11+
$this->id = idx($data, 'id');
12+
}
13+
14+
public function processRequest() {
15+
$request = $this->getRequest();
16+
$viewer = $request->getUser();
17+
18+
$project = id(new PhabricatorProjectQuery())
19+
->setViewer($viewer)
20+
->requireCapabilities(
21+
array(
22+
PhabricatorPolicyCapability::CAN_VIEW,
23+
PhabricatorPolicyCapability::CAN_EDIT,
24+
))
25+
->withIDs(array($this->projectID))
26+
->executeOne();
27+
28+
if (!$project) {
29+
return new Aphront404Response();
30+
}
31+
32+
$is_new = ($this->id ? false : true);
33+
34+
if (!$is_new) {
35+
// TODO: LATER!
36+
throw new Exception("When I'm ready!");
37+
} else {
38+
$column = new PhabricatorProjectColumn();
39+
}
40+
41+
$errors = array();
42+
$e_name = true;
43+
$error_view = null;
44+
$view_uri = $this->getApplicationURI('/board/'.$this->projectID.'/');
45+
46+
if ($request->isFormPost()) {
47+
$new_name = $request->getStr('name');
48+
$column->setName($new_name);
49+
50+
if (!strlen($column->getName())) {
51+
$errors[] = pht('Column name is required.');
52+
$e_name = pht('Required');
53+
} else {
54+
$e_name = null;
55+
}
56+
57+
$column->setProjectPHID($project->getPHID());
58+
$column->attachProject($project);
59+
$column->setSequence(0);
60+
61+
if (!$errors) {
62+
$column->save();
63+
return id(new AphrontRedirectResponse())->setURI($view_uri);
64+
}
65+
}
66+
if ($errors) {
67+
$error_view = new AphrontErrorView();
68+
$error_view->setTitle(pht('Form Errors'));
69+
$error_view->setErrors($errors);
70+
}
71+
72+
$form = new AphrontFormView();
73+
$form->setUser($request->getUser())
74+
->appendChild(
75+
id(new AphrontFormTextControl())
76+
->setValue($column->getName())
77+
->setLabel(pht('Name'))
78+
->setName('name')
79+
->setError($e_name)
80+
->setCaption(
81+
pht('This will be displayed as the header of the column.')));
82+
83+
if ($is_new) {
84+
$title = pht('Create Column');
85+
$submit = pht('Create Column');
86+
} else {
87+
$title = pht('Edit %s', $column->getName());
88+
$submit = pht('Save Column');
89+
}
90+
91+
$form->appendChild(
92+
id(new AphrontFormSubmitControl())
93+
->setValue($submit)
94+
->addCancelButton($view_uri));
95+
96+
$crumbs = $this->buildApplicationCrumbs();
97+
$crumbs->addTextCrumb($title);
98+
99+
$form_box = id(new PHUIObjectBoxView())
100+
->setHeaderText($title)
101+
->setFormError($errors)
102+
->setForm($form);
103+
104+
return $this->buildApplicationPage(
105+
array(
106+
$crumbs,
107+
$form_box,
108+
),
109+
array(
110+
'title' => $title,
111+
'device' => true,
112+
));
113+
}
114+
}

0 commit comments

Comments
 (0)