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) {
|
|
|
|
$task = id(new ManiphestTask())->load($this->id);
|
|
|
|
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));
|
|
|
|
}
|
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) {
|
|
|
|
$parent_task = id(new ManiphestTask())->load($parent_id);
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
|
2011-08-05 18:44:43 +02:00
|
|
|
$extensions = ManiphestTaskExtensions::newExtensions();
|
|
|
|
$aux_fields = $extensions->getAuxiliaryFieldSpecifications();
|
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
|
|
|
|
2011-07-26 19:39:36 +02:00
|
|
|
$workflow = '';
|
|
|
|
|
2011-02-20 23:15:53 +01:00
|
|
|
if ($task->getID()) {
|
|
|
|
if ($new_title != $task->getTitle()) {
|
|
|
|
$changes[ManiphestTransactionType::TYPE_TITLE] = $new_title;
|
|
|
|
}
|
|
|
|
if ($new_desc != $task->getDescription()) {
|
|
|
|
$changes[ManiphestTransactionType::TYPE_DESCRIPTION] = $new_desc;
|
|
|
|
}
|
2011-07-24 21:39:04 +02:00
|
|
|
if ($new_status != $task->getStatus()) {
|
|
|
|
$changes[ManiphestTransactionType::TYPE_STATUS] = $new_status;
|
|
|
|
}
|
2011-02-20 23:15:53 +01:00
|
|
|
} else {
|
|
|
|
$task->setTitle($new_title);
|
|
|
|
$task->setDescription($new_desc);
|
2011-02-21 05:08:16 +01:00
|
|
|
$changes[ManiphestTransactionType::TYPE_STATUS] =
|
|
|
|
ManiphestTaskStatus::STATUS_OPEN;
|
2011-07-26 19:39:36 +02:00
|
|
|
|
|
|
|
$workflow = 'create';
|
2011-02-20 23:15:53 +01:00
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
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)) {
|
2011-02-08 19:53:59 +01:00
|
|
|
$e_title = 'Required';
|
|
|
|
$errors[] = 'Title is required.';
|
|
|
|
}
|
|
|
|
|
2011-07-27 18:49:50 +02:00
|
|
|
foreach ($aux_fields as $aux_field) {
|
|
|
|
$aux_field->setValueFromRequest($request);
|
|
|
|
|
|
|
|
if ($aux_field->isRequired() && !strlen($aux_field->getValue())) {
|
|
|
|
$errors[] = $aux_field->getLabel() . ' is required.';
|
|
|
|
$aux_field->setError('Required');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strlen($aux_field->getValue())) {
|
|
|
|
try {
|
|
|
|
$aux_field->validate();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$errors[] = $e->getMessage();
|
|
|
|
$aux_field->setError('Invalid');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-26 19:39:36 +02:00
|
|
|
if ($errors) {
|
|
|
|
$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
|
|
|
if ($request->getInt('priority') != $task->getPriority()) {
|
|
|
|
$changes[ManiphestTransactionType::TYPE_PRIORITY] =
|
|
|
|
$request->getInt('priority');
|
|
|
|
}
|
|
|
|
|
2011-02-21 05:08:16 +01:00
|
|
|
if ($owner_phid != $task->getOwnerPHID()) {
|
2011-02-09 21:47:24 +01:00
|
|
|
$changes[ManiphestTransactionType::TYPE_OWNER] = $owner_phid;
|
|
|
|
}
|
|
|
|
|
2011-02-21 05:08:16 +01:00
|
|
|
if ($request->getArr('cc') != $task->getCCPHIDs()) {
|
2011-02-09 21:47:24 +01:00
|
|
|
$changes[ManiphestTransactionType::TYPE_CCS] = $request->getArr('cc');
|
|
|
|
}
|
|
|
|
|
2011-05-07 02:33:40 +02:00
|
|
|
$new_proj_arr = $request->getArr('projects');
|
|
|
|
$new_proj_arr = array_values($new_proj_arr);
|
|
|
|
sort($new_proj_arr);
|
|
|
|
|
|
|
|
$cur_proj_arr = $task->getProjectPHIDs();
|
|
|
|
$cur_proj_arr = array_values($cur_proj_arr);
|
|
|
|
sort($cur_proj_arr);
|
|
|
|
|
|
|
|
if ($new_proj_arr != $cur_proj_arr) {
|
|
|
|
$changes[ManiphestTransactionType::TYPE_PROJECTS] = $new_proj_arr;
|
2011-02-21 05:08:16 +01:00
|
|
|
}
|
|
|
|
|
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());
|
2011-05-06 18:17:55 +02:00
|
|
|
$changes[ManiphestTransactionType::TYPE_ATTACH] = array(
|
|
|
|
PhabricatorPHIDConstants::PHID_TYPE_FILE => $file_map,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
Track content sources (email, web, conduit, mobile) for replies
Summary:
When an object is updated, record the content source for the update. This mostly
isn't terribly useful but one concrete thing I want to do with it is let admins
audit via-email replies more easily since there are a bunch of options which let
you do hyjinx if you intentionally configure them insecurely. I think having a
little more auditability around this feature is generally good. At some point
I'm going to turn this into a link admins can click to see details.
It also allows us to see how frequently different mechanisms are used, and lets
you see if someone is at their desk or on a mobile or whatever, at least
indirectly.
The "tablet" and "mobile" sources are currently unused but I figured I'd throw
them in anyway. SMS support should definitely happen at some point.
Not 100% sure about the design for this, I might change it to plain text at some
point.
Test Plan: Updated objects and saw update sources rendered.
Reviewers: jungejason, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, epriestley, jungejason
Differential Revision: 844
2011-08-22 19:25:45 +02:00
|
|
|
$content_source = PhabricatorContentSource::newForSource(
|
|
|
|
PhabricatorContentSource::SOURCE_WEB,
|
|
|
|
array(
|
|
|
|
'ip' => $request->getRemoteAddr(),
|
|
|
|
));
|
|
|
|
|
2011-02-09 21:47:24 +01:00
|
|
|
$template = new ManiphestTransaction();
|
|
|
|
$template->setAuthorPHID($user->getPHID());
|
Track content sources (email, web, conduit, mobile) for replies
Summary:
When an object is updated, record the content source for the update. This mostly
isn't terribly useful but one concrete thing I want to do with it is let admins
audit via-email replies more easily since there are a bunch of options which let
you do hyjinx if you intentionally configure them insecurely. I think having a
little more auditability around this feature is generally good. At some point
I'm going to turn this into a link admins can click to see details.
It also allows us to see how frequently different mechanisms are used, and lets
you see if someone is at their desk or on a mobile or whatever, at least
indirectly.
The "tablet" and "mobile" sources are currently unused but I figured I'd throw
them in anyway. SMS support should definitely happen at some point.
Not 100% sure about the design for this, I might change it to plain text at some
point.
Test Plan: Updated objects and saw update sources rendered.
Reviewers: jungejason, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, epriestley, jungejason
Differential Revision: 844
2011-08-22 19:25:45 +02:00
|
|
|
$template->setContentSource($content_source);
|
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) {
|
|
|
|
$task->loadAndAttachAuxiliaryAttributes();
|
|
|
|
foreach ($aux_fields as $aux_field) {
|
|
|
|
$transaction = clone $template;
|
|
|
|
$transaction->setTransactionType(
|
|
|
|
ManiphestTransactionType::TYPE_AUXILIARY);
|
|
|
|
$aux_key = $aux_field->getAuxiliaryKey();
|
|
|
|
$transaction->setMetadataValue('aux:key', $aux_key);
|
|
|
|
$transaction->setNewValue($aux_field->getValueForStorage());
|
|
|
|
$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');
|
|
|
|
|
2011-05-07 02:22:48 +02:00
|
|
|
$editor = new ManiphestTransactionEditor();
|
2012-10-10 19:18:23 +02:00
|
|
|
$editor->setActor($user);
|
2012-03-07 00:10:17 +01:00
|
|
|
$editor->setAuxiliaryFields($aux_fields);
|
2011-05-07 02:22:48 +02:00
|
|
|
$editor->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();
|
|
|
|
}
|
|
|
|
|
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 {
|
2012-05-07 22:38:27 +02:00
|
|
|
if ($aux_fields) {
|
|
|
|
$task->loadAndAttachAuxiliaryAttributes();
|
|
|
|
foreach ($aux_fields as $aux_field) {
|
|
|
|
$aux_key = $aux_field->getAuxiliaryKey();
|
|
|
|
$value = $task->getAuxiliaryAttribute($aux_key);
|
|
|
|
$aux_field->setValueFromStorage($value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
$template_task = id(new ManiphestTask())->load($template_id);
|
|
|
|
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
|
|
|
|
|
|
|
if ($aux_fields) {
|
|
|
|
$template_task->loadAndAttachAuxiliaryAttributes();
|
|
|
|
foreach ($aux_fields as $aux_field) {
|
|
|
|
if (!$aux_field->shouldCopyWhenCreatingSimilarTask()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$aux_key = $aux_field->getAuxiliaryKey();
|
|
|
|
$value = $template_task->getAuxiliaryAttribute($aux_key);
|
|
|
|
$aux_field->setValueFromStorage($value);
|
|
|
|
}
|
|
|
|
}
|
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(),
|
|
|
|
$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);
|
|
|
|
$error_view->setTitle('Form Errors');
|
|
|
|
}
|
|
|
|
|
|
|
|
$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()) {
|
|
|
|
$button_name = 'Save Task';
|
|
|
|
$header_name = 'Edit Task';
|
2011-08-03 17:48:42 +02:00
|
|
|
} else if ($parent_task) {
|
|
|
|
$cancel_uri = '/T'.$parent_task->getID();
|
|
|
|
$button_name = 'Create Task';
|
|
|
|
$header_name = 'Create New Subtask';
|
2011-02-20 23:15:53 +01:00
|
|
|
} else {
|
|
|
|
$button_name = 'Create Task';
|
|
|
|
$header_name = 'Create New Task';
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
$form = new AphrontFormView();
|
|
|
|
$form
|
|
|
|
->setUser($user)
|
2011-05-06 18:17:55 +02:00
|
|
|
->setAction($request->getRequestURI()->getPath())
|
2011-08-03 17:48:42 +02:00
|
|
|
->addHiddenInput('template', $template_id);
|
|
|
|
|
|
|
|
if ($parent_task) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormStaticControl())
|
|
|
|
->setLabel('Parent Task')
|
|
|
|
->setValue($handles[$parent_task->getPHID()]->getFullName()))
|
|
|
|
->addHiddenInput('parent', $parent_task->getID());
|
|
|
|
}
|
|
|
|
|
|
|
|
$form
|
2011-02-08 19:53:59 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
|
|
|
->setLabel('Title')
|
|
|
|
->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())
|
|
|
|
->setLabel('Status')
|
|
|
|
->setName('status')
|
|
|
|
->setValue($task->getStatus())
|
|
|
|
->setOptions(ManiphestTaskStatus::getTaskStatusMap()));
|
|
|
|
}
|
|
|
|
|
|
|
|
$form
|
2011-02-08 19:53:59 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
->setLabel('Assigned To')
|
|
|
|
->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())
|
|
|
|
->setLabel('CC')
|
|
|
|
->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())
|
|
|
|
->setLabel('Priority')
|
|
|
|
->setName('priority')
|
|
|
|
->setOptions($priority_map)
|
|
|
|
->setValue($task->getPriority()))
|
2011-02-21 05:08:16 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
->setLabel('Projects')
|
|
|
|
->setName('projects')
|
|
|
|
->setValue($projects_value)
|
2011-06-10 00:28:29 +02:00
|
|
|
->setID($project_tokenizer_id)
|
|
|
|
->setCaption(
|
|
|
|
javelin_render_tag(
|
|
|
|
'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',
|
|
|
|
),
|
|
|
|
'Create New Project'))
|
2011-05-06 18:17:55 +02:00
|
|
|
->setDatasource('/typeahead/common/projects/'));
|
|
|
|
|
2011-12-24 04:03:28 +01:00
|
|
|
if ($aux_fields) {
|
|
|
|
foreach ($aux_fields as $aux_field) {
|
|
|
|
if ($aux_field->isRequired() &&
|
|
|
|
!$aux_field->getError() &&
|
|
|
|
!$aux_field->getValue()) {
|
|
|
|
$aux_field->setError(true);
|
|
|
|
}
|
2011-07-27 18:49:50 +02:00
|
|
|
|
2011-12-24 04:03:28 +01:00
|
|
|
$aux_control = $aux_field->renderControl();
|
|
|
|
$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) {
|
|
|
|
$file_display = array();
|
|
|
|
foreach ($files as $file) {
|
|
|
|
$file_display[] = phutil_escape_html($file->getName());
|
|
|
|
}
|
|
|
|
$file_display = implode('<br />', $file_display);
|
|
|
|
|
|
|
|
$form->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
|
|
|
->setLabel('Files')
|
|
|
|
->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) {
|
|
|
|
$email_hint = 'You can also create tasks by sending an email to: '.
|
|
|
|
'<tt>'.phutil_escape_html($email_create).'</tt>';
|
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
|
|
|
|
->setLabel('Description')
|
|
|
|
->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);
|
|
|
|
|
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
|
|
|
if (!$task->getID()) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormDragAndDropUploadControl())
|
|
|
|
->setLabel('Attached Files')
|
|
|
|
->setName('files')
|
|
|
|
->setActivatedClass('aphront-panel-view-drag-and-drop'));
|
|
|
|
}
|
|
|
|
|
|
|
|
$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
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
|
|
|
$panel->setWidth(AphrontPanelView::WIDTH_FULL);
|
2011-02-20 23:15:53 +01:00
|
|
|
$panel->setHeader($header_name);
|
2011-02-08 19:53:59 +01:00
|
|
|
$panel->appendChild($form);
|
2013-01-19 23:30:26 +01:00
|
|
|
$panel->setNoBackground();
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2012-01-25 20:23:00 +01:00
|
|
|
$description_preview_panel =
|
|
|
|
'<div class="aphront-panel-preview aphront-panel-preview-full">
|
|
|
|
<div class="maniphest-description-preview-header">
|
|
|
|
Description Preview
|
|
|
|
</div>
|
|
|
|
<div id="description-preview">
|
|
|
|
<div class="aphront-panel-preview-loading-text">
|
|
|
|
Loading preview...
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'maniphest-description-preview',
|
|
|
|
array(
|
|
|
|
'preview' => 'description-preview',
|
|
|
|
'textarea' => 'description-textarea',
|
|
|
|
'uri' => '/maniphest/task/descriptionpreview/',
|
|
|
|
));
|
|
|
|
|
2012-06-14 02:28:21 +02:00
|
|
|
if ($task->getID()) {
|
|
|
|
$page_objects = array( $task->getPHID() );
|
|
|
|
} else {
|
|
|
|
$page_objects = array();
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
return $this->buildStandardPageResponse(
|
|
|
|
array(
|
|
|
|
$error_view,
|
|
|
|
$panel,
|
2012-01-25 20:23:00 +01:00
|
|
|
$description_preview_panel
|
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,
|
2011-02-08 19:53:59 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|