Commit 56cc0aaf authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Factorise code

parent f8b47669
...@@ -76,6 +76,33 @@ ...@@ -76,6 +76,33 @@
/////////////////////////////// ///////////////////////////////
// Handle listbox action list // Handle listbox action list
/////////////////////////////// ///////////////////////////////
function getListboxClipboardActionList() {
var action_list = ensureArray(this.state.erp5_document._links.action_object_list_action || []),
i,
result_list = [],
icon;
result_list.push({
title: 'Copy',
icon: 'copy',
action: 'copy_document_list'
});
for (i = 0; i < action_list.length; i += 1) {
if (action_list[i].name === 'delete_document_list') {
icon = 'trash-o';
} else if (action_list[i].name === 'paste_document_list') {
icon = 'paste';
} else {
continue;
}
result_list.push({
title: action_list[i].title,
icon: icon,
action: action_list[i].name
});
}
return result_list;
}
function createSearchQuery(checked_uid_list, key) { function createSearchQuery(checked_uid_list, key) {
var i, var i,
search_query, search_query,
...@@ -173,6 +200,8 @@ ...@@ -173,6 +200,8 @@
}, true); }, true);
}); });
} }
window.getListboxClipboardActionList = getListboxClipboardActionList;
window.triggerListboxClipboardAction = triggerListboxClipboardAction; window.triggerListboxClipboardAction = triggerListboxClipboardAction;
}(window, RSVP, Array, isNaN, SimpleQuery, ComplexQuery, Query)); }(window, RSVP, Array, isNaN, SimpleQuery, ComplexQuery, Query));
\ 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.48315.28627.55534</string> </value> <value> <string>974.48316.46514.38946</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>1554109242.58</float> <float>1554110522.02</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*/
/*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) {
"use strict"; "use strict";
function updateSearchQueryFromSelection(extended_search, checked_uid_list, function updateSearchQueryFromSelection(extended_search, checked_uid_list,
...@@ -338,34 +340,11 @@ ...@@ -338,34 +340,11 @@
}) })
// Handle listbox custom button // Handle listbox custom button
.allowPublicAcquisition("getListboxClipboardActionList", function getListboxClipboardActionList() { .allowPublicAcquisition("getListboxClipboardActionList",
var action_list = ensureArray(this.state.erp5_document._links.action_object_list_action || []), getListboxClipboardActionList)
i, .allowPublicAcquisition("triggerListboxClipboardAction",
result_list = [], triggerListboxClipboardAction);
icon;
result_list.push({
title: 'Copy',
icon: 'copy',
action: 'copy_document_list'
});
for (i = 0; i < action_list.length; i += 1) {
if (action_list[i].name === 'delete_document_list') {
icon = 'trash-o';
} else if (action_list[i].name === 'paste_document_list') {
icon = 'paste';
} else {
continue;
}
result_list.push({
title: action_list[i].title,
icon: icon,
action: action_list[i].name
});
}
return result_list;
})
.allowPublicAcquisition("triggerListboxClipboardAction", triggerListboxClipboardAction);
}(window, rJS, RSVP, calculatePageTitle, SimpleQuery, ComplexQuery, Query, }(window, rJS, RSVP, calculatePageTitle, SimpleQuery, ComplexQuery, Query,
QueryFactory, ensureArray, triggerListboxClipboardAction)); QueryFactory, ensureArray, triggerListboxClipboardAction,
\ No newline at end of file getListboxClipboardActionList));
\ 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.48318.49230.61986</string> </value> <value> <string>974.48338.56343.35345</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>1554109391.26</float> <float>1554110585.33</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP, calculatePageTitle */ /*global window, rJS, RSVP, calculatePageTitle, triggerListboxClipboardAction,
getListboxClipboardActionList */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, calculatePageTitle) { (function (window, rJS, RSVP, calculatePageTitle, triggerListboxClipboardAction,
getListboxClipboardActionList) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -183,33 +185,10 @@ ...@@ -183,33 +185,10 @@
}, false, true) }, false, true)
// Handle listbox custom button // Handle listbox custom button
.allowPublicAcquisition("getListboxClipboardActionList", function getListboxClipboardActionList() { .allowPublicAcquisition("getListboxClipboardActionList",
var action_list = ensureArray(this.state.erp5_document._links.action_object_list_action || []), getListboxClipboardActionList)
i, .allowPublicAcquisition("triggerListboxClipboardAction",
result_list = [], triggerListboxClipboardAction);
icon;
result_list.push({
title: 'Copy',
icon: 'copy',
action: 'copy_document_list'
});
for (i = 0; i < action_list.length; i += 1) {
if (action_list[i].name === 'delete_document_list') {
icon = 'trash-o';
} else if (action_list[i].name === 'paste_document_list') {
icon = 'paste';
} else {
continue;
}
result_list.push({
title: action_list[i].title,
icon: icon,
action: action_list[i].name
});
}
return result_list;
})
.allowPublicAcquisition("triggerListboxClipboardAction", triggerListboxClipboardAction);
}(window, rJS, RSVP, calculatePageTitle)); }(window, rJS, RSVP, calculatePageTitle, triggerListboxClipboardAction,
\ No newline at end of file getListboxClipboardActionList));
\ 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.44332.43937.58060</string> </value> <value> <string>974.48338.34236.46097</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>1553870231.56</float> <float>1554110628.46</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