Commit 5dbdd24a authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Factorise more

parent 56cc0aaf
/*global window, RSVP, Array, isNaN, SimpleQuery, ComplexQuery, Query */
/*jslint indent: 2, maxerr: 3, nomen: true, unparam: true */
/*jslint indent: 2, maxerr: 3, nomen: true, unparam: true, continue: true */
(function (window, RSVP, Array, isNaN, SimpleQuery, ComplexQuery, Query) {
"use strict";
......@@ -149,7 +149,7 @@
}
if (view === undefined) {
// Action was not found.
return gadget.notifySubmitted({
return gadget.notifySubmittedClipboardAction({
"message": "Action not handled."
});
}
......@@ -157,7 +157,7 @@
if (action_name === 'paste_document_list') {
// Get the list of document uid from the internal clipboard
queue = gadget.getSetting('clipboard')
queue = gadget.getSettingClipboardAction('clipboard')
.push(function (uid_list) {
checked_uid_list = uid_list || [];
});
......@@ -172,22 +172,22 @@
// Dialog listbox use catalog method, which may be different from the current select method
// and so, it is mandatory to propagate a list of uid, otherwise, the dialog may display
// an unexpected huge list of unrelated documents
return gadget.notifySubmitted({
return gadget.notifySubmittedClipboardAction({
"message": "Nothing selected."
});
}
if (action_name === 'copy_document_list') {
return gadget.setSetting('clipboard', checked_uid_list)
return gadget.setSettingClipboardAction('clipboard', checked_uid_list)
.push(function () {
return gadget.notifySubmitted({
return gadget.notifySubmittedClipboardAction({
"message": "Copied.",
"status": "success"
});
});
}
return gadget.redirect({
return gadget.redirectClipboardAction({
command: 'display_dialog_with_history',
options: {
"jio_key": gadget.state.jio_key,
......@@ -201,7 +201,21 @@
});
}
window.getListboxClipboardActionList = getListboxClipboardActionList;
function declareGadgetClassCanHandleListboxClipboardAction(gadget_klass) {
gadget_klass
.declareAcquiredMethod("setSettingClipboardAction", "setSetting")
.declareAcquiredMethod("getSettingClipboardAction", "getSetting")
.declareAcquiredMethod("redirectClipboardAction", "redirect")
.declareAcquiredMethod("notifySubmittedClipboardAction",
"notifySubmitted")
// Handle listbox custom button
.allowPublicAcquisition("getListboxClipboardActionList",
getListboxClipboardActionList)
.allowPublicAcquisition("triggerListboxClipboardAction",
triggerListboxClipboardAction);
}
window.triggerListboxClipboardAction = triggerListboxClipboardAction;
window.declareGadgetClassCanHandleListboxClipboardAction =
declareGadgetClassCanHandleListboxClipboardAction;
}(window, RSVP, Array, isNaN, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.48316.46514.38946</string> </value>
<value> <string>974.48373.9942.49254</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1554110522.02</float>
<float>1554112759.88</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, calculatePageTitle, SimpleQuery, ComplexQuery,
Query, QueryFactory, ensureArray, triggerListboxClipboardAction,
getListboxClipboardActionList*/
declareGadgetClassCanHandleListboxClipboardAction*/
/*jslint nomen: true, indent: 2, maxerr: 3, continue: true */
(function (window, rJS, RSVP, calculatePageTitle, SimpleQuery, ComplexQuery,
Query, QueryFactory, ensureArray, triggerListboxClipboardAction,
getListboxClipboardActionList) {
declareGadgetClassCanHandleListboxClipboardAction) {
"use strict";
function updateSearchQueryFromSelection(extended_search, checked_uid_list,
......@@ -337,14 +337,10 @@
}
throw new Error('Unsupported triggerListboxSelectAction action: ' + action);
})
});
// Handle listbox custom button
.allowPublicAcquisition("getListboxClipboardActionList",
getListboxClipboardActionList)
.allowPublicAcquisition("triggerListboxClipboardAction",
triggerListboxClipboardAction);
declareGadgetClassCanHandleListboxClipboardAction(rJS(window));
}(window, rJS, RSVP, calculatePageTitle, SimpleQuery, ComplexQuery, Query,
QueryFactory, ensureArray, triggerListboxClipboardAction,
getListboxClipboardActionList));
\ No newline at end of file
declareGadgetClassCanHandleListboxClipboardAction));
\ No newline at end of file
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.48338.56343.35345</string> </value>
<value> <string>974.48375.35929.5939</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1554110585.33</float>
<float>1554112783.5</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, calculatePageTitle, triggerListboxClipboardAction,
getListboxClipboardActionList */
/*global window, rJS, RSVP, calculatePageTitle,
declareGadgetClassCanHandleListboxClipboardAction */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, calculatePageTitle, triggerListboxClipboardAction,
getListboxClipboardActionList) {
(function (window, rJS, RSVP, calculatePageTitle,
declareGadgetClassCanHandleListboxClipboardAction) {
"use strict";
rJS(window)
......@@ -182,13 +182,9 @@
}
}); // page form handles failures well enough
}, false, true)
}, false, true);
// Handle listbox custom button
.allowPublicAcquisition("getListboxClipboardActionList",
getListboxClipboardActionList)
.allowPublicAcquisition("triggerListboxClipboardAction",
triggerListboxClipboardAction);
declareGadgetClassCanHandleListboxClipboardAction(rJS(window));
}(window, rJS, RSVP, calculatePageTitle, triggerListboxClipboardAction,
getListboxClipboardActionList));
\ No newline at end of file
}(window, rJS, RSVP, calculatePageTitle,
declareGadgetClassCanHandleListboxClipboardAction));
\ No newline at end of file
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.48338.34236.46097</string> </value>
<value> <string>974.48339.52946.33450</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1554110628.46</float>
<float>1554112591.65</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, calculatePageTitle, isEmpty */
/*global window, rJS, RSVP, calculatePageTitle, isEmpty,
declareGadgetClassCanHandleListboxClipboardAction */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, calculatePageTitle, isEmpty) {
(function (window, rJS, RSVP, calculatePageTitle, isEmpty,
declareGadgetClassCanHandleListboxClipboardAction) {
"use strict";
/** Return true if `field` resembles non-empty and non-editable field. */
......@@ -161,4 +163,7 @@
});
});
}(window, rJS, RSVP, calculatePageTitle, isEmpty));
\ No newline at end of file
declareGadgetClassCanHandleListboxClipboardAction(rJS(window));
}(window, rJS, RSVP, calculatePageTitle, isEmpty,
declareGadgetClassCanHandleListboxClipboardAction));
\ No newline at end of file
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.58906.44395.12356</string> </value>
<value> <string>974.48369.21631.14967</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1547195629.34</float>
<float>1554112407.89</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment