1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 12:52:42 +01:00

Add drafts to Maniphest

Summary:
Use PhabricatorDraft to save text when previewing it so you don't lose stuff if
your browser crashes.

Test Plan:
Typed some text, closed/reopened the page, text was still there. Submitted
comment, text vanished.

Reviewed By: tuomaspelkonen
Reviewers: rm, tuomaspelkonen, jungejason, aran
CC: aran, tuomaspelkonen
Differential Revision: 262
This commit is contained in:
epriestley 2011-05-10 16:18:47 -07:00
parent e4f42dcd7d
commit c51eb2696d
6 changed files with 41 additions and 0 deletions

View file

@ -207,6 +207,16 @@ class ManiphestTaskDetailController extends ManiphestController {
$user->getPHID() => $user->getUsername().' ('.$user->getRealName().')',
);
$draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s',
$user->getPHID(),
$task->getPHID());
if ($draft) {
$draft_text = $draft->getDraft();
} else {
$draft_text = null;
}
$comment_form = new AphrontFormView();
$comment_form
->setUser($user)
@ -268,6 +278,7 @@ class ManiphestTaskDetailController extends ManiphestController {
id(new AphrontFormTextAreaControl())
->setLabel('Comments')
->setName('comments')
->setValue($draft_text)
->setID('transaction-comments'))
->appendChild(
id(new AphrontFormSubmitControl())

View file

@ -8,6 +8,7 @@
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/draft/storage/draft');
phutil_require_module('phabricator', 'applications/maniphest/constants/priority');
phutil_require_module('phabricator', 'applications/maniphest/constants/status');
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');

View file

@ -31,6 +31,23 @@ class ManiphestTransactionPreviewController extends ManiphestController {
$comments = $request->getStr('comments');
$task = id(new ManiphestTask())->load($this->id);
if (!$task) {
return new Aphront404Response();
}
$draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s',
$user->getPHID(),
$task->getPHID());
if (!$draft) {
$draft = new PhabricatorDraft();
$draft->setAuthorPHID($user->getPHID());
$draft->setDraftKey($task->getPHID());
}
$draft->setDraft($comments);
$draft->save();
$handles = id(new PhabricatorObjectHandleData(array($user->getPHID())))
->loadHandles();

View file

@ -6,10 +6,13 @@
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'applications/differential/parser/markup');
phutil_require_module('phabricator', 'applications/draft/storage/draft');
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
phutil_require_module('phabricator', 'applications/maniphest/controller/base');
phutil_require_module('phabricator', 'applications/maniphest/storage/task');
phutil_require_module('phabricator', 'applications/maniphest/storage/transaction');
phutil_require_module('phabricator', 'applications/maniphest/view/transactionlist');
phutil_require_module('phabricator', 'applications/phid/handle/data');

View file

@ -143,6 +143,14 @@ class ManiphestTransactionSaveController extends ManiphestController {
$editor = new ManiphestTransactionEditor();
$editor->applyTransactions($task, $transactions);
$draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s',
$user->getPHID(),
$task->getPHID());
if ($draft) {
$draft->delete();
}
return id(new AphrontRedirectResponse())
->setURI('/T'.$task->getID());
}

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/draft/storage/draft');
phutil_require_module('phabricator', 'applications/files/storage/file');
phutil_require_module('phabricator', 'applications/maniphest/constants/status');
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');