Commit 13787bdb authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Move delete button on the listbox itself

parent 44334150
......@@ -337,6 +337,8 @@
"getListboxClipboardActionList")
.declareAcquiredMethod("triggerListboxSelectAction",
"triggerListboxSelectAction")
.declareAcquiredMethod("triggerListboxClipboardAction",
"triggerListboxClipboardAction")
//////////////////////////////////////////////
// initialize the gadget content
......@@ -685,7 +687,7 @@
h1_element.appendChild(span_element);
div_element.appendChild(h1_element);
if (gadget.state.show_line_selector) {
if (gadget.state.show_select_action) {
for (k = 0; k < select_option_list.length; k += 1) {
// Add include button
// <button data-rel="hide" data-i18n="Include" name="IncludeRows" type="button" class="ui-icon-eye ui-btn-icon-left {{hide_class}}"></button>
......@@ -709,6 +711,30 @@
button_element.textContent = translation_list[4];
div_element.appendChild(button_element);
} else if (gadget.state.show_clipboard_action) {
for (k = 0; k < select_option_list.length; k += 1) {
// Add include button
// <button data-rel="hide" data-i18n="Include" name="IncludeRows" type="button" class="ui-icon-eye ui-btn-icon-left {{hide_class}}"></button>
button_element = document.createElement('button');
button_element.setAttribute('data-rel', 'clipboard');
button_element.setAttribute('data-clipboard-action', select_option_list[k].action);
button_element.setAttribute('name', 'ClipboardAction');
button_element.type = 'button';
button_element.setAttribute('class', 'ui-icon-' + select_option_list[k].icon + ' ui-btn-icon-left ' + gadget.state.hide_class);
button_element.textContent = select_option_list[k].title;
div_element.appendChild(button_element);
}
// Add cancel button
// <button data-rel="cancel" data-i18n="Cancel" name="ExcludeRows" type="button" class="ui-icon-times ui-btn-icon-left {{hide_class}}"></button>
button_element = document.createElement('button');
button_element.setAttribute('data-rel', 'hide');
button_element.setAttribute('name', 'CancelSelect');
button_element.type = 'button';
button_element.setAttribute('class', 'ui-icon-times ui-btn-icon-left ' + gadget.state.hide_class);
button_element.textContent = translation_list[4];
div_element.appendChild(button_element);
} else {
// Add Configure button
......@@ -1306,7 +1332,7 @@
}
if ((evt.target.type === 'button') &&
(evt.target.name === 'SelectAction')) {
((evt.target.name === 'SelectAction') || (evt.target.name === 'ClipboardAction'))) {
evt.preventDefault();
checked_uid_list = [];
......@@ -1322,7 +1348,10 @@
unchecked_uid_list.push(all_hide_element_list[i].getAttribute("data-uid"));
}
}
return gadget.triggerListboxSelectAction(evt.target.getAttribute('data-select-action'), checked_uid_list, unchecked_uid_list);
if (evt.target.name === 'SelectAction') {
return gadget.triggerListboxSelectAction(evt.target.getAttribute('data-select-action'), checked_uid_list, unchecked_uid_list);
}
return gadget.triggerListboxClipboardAction(evt.target.getAttribute('data-clipboard-action'), checked_uid_list, unchecked_uid_list);
}
}, false, false)
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.46954.57423.23859</string> </value>
<value> <string>972.46980.18805.19558</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1546422454.02</float>
<float>1546423960.78</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -4,6 +4,7 @@
<!--
data-i18n=Include
data-i18n=Exclude
data-i18n=Delete
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.25327.46098.50073</string> </value>
<value> <string>972.29743.559.65006</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1545389700.46</float>
<float>1546423008.44</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, calculatePageTitle, SimpleQuery, ComplexQuery,
Query, QueryFactory */
Query, QueryFactory, ensureArray */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, calculatePageTitle, SimpleQuery, ComplexQuery,
Query, QueryFactory) {
Query, QueryFactory, ensureArray) {
"use strict";
rJS(window)
......@@ -281,7 +281,34 @@
}
throw new Error('Unsupported triggerListboxSelectAction action: ' + action);
})
// Handle listbox custom button
.allowPublicAcquisition("getListboxClipboardActionList", function getListboxClipboardActionList() {
var delete_list = ensureArray(this.state.erp5_document._links.action_object_delete_action);
if (!delete_list.length) {
return [];
}
return this.getTranslationList(['Delete'])
.push(function (result_list) {
return [{
title: result_list[0],
icon: 'trash-o',
action: 'delete'
}];
});
})
.allowPublicAcquisition("triggerListboxClipboardAction", function triggerListboxClipboardAction(argument_list) {
var delete_list = ensureArray(this.state.erp5_document._links.action_object_delete_action);
return this.redirect({
command: 'change',
options: {
"view": delete_list[0].href,
"page": undefined
}
});
});
}(window, rJS, RSVP, calculatePageTitle, SimpleQuery, ComplexQuery, Query,
QueryFactory));
\ No newline at end of file
QueryFactory, ensureArray));
\ No newline at end of file
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.27145.17258.43178</string> </value>
<value> <string>972.47042.3653.24524</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1545233919.1</float>
<float>1546427695.43</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