Commit 970fd625 authored by Romain Courteaud's avatar Romain Courteaud

XXX [erp5_web_renderjs_ui] Listbox: new buttons, more fun

parent 20fb75d6
......@@ -5,6 +5,7 @@
data-i18n=No records
data-i18n=Records
data-i18n=Select
data-i18n=Clipboard
data-i18n=Configure
data-i18n=Sort
data-i18n=sample of
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.37684.40708.23176</string> </value>
<value> <string>972.44335.31558.29354</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1545124793.17</float>
<float>1546420711.37</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -278,7 +278,9 @@
"row_list": row_list,
"show_anchor": gadget.state.show_anchor,
"column_list": column_list,
"show_line_selector": gadget.state.show_line_selector
"show_line_selector": gadget.state.show_line_selector,
"show_select_action": gadget.state.show_select_action,
"show_clipboard_action": gadget.state.show_clipboard_action
});
return new RSVP.Queue()
.push(function () {
......@@ -331,6 +333,8 @@
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("getListboxSelectActionList",
"getListboxSelectActionList")
.declareAcquiredMethod("getListboxClipboardActionList",
"getListboxClipboardActionList")
.declareAcquiredMethod("triggerListboxSelectAction",
"triggerListboxSelectAction")
......@@ -481,7 +485,9 @@
// No error message
has_error: false,
show_line_selector: false
show_line_selector: false,
show_select_action: false,
show_clipboard_action: false
});
});
return queue;
......@@ -497,6 +503,7 @@
j,
result_queue = new RSVP.Queue(),
button_selector_list = ['button[name="Sort"]', 'button[name="Hide"]',
'button[name="Clipboard"]',
'button[name="Configure"]',
'button[name="SelectRows"]'],
button;
......@@ -614,7 +621,7 @@
}
}
if (gadget.state.show_line_selector) {
if (gadget.state.show_select_action) {
select_list = gadget.getListboxSelectActionList()
.push(undefined, function (error) {
if (error instanceof rJS.AcquisitionError) {
......@@ -627,12 +634,25 @@
});
}
if (gadget.state.show_clipboard_action) {
select_list = gadget.getListboxClipboardActionList()
.push(undefined, function (error) {
if (error instanceof rJS.AcquisitionError) {
// Do not break if parent gadget does not implement it
// XXX this could be a new rJS function when doing
// declareAcquiredMethod
return [];
}
throw error;
});
}
return RSVP.all([
gadget.getUrlForList(url_for_option_list),
is_sortable_list,
gadget.getTranslationList(['Jump',
'Select', 'Configure', 'Sort',
'Cancel']),
'Cancel', 'Clipboard']),
select_list
]);
})
......@@ -713,6 +733,17 @@
button_element.textContent = translation_list[3];
div_element.appendChild(button_element);
// Add Do button
// <button {{disabled}} data-rel="hide" data-i18n="Select" name="Hide" type="button" class="ui-icon-check-square-o ui-btn-icon-left {{hide_class}}"></button>
button_element = document.createElement('button');
button_element.disabled = gadget.state.disabled;
button_element.setAttribute('data-rel', 'clipboard');
button_element.setAttribute('name', 'Clipboard');
button_element.type = 'button';
button_element.setAttribute('class', 'ui-icon-ellipsis-v ui-btn-icon-left ' + gadget.state.hide_class);
button_element.textContent = translation_list[5];
div_element.appendChild(button_element);
// Add Select button
// <button {{disabled}} data-rel="hide" data-i18n="Select" name="Hide" type="button" class="ui-icon-check-square-o ui-btn-icon-left {{hide_class}}"></button>
button_element = document.createElement('button');
......@@ -1210,6 +1241,7 @@
.onEvent('click', function click(evt) {
// For some reason, Zelenium can click even if button has the disabled
// attribute. So, it is needed for now to manually checks
console.log('onCLick', this.state.disabled);
if (this.state.disabled) {
return;
}
......@@ -1217,6 +1249,7 @@
var gadget = this,
sort_button = gadget.element.querySelector('button[name="Sort"]'),
hide_button = gadget.element.querySelector('button[name="Hide"]'),
clipboard_button = gadget.element.querySelector('button[name="Clipboard"]'),
configure_button = gadget.element.querySelector('button[name="Configure"]'),
cancel_select_button = gadget.element.querySelector('button[name="CancelSelect"]'),
url,
......@@ -1226,6 +1259,8 @@
unchecked_uid_list,
i;
console.log('onCLick', clipboard_button, evt.target);
if (evt.target === configure_button) {
evt.preventDefault();
url = "gadget_erp5_configure_editor.html";
......@@ -1247,14 +1282,26 @@
if (evt.target === hide_button) {
evt.preventDefault();
return gadget.changeState({
show_line_selector: true
show_line_selector: true,
show_select_action: true
});
}
if (evt.target === clipboard_button) {
console.log('couscous clipboard');
evt.preventDefault();
return gadget.changeState({
show_line_selector: true,
show_clipboard_action: true
});
}
if (evt.target === cancel_select_button) {
evt.preventDefault();
return gadget.changeState({
show_line_selector: false
show_line_selector: false,
show_select_action: false,
show_clipboard_action: false
});
}
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>972.27092.48077.63488</string> </value>
<value> <string>972.46954.57423.23859</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1545386943.7</float>
<float>1546422454.02</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