Commit 39dacd0f authored by Romain Courteaud's avatar Romain Courteaud

XXX [erp5_web_renderjs_ui] Listbox: new buttons, more fun

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