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

[erp5_web_renderjs_ui] Factorise code

parent f8b47669
......@@ -76,6 +76,33 @@
///////////////////////////////
// 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) {
var i,
search_query,
......@@ -173,6 +200,8 @@
}, true);
});
}
window.getListboxClipboardActionList = getListboxClipboardActionList;
window.triggerListboxClipboardAction = triggerListboxClipboardAction;
}(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.48315.28627.55534</string> </value>
<value> <string>974.48316.46514.38946</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1554109242.58</float>
<float>1554110522.02</float>
<string>UTC</string>
</tuple>
</state>
......
/*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 */
(function (window, rJS, RSVP, calculatePageTitle, SimpleQuery, ComplexQuery,
Query, QueryFactory, ensureArray, triggerListboxClipboardAction) {
Query, QueryFactory, ensureArray, triggerListboxClipboardAction,
getListboxClipboardActionList) {
"use strict";
function updateSearchQueryFromSelection(extended_search, checked_uid_list,
......@@ -338,34 +340,11 @@
})
// Handle listbox custom button
.allowPublicAcquisition("getListboxClipboardActionList", 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;
})
.allowPublicAcquisition("triggerListboxClipboardAction", triggerListboxClipboardAction);
.allowPublicAcquisition("getListboxClipboardActionList",
getListboxClipboardActionList)
.allowPublicAcquisition("triggerListboxClipboardAction",
triggerListboxClipboardAction);
}(window, rJS, RSVP, calculatePageTitle, SimpleQuery, ComplexQuery, Query,
QueryFactory, ensureArray, triggerListboxClipboardAction));
\ No newline at end of file
QueryFactory, ensureArray, triggerListboxClipboardAction,
getListboxClipboardActionList));
\ No newline at end of file
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.48318.49230.61986</string> </value>
<value> <string>974.48338.56343.35345</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1554109391.26</float>
<float>1554110585.33</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, calculatePageTitle */
/*global window, rJS, RSVP, calculatePageTitle, triggerListboxClipboardAction,
getListboxClipboardActionList */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, calculatePageTitle) {
(function (window, rJS, RSVP, calculatePageTitle, triggerListboxClipboardAction,
getListboxClipboardActionList) {
"use strict";
rJS(window)
......@@ -183,33 +185,10 @@
}, false, true)
// Handle listbox custom button
.allowPublicAcquisition("getListboxClipboardActionList", 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;
})
.allowPublicAcquisition("triggerListboxClipboardAction", triggerListboxClipboardAction);
.allowPublicAcquisition("getListboxClipboardActionList",
getListboxClipboardActionList)
.allowPublicAcquisition("triggerListboxClipboardAction",
triggerListboxClipboardAction);
}(window, rJS, RSVP, calculatePageTitle));
\ No newline at end of file
}(window, rJS, RSVP, calculatePageTitle, triggerListboxClipboardAction,
getListboxClipboardActionList));
\ No newline at end of file
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.44332.43937.58060</string> </value>
<value> <string>974.48338.34236.46097</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1553870231.56</float>
<float>1554110628.46</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