Commit a61a99ec authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Factorise more

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