diff --git a/resources/sql/autopatches/20140109.projectcolumnsdates.sql b/resources/sql/autopatches/20140109.projectcolumnsdates.sql new file mode 100644 index 0000000000..96dda544e4 --- /dev/null +++ b/resources/sql/autopatches/20140109.projectcolumnsdates.sql @@ -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; diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index f592c344ea..a10670934b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1753,6 +1753,7 @@ phutil_register_library_map(array( 'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php', 'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php', 'PhabricatorProjectBoardController' => 'applications/project/controller/PhabricatorProjectBoardController.php', + 'PhabricatorProjectBoardEditController' => 'applications/project/controller/PhabricatorProjectBoardEditController.php', 'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php', 'PhabricatorProjectColumnQuery' => 'applications/project/query/PhabricatorProjectColumnQuery.php', 'PhabricatorProjectConstants' => 'applications/project/constants/PhabricatorProjectConstants.php', @@ -4362,6 +4363,7 @@ phutil_register_library_map(array( 2 => 'PhabricatorPolicyInterface', ), 'PhabricatorProjectBoardController' => 'PhabricatorProjectController', + 'PhabricatorProjectBoardEditController' => 'PhabricatorProjectController', 'PhabricatorProjectColumn' => array( 0 => 'PhabricatorProjectDAO', diff --git a/src/applications/project/application/PhabricatorApplicationProject.php b/src/applications/project/application/PhabricatorApplicationProject.php index ba7590a56c..7bb5beb9a3 100644 --- a/src/applications/project/application/PhabricatorApplicationProject.php +++ b/src/applications/project/application/PhabricatorApplicationProject.php @@ -46,6 +46,8 @@ final class PhabricatorApplicationProject extends PhabricatorApplication { 'PhabricatorProjectProfilePictureController', 'create/' => 'PhabricatorProjectCreateController', 'board/(?P[1-9]\d*)/' => 'PhabricatorProjectBoardController', + 'board/(?P[1-9]\d*)/edit/(?:(?P\d+)/)?' + => 'PhabricatorProjectBoardEditController', 'update/(?P[1-9]\d*)/(?P[^/]+)/' => 'PhabricatorProjectUpdateController', 'history/(?P[1-9]\d*)/' => 'PhabricatorProjectHistoryController', diff --git a/src/applications/project/controller/PhabricatorProjectBoardEditController.php b/src/applications/project/controller/PhabricatorProjectBoardEditController.php new file mode 100644 index 0000000000..1bf82d5a83 --- /dev/null +++ b/src/applications/project/controller/PhabricatorProjectBoardEditController.php @@ -0,0 +1,114 @@ +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, + )); + } +}