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
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-phabricator-transaction-comment-form
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
* javelin-util
|
|
* phabricator-shaped-request
|
|
*/
|
|
|
|
JX.behavior('phabricator-transaction-comment-form', function(config) {
|
|
|
|
var form = JX.$(config.formID);
|
|
|
|
JX.DOM.listen(form, 'willClear', null, function(e) {
|
|
e.kill();
|
|
JX.$(config.commentID).value = '';
|
|
});
|
|
|
|
var getdata = function() {
|
|
var obj = JX.DOM.convertFormToDictionary(form);
|
|
obj.__preview__ = 1;
|
|
|
|
if (config.draftKey) {
|
|
obj.__draft__ = config.draftKey;
|
|
}
|
|
|
|
return obj;
|
|
};
|
|
|
|
var onresponse = function(response) {
|
|
var panel = JX.$(config.panelID);
|
|
if (!response.xactions.length) {
|
|
JX.DOM.hide(panel);
|
|
} else {
|
|
JX.DOM.setContent(
|
|
JX.$(config.timelineID),
|
|
[
|
|
JX.$H(response.spacer),
|
|
JX.$H(response.xactions.join(response.spacer)),
|
|
JX.$H(response.spacer),
|
|
]);
|
|
JX.DOM.show(panel);
|
|
}
|
|
};
|
|
|
|
var request = new JX.PhabricatorShapedRequest(
|
|
config.actionURI,
|
|
onresponse,
|
|
getdata);
|
|
var trigger = JX.bind(request, request.trigger);
|
|
|
|
JX.DOM.listen(form, 'keydown', null, trigger);
|
|
|
|
request.start();
|
|
});
|