Task -> Project assocation, file uploads

Summary:

Test Plan:

Reviewers:

CC:
This commit is contained in:
epriestley
2011-02-20 20:08:16 -08:00
parent fdd510ba17
commit 7fb9a48690
16 changed files with 211 additions and 23 deletions

View File

@@ -48,6 +48,9 @@ class ManiphestTaskDetailController extends ManiphestController {
foreach ($task->getCCPHIDs() as $phid) {
$phids[$phid] = true;
}
foreach ($task->getProjectPHIDs() as $phid) {
$phids[$phid] = true;
}
if ($task->getOwnerPHID()) {
$phids[$task->getOwnerPHID()] = true;
}
@@ -93,6 +96,17 @@ class ManiphestTaskDetailController extends ManiphestController {
$dict['Author'] = $handles[$task->getAuthorPHID()]->renderLink();
$projects = $task->getProjectPHIDs();
if ($projects) {
$project_links = array();
foreach ($projects as $phid) {
$project_links[] = $handles[$phid]->renderLink();
}
$dict['Projects'] = implode(', ', $project_links);
} else {
$dict['Projects'] = '<em>None</em>';
}
if (idx($attached, 'DREV')) {
$revs = idx($attached, 'DREV');
$rev_links = array();
@@ -103,6 +117,17 @@ class ManiphestTaskDetailController extends ManiphestController {
$dict['Revisions'] = $rev_links;
}
if (idx($attached, 'FILE')) {
$revs = idx($attached, 'FILE');
$rev_links = array();
foreach ($revs as $rev => $info) {
$rev_links[] = $handles[$rev]->renderLink();
}
$rev_links = implode(', ', $rev_links);
$dict['Files'] = $rev_links;
}
$dict['Description'] =
'<div class="maniphest-task-description">'.
'<div class="phabricator-remarkup">'.
@@ -134,11 +159,6 @@ class ManiphestTaskDetailController extends ManiphestController {
$action->setClass('action-edit');
$actions[] = $action;
$action = new AphrontHeadsupActionView();
$action->setName('Upload File');
$action->setClass('action-upload unavailable');
$actions[] = $action;
$action = new AphrontHeadsupActionView();
$action->setName('Edit Differential Revisions');
$action->setClass('action-attach unavailable');
@@ -188,6 +208,7 @@ class ManiphestTaskDetailController extends ManiphestController {
$comment_form
->setUser($user)
->setAction('/maniphest/transaction/save/')
->setEncType('multipart/form-data')
->addHiddenInput('taskID', $task->getID())
->appendChild(
id(new AphrontFormSelectControl())
@@ -226,6 +247,20 @@ class ManiphestTaskDetailController extends ManiphestController {
->setControlID('priority')
->setControlStyle('display: none')
->setValue($task->getPriority()))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel('Projects')
->setName('projects')
->setControlID('projects')
->setControlStyle('display: none')
->setID('projects-tokenizer')
->setDisableBehavior(true))
->appendChild(
id(new AphrontFormFileControl())
->setLabel('File')
->setName('file')
->setControlID('file')
->setControlStyle('display: none'))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Comments')
@@ -242,8 +277,14 @@ class ManiphestTaskDetailController extends ManiphestController {
ManiphestTransactionType::TYPE_OWNER => 'assign_to',
ManiphestTransactionType::TYPE_CCS => 'ccs',
ManiphestTransactionType::TYPE_PRIORITY => 'priority',
ManiphestTransactionType::TYPE_PROJECTS => 'projects',
ManiphestTransactionType::TYPE_ATTACH => 'file',
),
'tokenizers' => array(
ManiphestTransactionType::TYPE_PROJECTS => array(
'id' => 'projects-tokenizer',
'src' => '/typeahead/common/projects/',
),
ManiphestTransactionType::TYPE_OWNER => array(
'id' => 'assign-tokenizer',
'src' => '/typeahead/common/users/',

View File

@@ -60,6 +60,8 @@ class ManiphestTaskEditController extends ManiphestController {
} else {
$task->setTitle($new_title);
$task->setDescription($new_desc);
$changes[ManiphestTransactionType::TYPE_STATUS] =
ManiphestTaskStatus::STATUS_OPEN;
}
$owner_tokenizer = $request->getArr('assigned_to');
@@ -72,22 +74,25 @@ class ManiphestTaskEditController extends ManiphestController {
if (!$errors) {
$changes[ManiphestTransactionType::TYPE_STATUS] =
ManiphestTaskStatus::STATUS_OPEN;
if ($request->getInt('priority') != $task->getPriority()) {
$changes[ManiphestTransactionType::TYPE_PRIORITY] =
$request->getInt('priority');
}
if ($owner_phid) {
if ($owner_phid != $task->getOwnerPHID()) {
$changes[ManiphestTransactionType::TYPE_OWNER] = $owner_phid;
}
if ($request->getArr('cc')) {
if ($request->getArr('cc') != $task->getCCPHIDs()) {
$changes[ManiphestTransactionType::TYPE_CCS] = $request->getArr('cc');
}
if ($request->getArr('projects') != $task->getProjectPHIDs()) {
$changes[ManiphestTransactionType::TYPE_PROJECTS]
= $request->getArr('projects');
}
$template = new ManiphestTransaction();
$template->setAuthorPHID($user->getPHID());
$transactions = array();
@@ -115,7 +120,8 @@ class ManiphestTaskEditController extends ManiphestController {
$phids = array_merge(
array($task->getOwnerPHID()),
$task->getCCPHIDs());
$task->getCCPHIDs(),
$task->getProjectPHIDs());
$phids = array_filter($phids);
$phids = array_unique($phids);
@@ -147,6 +153,12 @@ class ManiphestTaskEditController extends ManiphestController {
$cc_value = array();
}
if ($task->getProjectPHIDs()) {
$projects_value = array_select_keys($tvalues, $task->getProjectPHIDs());
} else {
$projects_value = array();
}
if ($task->getID()) {
$cancel_uri = '/T'.$task->getID();
$button_name = 'Save Task';
@@ -186,6 +198,12 @@ class ManiphestTaskEditController extends ManiphestController {
->setName('priority')
->setOptions($priority_map)
->setValue($task->getPriority()))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel('Projects')
->setName('projects')
->setValue($projects_value)
->setDatasource('/typeahead/common/projects/'))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Description')

View File

@@ -46,6 +46,13 @@ class ManiphestTransactionSaveController extends ManiphestController {
$assign_to = reset($assign_to);
$transaction->setNewValue($assign_to);
break;
case ManiphestTransactionType::TYPE_PROJECTS:
$projects = $request->getArr('projects');
$projects = array_merge($projects, $task->getProjectPHIDs());
$projects = array_filter($projects);
$projects = array_unique($projects);
$transaction->setNewValue($projects);
break;
case ManiphestTransactionType::TYPE_CCS:
$ccs = $request->getArr('ccs');
$ccs = array_merge($ccs, $task->getCCPHIDs());
@@ -56,6 +63,30 @@ class ManiphestTransactionSaveController extends ManiphestController {
case ManiphestTransactionType::TYPE_PRIORITY:
$transaction->setNewValue($request->getInt('priority'));
break;
case ManiphestTransactionType::TYPE_ATTACH:
// This means "attach a file" even though we store other types of data
// as 'attached'.
$phid = null;
if (!empty($_FILES['file'])) {
$err = idx($_FILES['file'], 'error');
if ($err != UPLOAD_ERR_NO_FILE) {
$file = PhabricatorFile::newFromPHPUpload($_FILES['file']);
$phid = $file->getPHID();
}
}
if ($phid) {
$new = $task->getAttached();
if (empty($new['FILE'])) {
$new['FILE'] = array();
}
$new['FILE'][$phid] = array();
}
var_dump($new);
die();
$transaction->setNewValue($new);
break;
default:
throw new Exception('unknown action');
}

View File

@@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
phutil_require_module('phabricator', 'applications/maniphest/controller/base');
phutil_require_module('phabricator', 'applications/maniphest/editor/transaction');