1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42:41 +01:00

Add draft support to ApplicationTransactions

Summary:
When previewing, save drafts. When loading objects, restore drafts if they are available.

Depends on: D665

Test Plan:
  - Viewed a Mock.
  - Typed text into the comment box.
  - Reloaded the page.
  - Text still there.
  - Hit submit, got my comment.
  - Reloaded the page.
  - Draft correctly deleted.
  - Repeated for Macros.

Reviewers: btrahan, chad, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2104

Differential Revision: https://secure.phabricator.com/D4252
This commit is contained in:
epriestley 2012-12-21 05:57:14 -08:00
parent 0fd77783a4
commit b116861b16
11 changed files with 243 additions and 127 deletions

2
externals/javelin vendored

@ -1 +1 @@
Subproject commit a2672d329212c90bda4f7979400a5149f9e967d2 Subproject commit 32c6e43f4b8b84df940bed8ed8d073e67f6c2b28

View file

@ -709,7 +709,7 @@ celerity_register_resource_map(array(
), ),
'aphront-tooltip-css' => 'aphront-tooltip-css' =>
array( array(
'uri' => '/res/32665c0e/rsrc/css/aphront/tooltip.css', 'uri' => '/res/79c36254/rsrc/css/aphront/tooltip.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -1199,7 +1199,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-differential-populate' => 'javelin-behavior-differential-populate' =>
array( array(
'uri' => '/res/781dd9a5/rsrc/js/application/differential/behavior-populate.js', 'uri' => '/res/769b91da/rsrc/js/application/differential/behavior-populate.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -1678,7 +1678,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-phabricator-transaction-comment-form' => 'javelin-behavior-phabricator-transaction-comment-form' =>
array( array(
'uri' => '/res/bdc362ee/rsrc/js/application/transactions/behavior-transaction-comment-form.js', 'uri' => '/res/acc3ada1/rsrc/js/application/transactions/behavior-transaction-comment-form.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -1691,7 +1691,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-phabricator-transaction-list' => 'javelin-behavior-phabricator-transaction-list' =>
array( array(
'uri' => '/res/212f97ba/rsrc/js/application/transactions/behavior-transaction-list.js', 'uri' => '/res/307a71af/rsrc/js/application/transactions/behavior-transaction-list.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -1881,7 +1881,7 @@ celerity_register_resource_map(array(
), ),
'javelin-dom' => 'javelin-dom' =>
array( array(
'uri' => '/res/4c79cf8a/rsrc/js/javelin/lib/DOM.js', 'uri' => '/res/2826c532/rsrc/js/javelin/lib/DOM.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -2063,7 +2063,7 @@ celerity_register_resource_map(array(
), ),
'javelin-stratcom' => 'javelin-stratcom' =>
array( array(
'uri' => '/res/3ec22c29/rsrc/js/javelin/core/Stratcom.js', 'uri' => '/res/c81f64eb/rsrc/js/javelin/core/Stratcom.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -2869,7 +2869,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-tooltip' => 'phabricator-tooltip' =>
array( array(
'uri' => '/res/bcddf5de/rsrc/js/application/core/ToolTip.js', 'uri' => '/res/55d76b9b/rsrc/js/application/core/ToolTip.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -3214,7 +3214,7 @@ celerity_register_resource_map(array(
), array( ), array(
'packages' => 'packages' =>
array( array(
'6d338e1d' => '43f32e36' =>
array( array(
'name' => 'core.pkg.css', 'name' => 'core.pkg.css',
'symbols' => 'symbols' =>
@ -3259,10 +3259,10 @@ celerity_register_resource_map(array(
37 => 'phabricator-object-item-list-view-css', 37 => 'phabricator-object-item-list-view-css',
38 => 'global-drag-and-drop-css', 38 => 'global-drag-and-drop-css',
), ),
'uri' => '/res/pkg/6d338e1d/core.pkg.css', 'uri' => '/res/pkg/43f32e36/core.pkg.css',
'type' => 'css', 'type' => 'css',
), ),
'70c8162b' => '2921e259' =>
array( array(
'name' => 'core.pkg.js', 'name' => 'core.pkg.js',
'symbols' => 'symbols' =>
@ -3300,7 +3300,7 @@ celerity_register_resource_map(array(
30 => 'phabricator-file-upload', 30 => 'phabricator-file-upload',
31 => 'javelin-behavior-global-drag-and-drop', 31 => 'javelin-behavior-global-drag-and-drop',
), ),
'uri' => '/res/pkg/70c8162b/core.pkg.js', 'uri' => '/res/pkg/2921e259/core.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'8edbada5' => '8edbada5' =>
@ -3338,7 +3338,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/380df740/differential.pkg.css', 'uri' => '/res/pkg/380df740/differential.pkg.css',
'type' => 'css', 'type' => 'css',
), ),
'8b98837e' => '76556a8f' =>
array( array(
'name' => 'differential.pkg.js', 'name' => 'differential.pkg.js',
'symbols' => 'symbols' =>
@ -3363,7 +3363,7 @@ celerity_register_resource_map(array(
17 => 'javelin-behavior-differential-toggle-files', 17 => 'javelin-behavior-differential-toggle-files',
18 => 'javelin-behavior-differential-user-select', 18 => 'javelin-behavior-differential-user-select',
), ),
'uri' => '/res/pkg/8b98837e/differential.pkg.js', 'uri' => '/res/pkg/76556a8f/differential.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'c8ce2d88' => 'c8ce2d88' =>
@ -3389,7 +3389,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/5e68be89/diffusion.pkg.js', 'uri' => '/res/pkg/5e68be89/diffusion.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'db6d724d' => 'fbeded59' =>
array( array(
'name' => 'javelin.pkg.js', 'name' => 'javelin.pkg.js',
'symbols' => 'symbols' =>
@ -3414,7 +3414,7 @@ celerity_register_resource_map(array(
17 => 'javelin-typeahead-ondemand-source', 17 => 'javelin-typeahead-ondemand-source',
18 => 'javelin-tokenizer', 18 => 'javelin-tokenizer',
), ),
'uri' => '/res/pkg/db6d724d/javelin.pkg.js', 'uri' => '/res/pkg/fbeded59/javelin.pkg.js',
'type' => 'js', 'type' => 'js',
), ),
'7839ae2d' => '7839ae2d' =>
@ -3448,23 +3448,23 @@ celerity_register_resource_map(array(
'reverse' => 'reverse' =>
array( array(
'aphront-attached-file-view-css' => '7839ae2d', 'aphront-attached-file-view-css' => '7839ae2d',
'aphront-crumbs-view-css' => '6d338e1d', 'aphront-crumbs-view-css' => '43f32e36',
'aphront-dialog-view-css' => '6d338e1d', 'aphront-dialog-view-css' => '43f32e36',
'aphront-error-view-css' => '6d338e1d', 'aphront-error-view-css' => '43f32e36',
'aphront-form-view-css' => '6d338e1d', 'aphront-form-view-css' => '43f32e36',
'aphront-headsup-action-list-view-css' => '380df740', 'aphront-headsup-action-list-view-css' => '380df740',
'aphront-headsup-view-css' => '6d338e1d', 'aphront-headsup-view-css' => '43f32e36',
'aphront-list-filter-view-css' => '6d338e1d', 'aphront-list-filter-view-css' => '43f32e36',
'aphront-pager-view-css' => '6d338e1d', 'aphront-pager-view-css' => '43f32e36',
'aphront-panel-view-css' => '6d338e1d', 'aphront-panel-view-css' => '43f32e36',
'aphront-side-nav-view-css' => '6d338e1d', 'aphront-side-nav-view-css' => '43f32e36',
'aphront-table-view-css' => '6d338e1d', 'aphront-table-view-css' => '43f32e36',
'aphront-tokenizer-control-css' => '6d338e1d', 'aphront-tokenizer-control-css' => '43f32e36',
'aphront-tooltip-css' => '6d338e1d', 'aphront-tooltip-css' => '43f32e36',
'aphront-typeahead-control-css' => '6d338e1d', 'aphront-typeahead-control-css' => '43f32e36',
'differential-changeset-view-css' => '380df740', 'differential-changeset-view-css' => '380df740',
'differential-core-view-css' => '380df740', 'differential-core-view-css' => '380df740',
'differential-inline-comment-editor' => '8b98837e', 'differential-inline-comment-editor' => '76556a8f',
'differential-local-commits-view-css' => '380df740', 'differential-local-commits-view-css' => '380df740',
'differential-results-table-css' => '380df740', 'differential-results-table-css' => '380df740',
'differential-revision-add-comment-css' => '380df740', 'differential-revision-add-comment-css' => '380df740',
@ -3475,117 +3475,117 @@ celerity_register_resource_map(array(
'differential-table-of-contents-css' => '380df740', 'differential-table-of-contents-css' => '380df740',
'diffusion-commit-view-css' => 'c8ce2d88', 'diffusion-commit-view-css' => 'c8ce2d88',
'diffusion-icons-css' => 'c8ce2d88', 'diffusion-icons-css' => 'c8ce2d88',
'global-drag-and-drop-css' => '6d338e1d', 'global-drag-and-drop-css' => '43f32e36',
'inline-comment-summary-css' => '380df740', 'inline-comment-summary-css' => '380df740',
'javelin-aphlict' => '70c8162b', 'javelin-aphlict' => '2921e259',
'javelin-behavior' => 'db6d724d', 'javelin-behavior' => 'fbeded59',
'javelin-behavior-aphlict-dropdown' => '70c8162b', 'javelin-behavior-aphlict-dropdown' => '2921e259',
'javelin-behavior-aphlict-listen' => '70c8162b', 'javelin-behavior-aphlict-listen' => '2921e259',
'javelin-behavior-aphront-basic-tokenizer' => '70c8162b', 'javelin-behavior-aphront-basic-tokenizer' => '2921e259',
'javelin-behavior-aphront-drag-and-drop' => '8b98837e', 'javelin-behavior-aphront-drag-and-drop' => '76556a8f',
'javelin-behavior-aphront-drag-and-drop-textarea' => '8b98837e', 'javelin-behavior-aphront-drag-and-drop-textarea' => '76556a8f',
'javelin-behavior-aphront-form-disable-on-submit' => '70c8162b', 'javelin-behavior-aphront-form-disable-on-submit' => '2921e259',
'javelin-behavior-audit-preview' => '5e68be89', 'javelin-behavior-audit-preview' => '5e68be89',
'javelin-behavior-dark-console' => '8edbada5', 'javelin-behavior-dark-console' => '8edbada5',
'javelin-behavior-dark-console-ajax' => '8edbada5', 'javelin-behavior-dark-console-ajax' => '8edbada5',
'javelin-behavior-device' => '70c8162b', 'javelin-behavior-device' => '2921e259',
'javelin-behavior-differential-accept-with-errors' => '8b98837e', 'javelin-behavior-differential-accept-with-errors' => '76556a8f',
'javelin-behavior-differential-add-reviewers-and-ccs' => '8b98837e', 'javelin-behavior-differential-add-reviewers-and-ccs' => '76556a8f',
'javelin-behavior-differential-comment-jump' => '8b98837e', 'javelin-behavior-differential-comment-jump' => '76556a8f',
'javelin-behavior-differential-diff-radios' => '8b98837e', 'javelin-behavior-differential-diff-radios' => '76556a8f',
'javelin-behavior-differential-dropdown-menus' => '8b98837e', 'javelin-behavior-differential-dropdown-menus' => '76556a8f',
'javelin-behavior-differential-edit-inline-comments' => '8b98837e', 'javelin-behavior-differential-edit-inline-comments' => '76556a8f',
'javelin-behavior-differential-feedback-preview' => '8b98837e', 'javelin-behavior-differential-feedback-preview' => '76556a8f',
'javelin-behavior-differential-keyboard-navigation' => '8b98837e', 'javelin-behavior-differential-keyboard-navigation' => '76556a8f',
'javelin-behavior-differential-populate' => '8b98837e', 'javelin-behavior-differential-populate' => '76556a8f',
'javelin-behavior-differential-show-more' => '8b98837e', 'javelin-behavior-differential-show-more' => '76556a8f',
'javelin-behavior-differential-toggle-files' => '8b98837e', 'javelin-behavior-differential-toggle-files' => '76556a8f',
'javelin-behavior-differential-user-select' => '8b98837e', 'javelin-behavior-differential-user-select' => '76556a8f',
'javelin-behavior-diffusion-commit-graph' => '5e68be89', 'javelin-behavior-diffusion-commit-graph' => '5e68be89',
'javelin-behavior-diffusion-pull-lastmodified' => '5e68be89', 'javelin-behavior-diffusion-pull-lastmodified' => '5e68be89',
'javelin-behavior-error-log' => '8edbada5', 'javelin-behavior-error-log' => '8edbada5',
'javelin-behavior-global-drag-and-drop' => '70c8162b', 'javelin-behavior-global-drag-and-drop' => '2921e259',
'javelin-behavior-konami' => '70c8162b', 'javelin-behavior-konami' => '2921e259',
'javelin-behavior-lightbox-attachments' => '70c8162b', 'javelin-behavior-lightbox-attachments' => '2921e259',
'javelin-behavior-maniphest-batch-selector' => '7707de41', 'javelin-behavior-maniphest-batch-selector' => '7707de41',
'javelin-behavior-maniphest-subpriority-editor' => '7707de41', 'javelin-behavior-maniphest-subpriority-editor' => '7707de41',
'javelin-behavior-maniphest-transaction-controls' => '7707de41', 'javelin-behavior-maniphest-transaction-controls' => '7707de41',
'javelin-behavior-maniphest-transaction-expand' => '7707de41', 'javelin-behavior-maniphest-transaction-expand' => '7707de41',
'javelin-behavior-maniphest-transaction-preview' => '7707de41', 'javelin-behavior-maniphest-transaction-preview' => '7707de41',
'javelin-behavior-phabricator-active-nav' => '70c8162b', 'javelin-behavior-phabricator-active-nav' => '2921e259',
'javelin-behavior-phabricator-autofocus' => '70c8162b', 'javelin-behavior-phabricator-autofocus' => '2921e259',
'javelin-behavior-phabricator-keyboard-shortcuts' => '70c8162b', 'javelin-behavior-phabricator-keyboard-shortcuts' => '2921e259',
'javelin-behavior-phabricator-nav' => '70c8162b', 'javelin-behavior-phabricator-nav' => '2921e259',
'javelin-behavior-phabricator-object-selector' => '8b98837e', 'javelin-behavior-phabricator-object-selector' => '76556a8f',
'javelin-behavior-phabricator-oncopy' => '70c8162b', 'javelin-behavior-phabricator-oncopy' => '2921e259',
'javelin-behavior-phabricator-remarkup-assist' => '70c8162b', 'javelin-behavior-phabricator-remarkup-assist' => '2921e259',
'javelin-behavior-phabricator-search-typeahead' => '70c8162b', 'javelin-behavior-phabricator-search-typeahead' => '2921e259',
'javelin-behavior-phabricator-tooltips' => '70c8162b', 'javelin-behavior-phabricator-tooltips' => '2921e259',
'javelin-behavior-phabricator-watch-anchor' => '70c8162b', 'javelin-behavior-phabricator-watch-anchor' => '2921e259',
'javelin-behavior-refresh-csrf' => '70c8162b', 'javelin-behavior-refresh-csrf' => '2921e259',
'javelin-behavior-repository-crossreference' => '8b98837e', 'javelin-behavior-repository-crossreference' => '76556a8f',
'javelin-behavior-toggle-class' => '70c8162b', 'javelin-behavior-toggle-class' => '2921e259',
'javelin-behavior-workflow' => '70c8162b', 'javelin-behavior-workflow' => '2921e259',
'javelin-dom' => 'db6d724d', 'javelin-dom' => 'fbeded59',
'javelin-event' => 'db6d724d', 'javelin-event' => 'fbeded59',
'javelin-install' => 'db6d724d', 'javelin-install' => 'fbeded59',
'javelin-json' => 'db6d724d', 'javelin-json' => 'fbeded59',
'javelin-mask' => 'db6d724d', 'javelin-mask' => 'fbeded59',
'javelin-request' => 'db6d724d', 'javelin-request' => 'fbeded59',
'javelin-resource' => 'db6d724d', 'javelin-resource' => 'fbeded59',
'javelin-stratcom' => 'db6d724d', 'javelin-stratcom' => 'fbeded59',
'javelin-tokenizer' => 'db6d724d', 'javelin-tokenizer' => 'fbeded59',
'javelin-typeahead' => 'db6d724d', 'javelin-typeahead' => 'fbeded59',
'javelin-typeahead-normalizer' => 'db6d724d', 'javelin-typeahead-normalizer' => 'fbeded59',
'javelin-typeahead-ondemand-source' => 'db6d724d', 'javelin-typeahead-ondemand-source' => 'fbeded59',
'javelin-typeahead-preloaded-source' => 'db6d724d', 'javelin-typeahead-preloaded-source' => 'fbeded59',
'javelin-typeahead-source' => 'db6d724d', 'javelin-typeahead-source' => 'fbeded59',
'javelin-uri' => 'db6d724d', 'javelin-uri' => 'fbeded59',
'javelin-util' => 'db6d724d', 'javelin-util' => 'fbeded59',
'javelin-vector' => 'db6d724d', 'javelin-vector' => 'fbeded59',
'javelin-workflow' => 'db6d724d', 'javelin-workflow' => 'fbeded59',
'lightbox-attachment-css' => '6d338e1d', 'lightbox-attachment-css' => '43f32e36',
'maniphest-task-summary-css' => '7839ae2d', 'maniphest-task-summary-css' => '7839ae2d',
'maniphest-transaction-detail-css' => '7839ae2d', 'maniphest-transaction-detail-css' => '7839ae2d',
'phabricator-app-buttons-css' => '6d338e1d', 'phabricator-app-buttons-css' => '43f32e36',
'phabricator-busy' => '70c8162b', 'phabricator-busy' => '2921e259',
'phabricator-content-source-view-css' => '380df740', 'phabricator-content-source-view-css' => '380df740',
'phabricator-core-buttons-css' => '6d338e1d', 'phabricator-core-buttons-css' => '43f32e36',
'phabricator-core-css' => '6d338e1d', 'phabricator-core-css' => '43f32e36',
'phabricator-crumbs-view-css' => '6d338e1d', 'phabricator-crumbs-view-css' => '43f32e36',
'phabricator-directory-css' => '6d338e1d', 'phabricator-directory-css' => '43f32e36',
'phabricator-drag-and-drop-file-upload' => '8b98837e', 'phabricator-drag-and-drop-file-upload' => '76556a8f',
'phabricator-dropdown-menu' => '70c8162b', 'phabricator-dropdown-menu' => '2921e259',
'phabricator-file-upload' => '70c8162b', 'phabricator-file-upload' => '2921e259',
'phabricator-filetree-view-css' => '6d338e1d', 'phabricator-filetree-view-css' => '43f32e36',
'phabricator-flag-css' => '6d338e1d', 'phabricator-flag-css' => '43f32e36',
'phabricator-form-view-css' => '6d338e1d', 'phabricator-form-view-css' => '43f32e36',
'phabricator-header-view-css' => '6d338e1d', 'phabricator-header-view-css' => '43f32e36',
'phabricator-jump-nav' => '6d338e1d', 'phabricator-jump-nav' => '43f32e36',
'phabricator-keyboard-shortcut' => '70c8162b', 'phabricator-keyboard-shortcut' => '2921e259',
'phabricator-keyboard-shortcut-manager' => '70c8162b', 'phabricator-keyboard-shortcut-manager' => '2921e259',
'phabricator-main-menu-view' => '6d338e1d', 'phabricator-main-menu-view' => '43f32e36',
'phabricator-menu-item' => '70c8162b', 'phabricator-menu-item' => '2921e259',
'phabricator-nav-view-css' => '6d338e1d', 'phabricator-nav-view-css' => '43f32e36',
'phabricator-notification' => '70c8162b', 'phabricator-notification' => '2921e259',
'phabricator-notification-css' => '6d338e1d', 'phabricator-notification-css' => '43f32e36',
'phabricator-notification-menu-css' => '6d338e1d', 'phabricator-notification-menu-css' => '43f32e36',
'phabricator-object-item-list-view-css' => '6d338e1d', 'phabricator-object-item-list-view-css' => '43f32e36',
'phabricator-object-selector-css' => '380df740', 'phabricator-object-selector-css' => '380df740',
'phabricator-paste-file-upload' => '70c8162b', 'phabricator-paste-file-upload' => '2921e259',
'phabricator-prefab' => '70c8162b', 'phabricator-prefab' => '2921e259',
'phabricator-project-tag-css' => '7839ae2d', 'phabricator-project-tag-css' => '7839ae2d',
'phabricator-remarkup-css' => '6d338e1d', 'phabricator-remarkup-css' => '43f32e36',
'phabricator-shaped-request' => '8b98837e', 'phabricator-shaped-request' => '76556a8f',
'phabricator-side-menu-view-css' => '6d338e1d', 'phabricator-side-menu-view-css' => '43f32e36',
'phabricator-standard-page-view' => '6d338e1d', 'phabricator-standard-page-view' => '43f32e36',
'phabricator-textareautils' => '70c8162b', 'phabricator-textareautils' => '2921e259',
'phabricator-tooltip' => '70c8162b', 'phabricator-tooltip' => '2921e259',
'phabricator-transaction-view-css' => '6d338e1d', 'phabricator-transaction-view-css' => '43f32e36',
'sprite-apps-large-css' => '6d338e1d', 'sprite-apps-large-css' => '43f32e36',
'sprite-gradient-css' => '6d338e1d', 'sprite-gradient-css' => '43f32e36',
'sprite-icon-css' => '6d338e1d', 'sprite-icon-css' => '43f32e36',
'sprite-menu-css' => '6d338e1d', 'sprite-menu-css' => '43f32e36',
'syntax-highlighting-css' => '6d338e1d', 'syntax-highlighting-css' => '43f32e36',
), ),
)); ));

View file

@ -353,7 +353,16 @@ final class AphrontRequest {
* @return dict<string, string> Original request parameters. * @return dict<string, string> Original request parameters.
*/ */
public function getPassthroughRequestParameters() { public function getPassthroughRequestParameters() {
$data = self::flattenData($this->getRequestData()); return self::flattenData($this->getPassthruRequestData());
}
/**
* Get request data other than "magic" parameters.
*
* @return dict<string, wild> Request data, with magic filtered out.
*/
public function getPassthroughRequestData() {
$data = $this->getRequestData();
// Remove magic parameters like __dialog__ and __ajax__. // Remove magic parameters like __dialog__ and __ajax__.
foreach ($data as $key => $value) { foreach ($data as $key => $value) {

View file

@ -28,4 +28,53 @@ final class PhabricatorDraft extends PhabricatorDraftDAO {
return parent::replace(); return parent::replace();
} }
public static function newFromUserAndKey(PhabricatorUser $user, $key) {
if ($user->getPHID() && strlen($key)) {
$draft = id(new PhabricatorDraft())->loadOneWhere(
'authorPHID = %s AND draftKey = %s',
$user->getPHID(),
$key);
if ($draft) {
return $draft;
}
}
$draft = new PhabricatorDraft();
if ($user->getPHID()) {
$draft
->setAuthorPHID($user->getPHID())
->setDraftKey($key);
}
return $draft;
}
public static function buildFromRequest(AphrontRequest $request) {
$user = $request->getUser();
if (!$user->getPHID()) {
return null;
}
if (!$request->getStr('__draft__')) {
return null;
}
$draft = id(new PhabricatorDraft())
->setAuthorPHID($user->getPHID())
->setDraftKey($request->getStr('__draft__'));
// If this is a preview, add other data. If not, leave the draft empty so
// that replaceOrDelete() will delete it.
if ($request->isPreviewRequest()) {
$other_data = $request->getPassthroughRequestData();
unset($other_data['comment']);
$draft
->setDraft($request->getStr('comment'))
->setMetadata($other_data);
}
return $draft;
}
} }

View file

@ -23,6 +23,7 @@ final class PhabricatorMacroCommentController
} }
$is_preview = $request->isPreviewRequest(); $is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$view_uri = $this->getApplicationURI('/view/'.$macro->getID().'/'); $view_uri = $this->getApplicationURI('/view/'.$macro->getID().'/');
@ -52,6 +53,10 @@ final class PhabricatorMacroCommentController
->setException($ex); ->setException($ex);
} }
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax()) { if ($request->isAjax()) {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($user) ->setViewer($user)

View file

@ -83,8 +83,11 @@ final class PhabricatorMacroViewController
? pht('Add Comment') ? pht('Add Comment')
: pht('Lavish Praise'); : pht('Lavish Praise');
$draft = PhabricatorDraft::newFromUserAndKey($user, $macro->getPHID());
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView()) $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
->setUser($user) ->setUser($user)
->setDraft($draft)
->setAction($this->getApplicationURI('/comment/'.$macro->getID().'/')) ->setAction($this->getApplicationURI('/comment/'.$macro->getID().'/'))
->setSubmitButtonName($submit_button_name); ->setSubmitButtonName($submit_button_name);

View file

@ -30,6 +30,8 @@ final class PholioMockCommentController extends PholioController {
$is_preview = $request->isPreviewRequest(); $is_preview = $request->isPreviewRequest();
$draft = PhabricatorDraft::buildFromRequest($request);
$mock_uri = '/M'.$mock->getID(); $mock_uri = '/M'.$mock->getID();
$comment = $request->getStr('comment'); $comment = $request->getStr('comment');
@ -61,6 +63,10 @@ final class PholioMockCommentController extends PholioController {
->setException($ex); ->setException($ex);
} }
if ($draft) {
$draft->replaceOrDelete();
}
if ($request->isAjax()) { if ($request->isAjax()) {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($user) ->setViewer($user)

View file

@ -159,6 +159,8 @@ final class PholioMockViewController extends PholioController {
private function buildAddCommentView(PholioMock $mock) { private function buildAddCommentView(PholioMock $mock) {
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$draft = PhabricatorDraft::newFromUserAndKey($user, $mock->getPHID());
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$title = $is_serious $title = $is_serious
@ -174,6 +176,7 @@ final class PholioMockViewController extends PholioController {
$form = id(new PhabricatorApplicationTransactionCommentView()) $form = id(new PhabricatorApplicationTransactionCommentView())
->setUser($user) ->setUser($user)
->setDraft($draft)
->setSubmitButtonName($button_name) ->setSubmitButtonName($button_name)
->setAction($this->getApplicationURI('/comment/'.$mock->getID().'/')); ->setAction($this->getApplicationURI('/comment/'.$mock->getID().'/'));

View file

@ -13,6 +13,17 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
private $previewToggleID; private $previewToggleID;
private $formID; private $formID;
private $statusID; private $statusID;
private $commentID;
private $draft;
public function setDraft(PhabricatorDraft $draft) {
$this->draft = $draft;
return $this;
}
public function getDraft() {
return $this->draft;
}
public function setSubmitButtonName($submit_button_name) { public function setSubmitButtonName($submit_button_name) {
$this->submitButtonName = $submit_button_name; $this->submitButtonName = $submit_button_name;
@ -47,12 +58,14 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
'timelineID' => $this->getPreviewTimelineID(), 'timelineID' => $this->getPreviewTimelineID(),
'panelID' => $this->getPreviewPanelID(), 'panelID' => $this->getPreviewPanelID(),
'statusID' => $this->getStatusID(), 'statusID' => $this->getStatusID(),
'commentID' => $this->getCommentID(),
'loadingString' => pht('Loading Preview...'), 'loadingString' => pht('Loading Preview...'),
'savingString' => pht('Saving Draft...'), 'savingString' => pht('Saving Draft...'),
'draftString' => pht('Saved Draft'), 'draftString' => pht('Saved Draft'),
'actionURI' => $this->getAction(), 'actionURI' => $this->getAction(),
'draftKey' => $this->getDraft()->getDraftKey(),
)); ));
return self::renderSingleView( return self::renderSingleView(
@ -70,6 +83,11 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
), ),
''); '');
$draft_comment = '';
if ($this->getDraft()) {
$draft_comment = $this->getDraft()->getDraft();
}
return id(new AphrontFormView()) return id(new AphrontFormView())
->setUser($this->getUser()) ->setUser($this->getUser())
->setFlexible(true) ->setFlexible(true)
@ -79,9 +97,11 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
->setID($this->getFormID()) ->setID($this->getFormID())
->appendChild( ->appendChild(
id(new PhabricatorRemarkupControl()) id(new PhabricatorRemarkupControl())
->setID($this->getCommentID())
->setName('comment') ->setName('comment')
->setLabel(pht('Comment')) ->setLabel(pht('Comment'))
->setUser($this->getUser())) ->setUser($this->getUser()))
->setValue($draft_comment)
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue($this->getSubmitButtonName())) ->setValue($this->getSubmitButtonName()))
@ -143,5 +163,12 @@ class PhabricatorApplicationTransactionCommentView extends AphrontView {
return $this->statusID; return $this->statusID;
} }
private function getCommentID() {
if (!$this->commentID) {
$this->commentID = celerity_generate_unique_node_id();
}
return $this->commentID;
}
} }

View file

@ -10,9 +10,19 @@ JX.behavior('phabricator-transaction-comment-form', function(config) {
var form = JX.$(config.formID); var form = JX.$(config.formID);
JX.DOM.listen(form, 'willClear', null, function(e) {
e.kill();
JX.$(config.commentID).value = '';
});
var getdata = function() { var getdata = function() {
var obj = JX.DOM.convertFormToDictionary(form); var obj = JX.DOM.convertFormToDictionary(form);
obj.__preview__ = 1; obj.__preview__ = 1;
if (config.draftKey) {
obj.__draft__ = config.draftKey;
}
return obj; return obj;
}; };

View file

@ -81,7 +81,11 @@ JX.behavior('phabricator-transaction-list', function(config) {
JX.Workflow.newFromForm(form, {anchor: next_anchor}) JX.Workflow.newFromForm(form, {anchor: next_anchor})
.setHandler(function(response) { .setHandler(function(response) {
ontransactions(response); ontransactions(response);
var e = JX.DOM.invoke(form, 'willClear');
if (!e.getPrevented()) {
form.reset(); form.reset();
}
}) })
.start(); .start();