2011-02-08 19:53:59 +01:00
|
|
|
<?php
|
|
|
|
|
2011-07-04 22:04:22 +02:00
|
|
|
/**
|
|
|
|
* @group maniphest
|
|
|
|
*/
|
2012-03-10 00:46:25 +01:00
|
|
|
final class ManiphestTaskEditController extends ManiphestController {
|
2011-02-20 23:15:53 +01:00
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = idx($data, 'id');
|
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2011-05-06 18:17:55 +02:00
|
|
|
$files = array();
|
2011-08-03 17:48:42 +02:00
|
|
|
$parent_task = null;
|
|
|
|
$template_id = null;
|
2011-05-06 18:17:55 +02:00
|
|
|
|
2011-02-20 23:15:53 +01:00
|
|
|
if ($this->id) {
|
2013-09-25 22:44:14 +02:00
|
|
|
$task = id(new ManiphestTaskQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->withIDs(array($this->id))
|
|
|
|
->executeOne();
|
2011-02-20 23:15:53 +01:00
|
|
|
if (!$task) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$task = new ManiphestTask();
|
2012-10-04 23:19:37 +02:00
|
|
|
$task->setPriority(ManiphestTaskPriority::getDefaultPriority());
|
2011-02-20 23:15:53 +01:00
|
|
|
$task->setAuthorPHID($user->getPHID());
|
2011-05-06 18:17:55 +02:00
|
|
|
|
|
|
|
// These allow task creation with defaults.
|
|
|
|
if (!$request->isFormPost()) {
|
|
|
|
$task->setTitle($request->getStr('title'));
|
2011-08-01 22:51:27 +02:00
|
|
|
|
|
|
|
$default_projects = $request->getStr('projects');
|
|
|
|
if ($default_projects) {
|
|
|
|
$task->setProjectPHIDs(explode(';', $default_projects));
|
|
|
|
}
|
2013-06-05 19:45:07 +02:00
|
|
|
|
|
|
|
$task->setDescription($request->getStr('description'));
|
|
|
|
|
|
|
|
$assign = $request->getStr('assign');
|
|
|
|
if (strlen($assign)) {
|
|
|
|
$assign_user = id(new PhabricatorUser())->loadOneWhere(
|
|
|
|
'username = %s',
|
|
|
|
$assign);
|
|
|
|
if ($assign_user) {
|
|
|
|
$task->setOwnerPHID($assign_user->getPHID());
|
|
|
|
}
|
|
|
|
}
|
2011-05-06 18:17:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$file_phids = $request->getArr('files', array());
|
|
|
|
if (!$file_phids) {
|
|
|
|
// Allow a single 'file' key instead, mostly since Mac OS X urlencodes
|
|
|
|
// square brackets in URLs when passed to 'open', so you can't 'open'
|
|
|
|
// a URL like '?files[]=xyz' and have PHP interpret it correctly.
|
|
|
|
$phid = $request->getStr('file');
|
|
|
|
if ($phid) {
|
|
|
|
$file_phids = array($phid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file_phids) {
|
|
|
|
$files = id(new PhabricatorFile())->loadAllWhere(
|
|
|
|
'phid IN (%Ls)',
|
|
|
|
$file_phids);
|
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2011-08-03 17:48:42 +02:00
|
|
|
$template_id = $request->getInt('template');
|
|
|
|
|
|
|
|
// You can only have a parent task if you're creating a new task.
|
|
|
|
$parent_id = $request->getInt('parent');
|
|
|
|
if ($parent_id) {
|
2013-09-25 22:44:14 +02:00
|
|
|
$parent_task = id(new ManiphestTaskQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($parent_id))
|
|
|
|
->executeOne();
|
2013-03-31 21:39:54 +02:00
|
|
|
if (!$template_id) {
|
|
|
|
$template_id = $parent_id;
|
|
|
|
}
|
2011-08-03 17:48:42 +02:00
|
|
|
}
|
|
|
|
}
|
Tweak style on "Create Another Task" button
Summary:
Not totally sure I'm in love with this but I think it's somewhat non-terrible,
despite the lack of lens flare.
Also made "Cancel" take you back to the task if you got to "Create" from "Create
Another Task".
Test Plan:
- Style:
https://secure.phabricator.com/file/view/PHID-FILE-ad37d3c1f3b2c7a7a7d1/
- Hit "Cancel" from "Create Another", got sent back to task.
- Hit "Cancel" from normal create, got sent back to list.
- Tried to save an invalid task after making changes to CC/Projects, changes
were preserved.
Reviewed By: codeblock
Reviewers: hunterbridges, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock
Differential Revision: 736
2011-07-27 19:46:22 +02:00
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
$errors = array();
|
|
|
|
$e_title = true;
|
|
|
|
|
2013-09-17 00:58:35 +02:00
|
|
|
$field_list = PhabricatorCustomField::getObjectFields(
|
|
|
|
$task,
|
|
|
|
PhabricatorCustomField::ROLE_EDIT);
|
|
|
|
|
|
|
|
foreach ($field_list->getFields() as $field) {
|
|
|
|
$field->setObject($task);
|
|
|
|
$field->setViewer($user);
|
|
|
|
}
|
|
|
|
|
2013-09-17 01:03:01 +02:00
|
|
|
$field_list->readFieldsFromStorage($task);
|
2013-09-17 00:58:35 +02:00
|
|
|
|
|
|
|
$aux_fields = $field_list->getFields();
|
2011-07-27 18:49:50 +02:00
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
if ($request->isFormPost()) {
|
2011-02-20 23:15:53 +01:00
|
|
|
$changes = array();
|
|
|
|
|
|
|
|
$new_title = $request->getStr('title');
|
|
|
|
$new_desc = $request->getStr('description');
|
2011-07-24 21:39:04 +02:00
|
|
|
$new_status = $request->getStr('status');
|
2011-02-20 23:15:53 +01:00
|
|
|
|
2013-09-25 20:16:55 +02:00
|
|
|
if (!$task->getID()) {
|
2011-07-26 19:39:36 +02:00
|
|
|
$workflow = 'create';
|
2013-09-25 20:18:38 +02:00
|
|
|
} else {
|
|
|
|
$workflow = '';
|
2011-02-20 23:15:53 +01:00
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2013-09-25 20:18:38 +02:00
|
|
|
$changes[ManiphestTransaction::TYPE_TITLE] = $new_title;
|
|
|
|
$changes[ManiphestTransaction::TYPE_DESCRIPTION] = $new_desc;
|
|
|
|
$changes[ManiphestTransaction::TYPE_STATUS] = $new_status;
|
|
|
|
|
2011-02-09 21:47:24 +01:00
|
|
|
$owner_tokenizer = $request->getArr('assigned_to');
|
|
|
|
$owner_phid = reset($owner_tokenizer);
|
|
|
|
|
2011-02-20 23:15:53 +01:00
|
|
|
if (!strlen($new_title)) {
|
2013-01-22 23:03:10 +01:00
|
|
|
$e_title = pht('Required');
|
|
|
|
$errors[] = pht('Title is required.');
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
|
|
|
|
2013-09-17 01:03:01 +02:00
|
|
|
$old_values = array();
|
2013-06-22 00:13:48 +02:00
|
|
|
foreach ($aux_fields as $aux_arr_key => $aux_field) {
|
2013-09-17 01:03:01 +02:00
|
|
|
// TODO: This should be buildFieldTransactionsFromRequest() once we
|
|
|
|
// switch to ApplicationTransactions properly.
|
|
|
|
|
|
|
|
$aux_old_value = $aux_field->getOldValueForApplicationTransactions();
|
|
|
|
$aux_field->readValueFromRequest($request);
|
|
|
|
$aux_new_value = $aux_field->getNewValueForApplicationTransactions();
|
2013-06-22 00:13:48 +02:00
|
|
|
|
2013-09-19 20:55:54 +02:00
|
|
|
// TODO: We're faking a call to the ApplicaitonTransaction validation
|
|
|
|
// logic here. We need valid objects to pass, but they aren't used
|
|
|
|
// in a meaningful way. For now, build User objects. Once the Maniphest
|
|
|
|
// objects exist, this will switch over automatically. This is a big
|
|
|
|
// hack but shouldn't be long for this world.
|
|
|
|
$placeholder_editor = new PhabricatorUserProfileEditor();
|
|
|
|
|
|
|
|
$field_errors = $aux_field->validateApplicationTransactions(
|
|
|
|
$placeholder_editor,
|
|
|
|
PhabricatorTransactions::TYPE_CUSTOMFIELD,
|
|
|
|
array(
|
2013-09-24 19:49:06 +02:00
|
|
|
id(new ManiphestTransaction())
|
2013-09-19 20:55:54 +02:00
|
|
|
->setOldValue($aux_old_value)
|
|
|
|
->setNewValue($aux_new_value),
|
|
|
|
));
|
2011-07-27 18:49:50 +02:00
|
|
|
|
2013-09-19 20:55:54 +02:00
|
|
|
foreach ($field_errors as $error) {
|
|
|
|
$errors[] = $error->getMessage();
|
2011-07-27 18:49:50 +02:00
|
|
|
}
|
2013-09-17 01:03:01 +02:00
|
|
|
|
|
|
|
$old_values[$aux_field->getFieldKey()] = $aux_old_value;
|
2011-07-27 18:49:50 +02:00
|
|
|
}
|
|
|
|
|
2011-07-26 19:39:36 +02:00
|
|
|
if ($errors) {
|
2013-09-25 20:16:55 +02:00
|
|
|
$task->setTitle($new_title);
|
|
|
|
$task->setDescription($new_desc);
|
2011-07-26 19:39:36 +02:00
|
|
|
$task->setPriority($request->getInt('priority'));
|
|
|
|
$task->setOwnerPHID($owner_phid);
|
|
|
|
$task->setCCPHIDs($request->getArr('cc'));
|
|
|
|
$task->setProjectPHIDs($request->getArr('projects'));
|
|
|
|
} else {
|
2011-02-09 21:47:24 +01:00
|
|
|
|
2013-09-25 20:18:38 +02:00
|
|
|
$changes[ManiphestTransaction::TYPE_PRIORITY] =
|
|
|
|
$request->getInt('priority');
|
|
|
|
$changes[ManiphestTransaction::TYPE_OWNER] = $owner_phid;
|
|
|
|
$changes[ManiphestTransaction::TYPE_CCS] = $request->getArr('cc');
|
|
|
|
$changes[ManiphestTransaction::TYPE_PROJECTS] =
|
|
|
|
$request->getArr('projects');
|
2011-02-21 05:08:16 +01:00
|
|
|
|
2013-09-25 22:44:45 +02:00
|
|
|
$changes[PhabricatorTransactions::TYPE_VIEW_POLICY] =
|
|
|
|
$request->getStr('viewPolicy');
|
|
|
|
$changes[PhabricatorTransactions::TYPE_EDIT_POLICY] =
|
|
|
|
$request->getStr('editPolicy');
|
|
|
|
|
2011-05-06 18:17:55 +02:00
|
|
|
if ($files) {
|
|
|
|
$file_map = mpull($files, 'getPHID');
|
Fix some minor issues with Maniphest file/attachment handling
Summary:
@danielraffel is reporting an issue with file attachments which I can't
reproduce, but I did find a couple of minor things.
- Elsewhere, we store array() as the value of these PHID dictionaries (the
idea being that we might store metadata there some day). While we may or may not
do this, we should at least be consistent.
- When you edit a task, there's a file upload control but it doesn't actually
do anything. Just don't show it, there's no real reason to have it there.
Test Plan: Created a new task with attached files, verified they encoded as "[]"
instead of "true" in the database. Edited a task and didn't get a file control.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: aran
CC: danielraffel, aran
Differential Revision: 1003
2011-10-12 04:30:11 +02:00
|
|
|
$file_map = array_fill_keys($file_map, array());
|
2013-09-25 20:16:43 +02:00
|
|
|
$changes[ManiphestTransaction::TYPE_ATTACH] = array(
|
2013-07-22 17:02:56 +02:00
|
|
|
PhabricatorFilePHIDTypeFile::TYPECONST => $file_map,
|
2011-05-06 18:17:55 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-09-24 19:49:06 +02:00
|
|
|
$template = new ManiphestTransaction();
|
2011-02-09 21:47:24 +01:00
|
|
|
$transactions = array();
|
|
|
|
|
|
|
|
foreach ($changes as $type => $value) {
|
|
|
|
$transaction = clone $template;
|
|
|
|
$transaction->setTransactionType($type);
|
|
|
|
$transaction->setNewValue($value);
|
|
|
|
$transactions[] = $transaction;
|
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2011-12-24 04:03:28 +01:00
|
|
|
if ($aux_fields) {
|
|
|
|
foreach ($aux_fields as $aux_field) {
|
|
|
|
$transaction = clone $template;
|
|
|
|
$transaction->setTransactionType(
|
Migrate all Maniphest transaction data to new storage
Summary:
Ref T2217. This is the risky, hard part; everything after this should be smooth sailing. This is //mostly// clean, except:
- The old format would opportunistically combine a comment with some other transaction type if it could. We no longer do that, so:
- When migrating, "edit" + "comment" transactions need to be split in two.
- When editing now, we should no longer combine these transaction types.
- These changes are pretty straightforward and low-impact.
- This migration promotes "auxiliary field" data to the new CustomField/StandardField format, so that's not a straight migration either. The formats are very similar, though.
Broadly, this takes the same attack that the auth migration did: proxy all the code through to the new storage. `ManiphestTransaction` is now just an API on top of `ManiphestTransactionPro`, which is the new storage format. The two formats are very similar, so this was mostly a straight copy from one table to the other.
Test Plan:
- Without performing the migration, made a bunch of edits and comments on tasks and verified the new code works correctly.
- Droped the test data and performed the migration.
- Looked at the resulting data for obvious discrepancies.
- Looked at a bunch of tasks and their transaction history.
- Used Conduit to pull transaction data.
- Edited task description and clicked "View Details" on transaction.
- Used batch editor.
- Made a bunch more edits.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2217
Differential Revision: https://secure.phabricator.com/D7068
2013-09-23 23:25:28 +02:00
|
|
|
PhabricatorTransactions::TYPE_CUSTOMFIELD);
|
2013-09-17 01:03:01 +02:00
|
|
|
$aux_key = $aux_field->getFieldKey();
|
Migrate all Maniphest transaction data to new storage
Summary:
Ref T2217. This is the risky, hard part; everything after this should be smooth sailing. This is //mostly// clean, except:
- The old format would opportunistically combine a comment with some other transaction type if it could. We no longer do that, so:
- When migrating, "edit" + "comment" transactions need to be split in two.
- When editing now, we should no longer combine these transaction types.
- These changes are pretty straightforward and low-impact.
- This migration promotes "auxiliary field" data to the new CustomField/StandardField format, so that's not a straight migration either. The formats are very similar, though.
Broadly, this takes the same attack that the auth migration did: proxy all the code through to the new storage. `ManiphestTransaction` is now just an API on top of `ManiphestTransactionPro`, which is the new storage format. The two formats are very similar, so this was mostly a straight copy from one table to the other.
Test Plan:
- Without performing the migration, made a bunch of edits and comments on tasks and verified the new code works correctly.
- Droped the test data and performed the migration.
- Looked at the resulting data for obvious discrepancies.
- Looked at a bunch of tasks and their transaction history.
- Used Conduit to pull transaction data.
- Edited task description and clicked "View Details" on transaction.
- Used batch editor.
- Made a bunch more edits.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2217
Differential Revision: https://secure.phabricator.com/D7068
2013-09-23 23:25:28 +02:00
|
|
|
$transaction->setMetadataValue('customfield:key', $aux_key);
|
2013-09-19 20:56:15 +02:00
|
|
|
$old = idx($old_values, $aux_key);
|
|
|
|
$new = $aux_field->getNewValueForApplicationTransactions();
|
|
|
|
|
|
|
|
$transaction->setOldValue($old);
|
|
|
|
$transaction->setNewValue($new);
|
|
|
|
|
2011-12-24 04:03:28 +01:00
|
|
|
$transactions[] = $transaction;
|
|
|
|
}
|
|
|
|
}
|
2011-08-31 22:25:13 +02:00
|
|
|
|
2011-12-24 04:03:28 +01:00
|
|
|
if ($transactions) {
|
2012-04-17 21:09:04 +02:00
|
|
|
$is_new = !$task->getID();
|
|
|
|
|
2011-08-31 22:25:13 +02:00
|
|
|
$event = new PhabricatorEvent(
|
|
|
|
PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK,
|
|
|
|
array(
|
|
|
|
'task' => $task,
|
2012-04-17 21:09:04 +02:00
|
|
|
'new' => $is_new,
|
2011-08-31 22:25:13 +02:00
|
|
|
'transactions' => $transactions,
|
|
|
|
));
|
|
|
|
$event->setUser($user);
|
|
|
|
$event->setAphrontRequest($request);
|
2011-11-10 02:23:33 +01:00
|
|
|
PhutilEventEngine::dispatchEvent($event);
|
2011-08-31 22:25:13 +02:00
|
|
|
|
|
|
|
$task = $event->getValue('task');
|
|
|
|
$transactions = $event->getValue('transactions');
|
|
|
|
|
2013-09-24 15:26:59 +02:00
|
|
|
$editor = id(new ManiphestTransactionEditorPro())
|
|
|
|
->setActor($user)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->applyTransactions($task, $transactions);
|
2012-04-17 21:09:04 +02:00
|
|
|
|
|
|
|
$event = new PhabricatorEvent(
|
|
|
|
PhabricatorEventType::TYPE_MANIPHEST_DIDEDITTASK,
|
|
|
|
array(
|
|
|
|
'task' => $task,
|
|
|
|
'new' => $is_new,
|
|
|
|
'transactions' => $transactions,
|
|
|
|
));
|
|
|
|
$event->setUser($user);
|
|
|
|
$event->setAphrontRequest($request);
|
|
|
|
PhutilEventEngine::dispatchEvent($event);
|
2011-05-07 02:22:48 +02:00
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2012-04-17 21:09:04 +02:00
|
|
|
|
2011-08-03 17:48:42 +02:00
|
|
|
if ($parent_task) {
|
2012-07-20 17:59:39 +02:00
|
|
|
id(new PhabricatorEdgeEditor())
|
2012-10-16 22:39:35 +02:00
|
|
|
->setActor($user)
|
2012-07-20 17:59:39 +02:00
|
|
|
->addEdge(
|
|
|
|
$parent_task->getPHID(),
|
|
|
|
PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK,
|
|
|
|
$task->getPHID())
|
|
|
|
->save();
|
2011-08-03 17:48:42 +02:00
|
|
|
$workflow = $parent_task->getID();
|
|
|
|
}
|
|
|
|
|
2013-05-31 03:55:25 +02:00
|
|
|
if ($request->isAjax()) {
|
|
|
|
return id(new AphrontAjaxResponse())->setContent(
|
|
|
|
array(
|
|
|
|
'tasks' => $this->renderSingleTask($task),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-07-26 19:39:36 +02:00
|
|
|
$redirect_uri = '/T'.$task->getID();
|
|
|
|
|
|
|
|
if ($workflow) {
|
|
|
|
$redirect_uri .= '?workflow='.$workflow;
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
return id(new AphrontRedirectResponse())
|
2011-07-26 19:39:36 +02:00
|
|
|
->setURI($redirect_uri);
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
2011-02-09 21:47:24 +01:00
|
|
|
} else {
|
2011-02-20 23:15:53 +01:00
|
|
|
if (!$task->getID()) {
|
|
|
|
$task->setCCPHIDs(array(
|
|
|
|
$user->getPHID(),
|
|
|
|
));
|
Tweak style on "Create Another Task" button
Summary:
Not totally sure I'm in love with this but I think it's somewhat non-terrible,
despite the lack of lens flare.
Also made "Cancel" take you back to the task if you got to "Create" from "Create
Another Task".
Test Plan:
- Style:
https://secure.phabricator.com/file/view/PHID-FILE-ad37d3c1f3b2c7a7a7d1/
- Hit "Cancel" from "Create Another", got sent back to task.
- Hit "Cancel" from normal create, got sent back to list.
- Tried to save an invalid task after making changes to CC/Projects, changes
were preserved.
Reviewed By: codeblock
Reviewers: hunterbridges, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock
Differential Revision: 736
2011-07-27 19:46:22 +02:00
|
|
|
if ($template_id) {
|
2013-09-25 22:44:14 +02:00
|
|
|
$template_task = id(new ManiphestTaskQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($template_id))
|
|
|
|
->executeOne();
|
Tweak style on "Create Another Task" button
Summary:
Not totally sure I'm in love with this but I think it's somewhat non-terrible,
despite the lack of lens flare.
Also made "Cancel" take you back to the task if you got to "Create" from "Create
Another Task".
Test Plan:
- Style:
https://secure.phabricator.com/file/view/PHID-FILE-ad37d3c1f3b2c7a7a7d1/
- Hit "Cancel" from "Create Another", got sent back to task.
- Hit "Cancel" from normal create, got sent back to list.
- Tried to save an invalid task after making changes to CC/Projects, changes
were preserved.
Reviewed By: codeblock
Reviewers: hunterbridges, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock
Differential Revision: 736
2011-07-27 19:46:22 +02:00
|
|
|
if ($template_task) {
|
|
|
|
$task->setCCPHIDs($template_task->getCCPHIDs());
|
|
|
|
$task->setProjectPHIDs($template_task->getProjectPHIDs());
|
|
|
|
$task->setOwnerPHID($template_task->getOwnerPHID());
|
2012-08-06 04:10:20 +02:00
|
|
|
$task->setPriority($template_task->getPriority());
|
2012-05-07 22:38:27 +02:00
|
|
|
|
2013-09-17 01:03:01 +02:00
|
|
|
$template_fields = PhabricatorCustomField::getObjectFields(
|
|
|
|
$template_task,
|
|
|
|
PhabricatorCustomField::ROLE_EDIT);
|
|
|
|
|
|
|
|
$fields = $template_fields->getFields();
|
|
|
|
foreach ($fields as $key => $field) {
|
|
|
|
if (!$field->shouldCopyWhenCreatingSimilarTask()) {
|
|
|
|
unset($fields[$key]);
|
|
|
|
}
|
|
|
|
if (empty($aux_fields[$key])) {
|
|
|
|
unset($fields[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($fields) {
|
|
|
|
id(new PhabricatorCustomFieldList($fields))
|
|
|
|
->readFieldsFromStorage($template_task);
|
2012-05-07 22:38:27 +02:00
|
|
|
|
2013-09-17 01:03:01 +02:00
|
|
|
foreach ($fields as $key => $field) {
|
|
|
|
$aux_fields[$key]->setValueFromStorage(
|
|
|
|
$field->getValueForStorage());
|
2012-05-07 22:38:27 +02:00
|
|
|
}
|
|
|
|
}
|
Tweak style on "Create Another Task" button
Summary:
Not totally sure I'm in love with this but I think it's somewhat non-terrible,
despite the lack of lens flare.
Also made "Cancel" take you back to the task if you got to "Create" from "Create
Another Task".
Test Plan:
- Style:
https://secure.phabricator.com/file/view/PHID-FILE-ad37d3c1f3b2c7a7a7d1/
- Hit "Cancel" from "Create Another", got sent back to task.
- Hit "Cancel" from normal create, got sent back to list.
- Tried to save an invalid task after making changes to CC/Projects, changes
were preserved.
Reviewed By: codeblock
Reviewers: hunterbridges, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock
Differential Revision: 736
2011-07-27 19:46:22 +02:00
|
|
|
}
|
|
|
|
}
|
2011-02-20 23:15:53 +01:00
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$phids = array_merge(
|
|
|
|
array($task->getOwnerPHID()),
|
2011-02-21 05:08:16 +01:00
|
|
|
$task->getCCPHIDs(),
|
2013-09-19 20:56:30 +02:00
|
|
|
$task->getProjectPHIDs());
|
2011-07-26 19:39:36 +02:00
|
|
|
|
2011-08-03 17:48:42 +02:00
|
|
|
if ($parent_task) {
|
|
|
|
$phids[] = $parent_task->getPHID();
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
$phids = array_filter($phids);
|
|
|
|
$phids = array_unique($phids);
|
|
|
|
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2011-02-08 19:53:59 +01:00
|
|
|
|
|
|
|
$tvalues = mpull($handles, 'getFullName', 'getPHID');
|
|
|
|
|
|
|
|
$error_view = null;
|
|
|
|
if ($errors) {
|
|
|
|
$error_view = new AphrontErrorView();
|
|
|
|
$error_view->setErrors($errors);
|
2013-01-22 23:03:10 +01:00
|
|
|
$error_view->setTitle(pht('Form Errors'));
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
|
|
|
|
|
|
|
|
if ($task->getOwnerPHID()) {
|
|
|
|
$assigned_value = array(
|
|
|
|
$task->getOwnerPHID() => $handles[$task->getOwnerPHID()]->getFullName(),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
$assigned_value = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($task->getCCPHIDs()) {
|
|
|
|
$cc_value = array_select_keys($tvalues, $task->getCCPHIDs());
|
|
|
|
} else {
|
|
|
|
$cc_value = array();
|
|
|
|
}
|
|
|
|
|
2011-02-21 05:08:16 +01:00
|
|
|
if ($task->getProjectPHIDs()) {
|
|
|
|
$projects_value = array_select_keys($tvalues, $task->getProjectPHIDs());
|
|
|
|
} else {
|
|
|
|
$projects_value = array();
|
|
|
|
}
|
|
|
|
|
Tweak style on "Create Another Task" button
Summary:
Not totally sure I'm in love with this but I think it's somewhat non-terrible,
despite the lack of lens flare.
Also made "Cancel" take you back to the task if you got to "Create" from "Create
Another Task".
Test Plan:
- Style:
https://secure.phabricator.com/file/view/PHID-FILE-ad37d3c1f3b2c7a7a7d1/
- Hit "Cancel" from "Create Another", got sent back to task.
- Hit "Cancel" from normal create, got sent back to list.
- Tried to save an invalid task after making changes to CC/Projects, changes
were preserved.
Reviewed By: codeblock
Reviewers: hunterbridges, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock
Differential Revision: 736
2011-07-27 19:46:22 +02:00
|
|
|
$cancel_id = nonempty($task->getID(), $template_id);
|
|
|
|
if ($cancel_id) {
|
|
|
|
$cancel_uri = '/T'.$cancel_id;
|
|
|
|
} else {
|
|
|
|
$cancel_uri = '/maniphest/';
|
|
|
|
}
|
|
|
|
|
2011-02-20 23:15:53 +01:00
|
|
|
if ($task->getID()) {
|
2013-01-22 23:03:10 +01:00
|
|
|
$button_name = pht('Save Task');
|
|
|
|
$header_name = pht('Edit Task');
|
2011-08-03 17:48:42 +02:00
|
|
|
} else if ($parent_task) {
|
|
|
|
$cancel_uri = '/T'.$parent_task->getID();
|
2013-01-22 23:03:10 +01:00
|
|
|
$button_name = pht('Create Task');
|
|
|
|
$header_name = pht('Create New Subtask');
|
2011-02-20 23:15:53 +01:00
|
|
|
} else {
|
2013-01-22 23:03:10 +01:00
|
|
|
$button_name = pht('Create Task');
|
|
|
|
$header_name = pht('Create New Task');
|
2011-02-20 23:15:53 +01:00
|
|
|
}
|
|
|
|
|
2012-01-25 20:23:00 +01:00
|
|
|
require_celerity_resource('maniphest-task-edit-css');
|
|
|
|
|
2011-06-10 00:28:29 +02:00
|
|
|
$project_tokenizer_id = celerity_generate_unique_node_id();
|
|
|
|
|
2013-05-31 03:55:25 +02:00
|
|
|
if ($request->isAjax()) {
|
2013-08-26 20:53:11 +02:00
|
|
|
$form = new PHUIFormLayoutView();
|
2013-05-31 03:55:25 +02:00
|
|
|
} else {
|
|
|
|
$form = new AphrontFormView();
|
|
|
|
$form
|
|
|
|
->setUser($user)
|
|
|
|
->addHiddenInput('template', $template_id);
|
|
|
|
}
|
2011-08-03 17:48:42 +02:00
|
|
|
|
|
|
|
if ($parent_task) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormStaticControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Parent Task'))
|
2011-08-03 17:48:42 +02:00
|
|
|
->setValue($handles[$parent_task->getPHID()]->getFullName()))
|
|
|
|
->addHiddenInput('parent', $parent_task->getID());
|
|
|
|
}
|
|
|
|
|
|
|
|
$form
|
2011-02-08 19:53:59 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Title'))
|
2011-02-08 19:53:59 +01:00
|
|
|
->setName('title')
|
|
|
|
->setError($e_title)
|
|
|
|
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
|
2011-07-24 21:39:04 +02:00
|
|
|
->setValue($task->getTitle()));
|
|
|
|
|
|
|
|
if ($task->getID()) {
|
|
|
|
// Only show this in "edit" mode, not "create" mode, since creating a
|
|
|
|
// non-open task is kind of silly and it would just clutter up the
|
|
|
|
// "create" interface.
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Status'))
|
2011-07-24 21:39:04 +02:00
|
|
|
->setName('status')
|
|
|
|
->setValue($task->getStatus())
|
|
|
|
->setOptions(ManiphestTaskStatus::getTaskStatusMap()));
|
|
|
|
}
|
|
|
|
|
2013-09-25 22:44:45 +02:00
|
|
|
$policies = id(new PhabricatorPolicyQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->setObject($task)
|
|
|
|
->execute();
|
|
|
|
|
2011-07-24 21:39:04 +02:00
|
|
|
$form
|
2011-02-08 19:53:59 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Assigned To'))
|
2011-02-08 19:53:59 +01:00
|
|
|
->setName('assigned_to')
|
|
|
|
->setValue($assigned_value)
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-10 00:46:39 +01:00
|
|
|
->setUser($user)
|
2011-02-08 19:53:59 +01:00
|
|
|
->setDatasource('/typeahead/common/users/')
|
|
|
|
->setLimit(1))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('CC'))
|
2011-02-08 19:53:59 +01:00
|
|
|
->setName('cc')
|
|
|
|
->setValue($cc_value)
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-10 00:46:39 +01:00
|
|
|
->setUser($user)
|
2011-02-08 19:53:59 +01:00
|
|
|
->setDatasource('/typeahead/common/mailable/'))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Priority'))
|
2011-02-08 19:53:59 +01:00
|
|
|
->setName('priority')
|
|
|
|
->setOptions($priority_map)
|
|
|
|
->setValue($task->getPriority()))
|
2013-09-25 22:44:45 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormPolicyControl())
|
|
|
|
->setUser($user)
|
|
|
|
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
|
|
|
|
->setPolicyObject($task)
|
|
|
|
->setPolicies($policies)
|
|
|
|
->setName('viewPolicy'))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormPolicyControl())
|
|
|
|
->setUser($user)
|
|
|
|
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
|
|
|
->setPolicyObject($task)
|
|
|
|
->setPolicies($policies)
|
|
|
|
->setCaption(
|
|
|
|
pht(
|
|
|
|
'NOTE: These policy controls still have some rough edges and '.
|
|
|
|
'are not yet fully functional.'))
|
|
|
|
->setName('editPolicy'))
|
2011-02-21 05:08:16 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Projects'))
|
2011-02-21 05:08:16 +01:00
|
|
|
->setName('projects')
|
|
|
|
->setValue($projects_value)
|
2011-06-10 00:28:29 +02:00
|
|
|
->setID($project_tokenizer_id)
|
|
|
|
->setCaption(
|
2013-01-25 21:57:17 +01:00
|
|
|
javelin_tag(
|
2011-06-10 00:28:29 +02:00
|
|
|
'a',
|
|
|
|
array(
|
2011-06-26 17:37:47 +02:00
|
|
|
'href' => '/project/create/',
|
2011-06-10 00:28:29 +02:00
|
|
|
'mustcapture' => true,
|
|
|
|
'sigil' => 'project-create',
|
|
|
|
),
|
2013-01-22 23:03:10 +01:00
|
|
|
pht('Create New Project')))
|
2011-05-06 18:17:55 +02:00
|
|
|
->setDatasource('/typeahead/common/projects/'));
|
|
|
|
|
2013-03-08 02:24:58 +01:00
|
|
|
foreach ($aux_fields as $aux_field) {
|
2013-09-19 20:55:45 +02:00
|
|
|
$aux_control = $aux_field->renderEditControl();
|
2013-03-08 02:24:58 +01:00
|
|
|
$form->appendChild($aux_control);
|
2011-07-27 18:49:50 +02:00
|
|
|
}
|
|
|
|
|
2011-06-26 17:37:47 +02:00
|
|
|
require_celerity_resource('aphront-error-view-css');
|
|
|
|
|
2012-08-08 19:03:41 +02:00
|
|
|
Javelin::initBehavior('project-create', array(
|
2011-06-10 00:28:29 +02:00
|
|
|
'tokenizerID' => $project_tokenizer_id,
|
|
|
|
));
|
|
|
|
|
2011-05-06 18:17:55 +02:00
|
|
|
if ($files) {
|
2013-02-05 23:30:29 +01:00
|
|
|
$file_display = mpull($files, 'getName');
|
2013-02-13 23:50:15 +01:00
|
|
|
$file_display = phutil_implode_html(phutil_tag('br'), $file_display);
|
2011-05-06 18:17:55 +02:00
|
|
|
|
|
|
|
$form->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Files'))
|
2011-05-06 18:17:55 +02:00
|
|
|
->setValue($file_display));
|
|
|
|
|
|
|
|
foreach ($files as $ii => $file) {
|
|
|
|
$form->addHiddenInput('files['.$ii.']', $file->getPHID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-19 21:27:28 +02:00
|
|
|
|
|
|
|
$description_control = new PhabricatorRemarkupControl();
|
|
|
|
// "Upsell" creating tasks via email in create flows if the instance is
|
|
|
|
// configured for this awesomeness.
|
2011-07-04 18:45:42 +02:00
|
|
|
$email_create = PhabricatorEnv::getEnvConfig(
|
|
|
|
'metamta.maniphest.public-create-email');
|
|
|
|
if (!$task->getID() && $email_create) {
|
2013-02-05 22:23:05 +01:00
|
|
|
$email_hint = pht(
|
|
|
|
'You can also create tasks by sending an email to: %s',
|
|
|
|
phutil_tag('tt', array(), $email_create));
|
2012-09-19 21:27:28 +02:00
|
|
|
$description_control->setCaption($email_hint);
|
2011-07-04 18:45:42 +02:00
|
|
|
}
|
|
|
|
|
2012-09-19 21:27:28 +02:00
|
|
|
$description_control
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Description'))
|
2012-09-19 21:27:28 +02:00
|
|
|
->setName('description')
|
|
|
|
->setID('description-textarea')
|
2012-11-27 23:06:31 +01:00
|
|
|
->setValue($task->getDescription())
|
|
|
|
->setUser($user);
|
2011-08-19 18:36:41 +02:00
|
|
|
|
2011-05-06 18:17:55 +02:00
|
|
|
$form
|
2012-09-19 21:27:28 +02:00
|
|
|
->appendChild($description_control);
|
|
|
|
|
2013-05-31 03:55:25 +02:00
|
|
|
|
|
|
|
if ($request->isAjax()) {
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
|
|
->setUser($user)
|
|
|
|
->setWidth(AphrontDialogView::WIDTH_FULL)
|
|
|
|
->setTitle($header_name)
|
|
|
|
->appendChild(
|
|
|
|
array(
|
|
|
|
$error_view,
|
|
|
|
$form,
|
|
|
|
))
|
|
|
|
->addCancelButton($cancel_uri)
|
|
|
|
->addSubmitButton($button_name);
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
}
|
|
|
|
|
Fix some minor issues with Maniphest file/attachment handling
Summary:
@danielraffel is reporting an issue with file attachments which I can't
reproduce, but I did find a couple of minor things.
- Elsewhere, we store array() as the value of these PHID dictionaries (the
idea being that we might store metadata there some day). While we may or may not
do this, we should at least be consistent.
- When you edit a task, there's a file upload control but it doesn't actually
do anything. Just don't show it, there's no real reason to have it there.
Test Plan: Created a new task with attached files, verified they encoded as "[]"
instead of "true" in the database. Edited a task and didn't get a file control.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: aran
CC: danielraffel, aran
Differential Revision: 1003
2011-10-12 04:30:11 +02:00
|
|
|
$form
|
2011-02-08 19:53:59 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2011-02-20 23:15:53 +01:00
|
|
|
->addCancelButton($cancel_uri)
|
|
|
|
->setValue($button_name));
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2013-09-25 20:23:29 +02:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-26 20:53:11 +02:00
|
|
|
->setHeaderText($header_name)
|
|
|
|
->setFormError($error_view)
|
|
|
|
->setForm($form);
|
|
|
|
|
2013-08-05 19:46:39 +02:00
|
|
|
$preview = id(new PHUIRemarkupPreviewPanel())
|
|
|
|
->setHeader(pht('Description Preview'))
|
|
|
|
->setControlID('description-textarea')
|
|
|
|
->setPreviewURI($this->getApplicationURI('task/descriptionpreview/'));
|
2012-01-25 20:23:00 +01:00
|
|
|
|
2012-06-14 02:28:21 +02:00
|
|
|
if ($task->getID()) {
|
|
|
|
$page_objects = array( $task->getPHID() );
|
|
|
|
} else {
|
|
|
|
$page_objects = array();
|
|
|
|
}
|
|
|
|
|
2013-03-26 21:15:15 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
2013-09-13 20:29:08 +02:00
|
|
|
->setName($header_name));
|
2013-03-26 21:15:15 +01:00
|
|
|
|
2013-01-22 23:03:10 +01:00
|
|
|
return $this->buildApplicationPage(
|
2011-02-08 19:53:59 +01:00
|
|
|
array(
|
2013-03-26 21:15:15 +01:00
|
|
|
$crumbs,
|
2013-08-26 20:53:11 +02:00
|
|
|
$form_box,
|
2013-08-05 19:46:39 +02:00
|
|
|
$preview,
|
2011-02-08 19:53:59 +01:00
|
|
|
),
|
|
|
|
array(
|
2012-01-25 20:23:00 +01:00
|
|
|
'title' => $header_name,
|
2012-06-14 02:28:21 +02:00
|
|
|
'pageObjects' => $page_objects,
|
2013-03-13 07:30:03 +01:00
|
|
|
'device' => true,
|
2011-02-08 19:53:59 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|