mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +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:
parent
e4f42dcd7d
commit
c51eb2696d
6 changed files with 41 additions and 0 deletions
|
@ -207,6 +207,16 @@ class ManiphestTaskDetailController extends ManiphestController {
|
||||||
$user->getPHID() => $user->getUsername().' ('.$user->getRealName().')',
|
$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 = new AphrontFormView();
|
||||||
$comment_form
|
$comment_form
|
||||||
->setUser($user)
|
->setUser($user)
|
||||||
|
@ -268,6 +278,7 @@ class ManiphestTaskDetailController extends ManiphestController {
|
||||||
id(new AphrontFormTextAreaControl())
|
id(new AphrontFormTextAreaControl())
|
||||||
->setLabel('Comments')
|
->setLabel('Comments')
|
||||||
->setName('comments')
|
->setName('comments')
|
||||||
|
->setValue($draft_text)
|
||||||
->setID('transaction-comments'))
|
->setID('transaction-comments'))
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormSubmitControl())
|
id(new AphrontFormSubmitControl())
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'aphront/response/404');
|
phutil_require_module('phabricator', 'aphront/response/404');
|
||||||
phutil_require_module('phabricator', 'applications/differential/parser/markup');
|
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/priority');
|
||||||
phutil_require_module('phabricator', 'applications/maniphest/constants/status');
|
phutil_require_module('phabricator', 'applications/maniphest/constants/status');
|
||||||
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
|
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
|
||||||
|
|
|
@ -31,6 +31,23 @@ class ManiphestTransactionPreviewController extends ManiphestController {
|
||||||
|
|
||||||
$comments = $request->getStr('comments');
|
$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())))
|
$handles = id(new PhabricatorObjectHandleData(array($user->getPHID())))
|
||||||
->loadHandles();
|
->loadHandles();
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,13 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/404');
|
||||||
phutil_require_module('phabricator', 'aphront/response/ajax');
|
phutil_require_module('phabricator', 'aphront/response/ajax');
|
||||||
phutil_require_module('phabricator', 'applications/differential/parser/markup');
|
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/constants/transactiontype');
|
||||||
phutil_require_module('phabricator', 'applications/maniphest/controller/base');
|
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/storage/transaction');
|
||||||
phutil_require_module('phabricator', 'applications/maniphest/view/transactionlist');
|
phutil_require_module('phabricator', 'applications/maniphest/view/transactionlist');
|
||||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||||
|
|
|
@ -143,6 +143,14 @@ class ManiphestTransactionSaveController extends ManiphestController {
|
||||||
$editor = new ManiphestTransactionEditor();
|
$editor = new ManiphestTransactionEditor();
|
||||||
$editor->applyTransactions($task, $transactions);
|
$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())
|
return id(new AphrontRedirectResponse())
|
||||||
->setURI('/T'.$task->getID());
|
->setURI('/T'.$task->getID());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'aphront/response/404');
|
phutil_require_module('phabricator', 'aphront/response/404');
|
||||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
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/files/storage/file');
|
||||||
phutil_require_module('phabricator', 'applications/maniphest/constants/status');
|
phutil_require_module('phabricator', 'applications/maniphest/constants/status');
|
||||||
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
|
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
|
||||||
|
|
Loading…
Reference in a new issue