2014-01-10 01:09:38 +01:00
|
|
|
<?php
|
|
|
|
|
Allow columns to have a point limit
Summary:
Fixes T5885. This implements optional soft point limits for workboard columns, per traditional Kanban.
- Allow columns to have a point limit set.
- When a column has a point limit, show it in the header.
- If a column has too many points in it, show the column and point count in red.
@chad, this could probably use some design tweaks. In particular:
- I changed the color of "hidden" columns to avoid confusion with "overfull" columns. We might be able to find a better color.
- UI hints for overfull columns might need adjustment.
(After T4427, we'll let you sum some custom field instead of total number of tasks, which is why this is called "points" rather than "number of tasks".)
Test Plan:
{F190914}
Note that:
- "Pre-planning" has a limit, so it shows "4/12".
- "Planning" has a limit and is overfull, so it shows "5 / 4".
- Other columns do not have limits.
- "Post-planning" is a hidden column. This might be too muted now.
Transactions:
{F190915}
Error messages / edit screen:
{F190916}
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: chad, epriestley
Maniphest Tasks: T5885
Differential Revision: https://secure.phabricator.com/D10276
2014-08-15 20:16:08 +02:00
|
|
|
final class PhabricatorProjectColumnEditController
|
2014-03-26 22:40:47 +01:00
|
|
|
extends PhabricatorProjectBoardController {
|
2014-01-10 01:09:38 +01:00
|
|
|
|
2015-08-08 19:34:55 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $request->getViewer();
|
|
|
|
$id = $request->getURIData('id');
|
|
|
|
$project_id = $request->getURIData('projectID');
|
2014-01-10 01:09:38 +01:00
|
|
|
|
|
|
|
$project = id(new PhabricatorProjectQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
2015-08-08 19:34:55 +02:00
|
|
|
->withIDs(array($project_id))
|
2015-01-12 19:04:01 +01:00
|
|
|
->needImages(true)
|
2014-01-10 01:09:38 +01:00
|
|
|
->executeOne();
|
|
|
|
|
|
|
|
if (!$project) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
2014-03-26 22:40:47 +01:00
|
|
|
$this->setProject($project);
|
2014-01-10 01:09:38 +01:00
|
|
|
|
2015-08-08 19:34:55 +02:00
|
|
|
$is_new = ($id ? false : true);
|
2014-01-10 01:09:38 +01:00
|
|
|
|
|
|
|
if (!$is_new) {
|
2014-01-12 03:16:26 +01:00
|
|
|
$column = id(new PhabricatorProjectColumnQuery())
|
|
|
|
->setViewer($viewer)
|
2015-08-08 19:34:55 +02:00
|
|
|
->withIDs(array($id))
|
2014-01-12 03:16:26 +01:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->executeOne();
|
|
|
|
if (!$column) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
2014-01-10 01:09:38 +01:00
|
|
|
} else {
|
2014-01-13 06:40:02 +01:00
|
|
|
$column = PhabricatorProjectColumn::initializeNewColumn($viewer);
|
2014-01-10 01:09:38 +01:00
|
|
|
}
|
|
|
|
|
2014-03-26 22:40:47 +01:00
|
|
|
$e_name = null;
|
Allow columns to have a point limit
Summary:
Fixes T5885. This implements optional soft point limits for workboard columns, per traditional Kanban.
- Allow columns to have a point limit set.
- When a column has a point limit, show it in the header.
- If a column has too many points in it, show the column and point count in red.
@chad, this could probably use some design tweaks. In particular:
- I changed the color of "hidden" columns to avoid confusion with "overfull" columns. We might be able to find a better color.
- UI hints for overfull columns might need adjustment.
(After T4427, we'll let you sum some custom field instead of total number of tasks, which is why this is called "points" rather than "number of tasks".)
Test Plan:
{F190914}
Note that:
- "Pre-planning" has a limit, so it shows "4/12".
- "Planning" has a limit and is overfull, so it shows "5 / 4".
- Other columns do not have limits.
- "Post-planning" is a hidden column. This might be too muted now.
Transactions:
{F190915}
Error messages / edit screen:
{F190916}
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: chad, epriestley
Maniphest Tasks: T5885
Differential Revision: https://secure.phabricator.com/D10276
2014-08-15 20:16:08 +02:00
|
|
|
$e_limit = null;
|
|
|
|
|
|
|
|
$v_limit = $column->getPointLimit();
|
|
|
|
$v_name = $column->getName();
|
|
|
|
|
2014-03-26 22:40:47 +01:00
|
|
|
$validation_exception = null;
|
2015-08-08 19:34:55 +02:00
|
|
|
$base_uri = '/board/'.$project_id.'/';
|
2014-03-26 22:40:47 +01:00
|
|
|
if ($is_new) {
|
|
|
|
// we want to go back to the board
|
|
|
|
$view_uri = $this->getApplicationURI($base_uri);
|
|
|
|
} else {
|
2015-08-08 19:34:55 +02:00
|
|
|
$view_uri = $this->getApplicationURI($base_uri.'column/'.$id.'/');
|
2014-03-26 22:40:47 +01:00
|
|
|
}
|
2014-01-10 01:09:38 +01:00
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
Allow columns to have a point limit
Summary:
Fixes T5885. This implements optional soft point limits for workboard columns, per traditional Kanban.
- Allow columns to have a point limit set.
- When a column has a point limit, show it in the header.
- If a column has too many points in it, show the column and point count in red.
@chad, this could probably use some design tweaks. In particular:
- I changed the color of "hidden" columns to avoid confusion with "overfull" columns. We might be able to find a better color.
- UI hints for overfull columns might need adjustment.
(After T4427, we'll let you sum some custom field instead of total number of tasks, which is why this is called "points" rather than "number of tasks".)
Test Plan:
{F190914}
Note that:
- "Pre-planning" has a limit, so it shows "4/12".
- "Planning" has a limit and is overfull, so it shows "5 / 4".
- Other columns do not have limits.
- "Post-planning" is a hidden column. This might be too muted now.
Transactions:
{F190915}
Error messages / edit screen:
{F190916}
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: chad, epriestley
Maniphest Tasks: T5885
Differential Revision: https://secure.phabricator.com/D10276
2014-08-15 20:16:08 +02:00
|
|
|
$v_name = $request->getStr('name');
|
|
|
|
$v_limit = $request->getStr('limit');
|
2014-01-10 01:09:38 +01:00
|
|
|
|
2014-01-12 03:16:26 +01:00
|
|
|
if ($is_new) {
|
|
|
|
$column->setProjectPHID($project->getPHID());
|
|
|
|
$column->attachProject($project);
|
|
|
|
|
|
|
|
$columns = id(new PhabricatorProjectColumnQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withProjectPHIDs(array($project->getPHID()))
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$new_sequence = 1;
|
|
|
|
if ($columns) {
|
|
|
|
$values = mpull($columns, 'getSequence');
|
|
|
|
$new_sequence = max($values) + 1;
|
|
|
|
}
|
|
|
|
$column->setSequence($new_sequence);
|
|
|
|
}
|
2014-01-10 01:09:38 +01:00
|
|
|
|
Allow columns to have a point limit
Summary:
Fixes T5885. This implements optional soft point limits for workboard columns, per traditional Kanban.
- Allow columns to have a point limit set.
- When a column has a point limit, show it in the header.
- If a column has too many points in it, show the column and point count in red.
@chad, this could probably use some design tweaks. In particular:
- I changed the color of "hidden" columns to avoid confusion with "overfull" columns. We might be able to find a better color.
- UI hints for overfull columns might need adjustment.
(After T4427, we'll let you sum some custom field instead of total number of tasks, which is why this is called "points" rather than "number of tasks".)
Test Plan:
{F190914}
Note that:
- "Pre-planning" has a limit, so it shows "4/12".
- "Planning" has a limit and is overfull, so it shows "5 / 4".
- Other columns do not have limits.
- "Post-planning" is a hidden column. This might be too muted now.
Transactions:
{F190915}
Error messages / edit screen:
{F190916}
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: chad, epriestley
Maniphest Tasks: T5885
Differential Revision: https://secure.phabricator.com/D10276
2014-08-15 20:16:08 +02:00
|
|
|
$xactions = array();
|
|
|
|
|
2016-02-04 16:50:58 +01:00
|
|
|
if (!$column->getProxy()) {
|
|
|
|
$type_name = PhabricatorProjectColumnTransaction::TYPE_NAME;
|
|
|
|
$xactions[] = id(new PhabricatorProjectColumnTransaction())
|
|
|
|
->setTransactionType($type_name)
|
|
|
|
->setNewValue($v_name);
|
|
|
|
}
|
Allow columns to have a point limit
Summary:
Fixes T5885. This implements optional soft point limits for workboard columns, per traditional Kanban.
- Allow columns to have a point limit set.
- When a column has a point limit, show it in the header.
- If a column has too many points in it, show the column and point count in red.
@chad, this could probably use some design tweaks. In particular:
- I changed the color of "hidden" columns to avoid confusion with "overfull" columns. We might be able to find a better color.
- UI hints for overfull columns might need adjustment.
(After T4427, we'll let you sum some custom field instead of total number of tasks, which is why this is called "points" rather than "number of tasks".)
Test Plan:
{F190914}
Note that:
- "Pre-planning" has a limit, so it shows "4/12".
- "Planning" has a limit and is overfull, so it shows "5 / 4".
- Other columns do not have limits.
- "Post-planning" is a hidden column. This might be too muted now.
Transactions:
{F190915}
Error messages / edit screen:
{F190916}
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: chad, epriestley
Maniphest Tasks: T5885
Differential Revision: https://secure.phabricator.com/D10276
2014-08-15 20:16:08 +02:00
|
|
|
|
|
|
|
$type_limit = PhabricatorProjectColumnTransaction::TYPE_LIMIT;
|
|
|
|
$xactions[] = id(new PhabricatorProjectColumnTransaction())
|
|
|
|
->setTransactionType($type_limit)
|
|
|
|
->setNewValue($v_limit);
|
2014-03-26 22:40:47 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
$editor = id(new PhabricatorProjectColumnTransactionEditor())
|
|
|
|
->setActor($viewer)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->applyTransactions($column, $xactions);
|
2014-01-10 01:09:38 +01:00
|
|
|
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
2014-03-26 22:40:47 +01:00
|
|
|
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
|
|
|
$e_name = $ex->getShortMessage($type_name);
|
Allow columns to have a point limit
Summary:
Fixes T5885. This implements optional soft point limits for workboard columns, per traditional Kanban.
- Allow columns to have a point limit set.
- When a column has a point limit, show it in the header.
- If a column has too many points in it, show the column and point count in red.
@chad, this could probably use some design tweaks. In particular:
- I changed the color of "hidden" columns to avoid confusion with "overfull" columns. We might be able to find a better color.
- UI hints for overfull columns might need adjustment.
(After T4427, we'll let you sum some custom field instead of total number of tasks, which is why this is called "points" rather than "number of tasks".)
Test Plan:
{F190914}
Note that:
- "Pre-planning" has a limit, so it shows "4/12".
- "Planning" has a limit and is overfull, so it shows "5 / 4".
- Other columns do not have limits.
- "Post-planning" is a hidden column. This might be too muted now.
Transactions:
{F190915}
Error messages / edit screen:
{F190916}
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: chad, epriestley
Maniphest Tasks: T5885
Differential Revision: https://secure.phabricator.com/D10276
2014-08-15 20:16:08 +02:00
|
|
|
$e_limit = $ex->getShortMessage($type_limit);
|
2014-03-26 22:40:47 +01:00
|
|
|
$validation_exception = $ex;
|
2014-01-10 01:09:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-04 16:50:58 +01:00
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($request->getUser());
|
|
|
|
|
|
|
|
if (!$column->getProxy()) {
|
|
|
|
$form->appendChild(
|
2014-01-10 01:09:38 +01:00
|
|
|
id(new AphrontFormTextControl())
|
Allow columns to have a point limit
Summary:
Fixes T5885. This implements optional soft point limits for workboard columns, per traditional Kanban.
- Allow columns to have a point limit set.
- When a column has a point limit, show it in the header.
- If a column has too many points in it, show the column and point count in red.
@chad, this could probably use some design tweaks. In particular:
- I changed the color of "hidden" columns to avoid confusion with "overfull" columns. We might be able to find a better color.
- UI hints for overfull columns might need adjustment.
(After T4427, we'll let you sum some custom field instead of total number of tasks, which is why this is called "points" rather than "number of tasks".)
Test Plan:
{F190914}
Note that:
- "Pre-planning" has a limit, so it shows "4/12".
- "Planning" has a limit and is overfull, so it shows "5 / 4".
- Other columns do not have limits.
- "Post-planning" is a hidden column. This might be too muted now.
Transactions:
{F190915}
Error messages / edit screen:
{F190916}
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: chad, epriestley
Maniphest Tasks: T5885
Differential Revision: https://secure.phabricator.com/D10276
2014-08-15 20:16:08 +02:00
|
|
|
->setValue($v_name)
|
2014-01-10 01:09:38 +01:00
|
|
|
->setLabel(pht('Name'))
|
|
|
|
->setName('name')
|
2016-02-04 16:50:58 +01:00
|
|
|
->setError($e_name));
|
|
|
|
}
|
Allow columns to have a point limit
Summary:
Fixes T5885. This implements optional soft point limits for workboard columns, per traditional Kanban.
- Allow columns to have a point limit set.
- When a column has a point limit, show it in the header.
- If a column has too many points in it, show the column and point count in red.
@chad, this could probably use some design tweaks. In particular:
- I changed the color of "hidden" columns to avoid confusion with "overfull" columns. We might be able to find a better color.
- UI hints for overfull columns might need adjustment.
(After T4427, we'll let you sum some custom field instead of total number of tasks, which is why this is called "points" rather than "number of tasks".)
Test Plan:
{F190914}
Note that:
- "Pre-planning" has a limit, so it shows "4/12".
- "Planning" has a limit and is overfull, so it shows "5 / 4".
- Other columns do not have limits.
- "Post-planning" is a hidden column. This might be too muted now.
Transactions:
{F190915}
Error messages / edit screen:
{F190916}
Reviewers: btrahan, chad
Reviewed By: btrahan
Subscribers: chad, epriestley
Maniphest Tasks: T5885
Differential Revision: https://secure.phabricator.com/D10276
2014-08-15 20:16:08 +02:00
|
|
|
|
2016-02-04 16:50:58 +01:00
|
|
|
$form->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setValue($v_limit)
|
|
|
|
->setLabel(pht('Point Limit'))
|
|
|
|
->setName('limit')
|
|
|
|
->setError($e_limit)
|
|
|
|
->setCaption(
|
|
|
|
pht('Maximum number of points of tasks allowed in the column.')));
|
2014-01-10 01:09:38 +01:00
|
|
|
|
|
|
|
if ($is_new) {
|
|
|
|
$title = pht('Create Column');
|
|
|
|
$submit = pht('Create Column');
|
|
|
|
} else {
|
2014-06-25 21:30:43 +02:00
|
|
|
$title = pht('Edit %s', $column->getDisplayName());
|
2014-01-10 01:09:38 +01:00
|
|
|
$submit = pht('Save Column');
|
|
|
|
}
|
|
|
|
|
|
|
|
$form->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue($submit)
|
|
|
|
->addCancelButton($view_uri));
|
|
|
|
|
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText($title)
|
2014-03-26 22:40:47 +01:00
|
|
|
->setValidationException($validation_exception)
|
2014-01-10 01:09:38 +01:00
|
|
|
->setForm($form);
|
|
|
|
|
2016-01-12 23:15:59 +01:00
|
|
|
$nav = $this->getProfileMenu();
|
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
->setTitle($title)
|
|
|
|
->setNavigation($nav)
|
|
|
|
->appendChild($form_box);
|
2014-01-10 01:09:38 +01:00
|
|
|
}
|
|
|
|
}
|