mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 17:22:42 +01:00
9de39c12a2
Summary: Fixes T4846. These are one off (for now) since they have various crazy actions with them. I think this will get unified and more cleaned up when we refine the UI for taking multiple actions at once, etc. Test Plan: noted no "commented on x" in either maniphest or differential. starting making a comment and noted prevew showed. started adding a subscriber (added to tokenizer) and preview showed. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T4846 Differential Revision: https://secure.phabricator.com/D12936
76 lines
2 KiB
JavaScript
76 lines
2 KiB
JavaScript
/**
|
|
* @provides javelin-behavior-maniphest-transaction-preview
|
|
* @requires javelin-behavior
|
|
* javelin-dom
|
|
* javelin-util
|
|
* javelin-json
|
|
* javelin-stratcom
|
|
* phabricator-shaped-request
|
|
*/
|
|
|
|
JX.behavior('maniphest-transaction-preview', function(config) {
|
|
|
|
var comments = JX.$(config.comments);
|
|
var action = JX.$(config.action);
|
|
|
|
var callback = function(r) {
|
|
var panel = JX.$(config.preview);
|
|
var data = getdata();
|
|
var hide = true;
|
|
for (var field in data) {
|
|
if (field == 'action') {
|
|
continue;
|
|
}
|
|
if (data[field]) {
|
|
hide = false;
|
|
}
|
|
}
|
|
if (hide) {
|
|
JX.DOM.hide(panel);
|
|
} else {
|
|
JX.DOM.setContent(panel, JX.$H(r));
|
|
JX.DOM.show(panel);
|
|
}
|
|
};
|
|
|
|
var getdata = function() {
|
|
var selected = action.value;
|
|
|
|
var value = null;
|
|
try {
|
|
var control = JX.$(config.map[selected]);
|
|
var input = ([]
|
|
.concat(JX.DOM.scry(control, 'select'))
|
|
.concat(JX.DOM.scry(control, 'input')))[0];
|
|
if (JX.DOM.isType(input, 'input')) {
|
|
// Avoid reading 'value'(s) out of the tokenizer free text input.
|
|
if (input.type != 'hidden') {
|
|
value = null;
|
|
// Get the tokenizer and all that delicious data
|
|
} else {
|
|
var tokenizer_dom = JX.$(config.tokenizers[selected].id);
|
|
var tokenizer = JX.Stratcom.getData(tokenizer_dom).tokenizer;
|
|
value = JX.JSON.stringify(JX.keys(tokenizer.getTokens()));
|
|
}
|
|
} else {
|
|
value = input.value;
|
|
}
|
|
} catch (_ignored_) {
|
|
// Ignored.
|
|
}
|
|
|
|
return {
|
|
comments : comments.value,
|
|
action : selected,
|
|
value : value || ''
|
|
};
|
|
};
|
|
|
|
var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata);
|
|
var trigger = JX.bind(request, request.trigger);
|
|
|
|
JX.DOM.listen(comments, 'keydown', null, trigger);
|
|
JX.DOM.listen(action, 'change', null, trigger);
|
|
|
|
request.start();
|
|
});
|