Commit cc56ac36 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Disable listbox button by default

Forbid click if the event listener is not activated yet
parent 2e760fba
...@@ -193,9 +193,9 @@ ...@@ -193,9 +193,9 @@
<script id="listbox-template" type="text/x-handlebars-template"> <script id="listbox-template" type="text/x-handlebars-template">
<div class="ui-table-header ui-header ui-bar-c ui-corner-all"> <div class="ui-table-header ui-header ui-bar-c ui-corner-all">
<h1 data-i18n="{{title}}" class="ui-title ui-override-theme">{{title}}<span> <span class="listboxloader ui-icon-spinner ui-btn-icon-left"></span></span></h1> <h1 data-i18n="{{title}}" class="ui-title ui-override-theme">{{title}}<span> <span class="listboxloader ui-icon-spinner ui-btn-icon-left"></span></span></h1>
<button data-rel="hide" data-i18n="{{hide_button_text}}" name="{{hide_button_name}}" type="button" class="submit responsive ui-last-child ui-btn ui-icon-low-vision ui-btn-icon-left {{hide_class}}">{{hide_button_text}}</button> <button {{disabled}} data-rel="hide" data-i18n="{{hide_button_text}}" name="{{hide_button_name}}" type="button" class="submit responsive ui-last-child ui-btn ui-icon-low-vision ui-btn-icon-left {{hide_class}}">{{hide_button_text}}</button>
<button data-rel="configure_columns" data-i18n="Configure" name="Configure" type="button" class="submit responsive ui-last-child ui-btn ui-icon-wrench ui-btn-icon-left {{configure_class}}">Configure</button> <button {{disabled}} data-rel="configure_columns" data-i18n="Configure" name="Configure" type="button" class="submit responsive ui-last-child ui-btn ui-icon-wrench ui-btn-icon-left {{configure_class}}">Configure</button>
<button data-rel="Sort" data-i18n="Sort" name="Sort" type="button" class="submit responsive ui-last-child ui-btn ui-icon-sort-amount-desc ui-btn-icon-left {{sort_class}}">Sort</button> <button {{disabled}} data-rel="Sort" data-i18n="Sort" name="Sort" type="button" class="submit responsive ui-last-child ui-btn ui-icon-sort-amount-desc ui-btn-icon-left {{sort_class}}">Sort</button>
</div> </div>
<table class="ui-responsive ui-body-c ui-table-inset"> <table class="ui-responsive ui-body-c ui-table-inset">
<thead class="ui-bar-inherit thead"></thead> <thead class="ui-bar-inherit thead"></thead>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>967.24634.17714.15001</string> </value> <value> <string>967.44841.15161.33928</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>1526286250.56</float> <float>1526894643.05</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -129,6 +129,7 @@ ...@@ -129,6 +129,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// ready // ready
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.setState({disabled: true})
// Init local properties // Init local properties
.ready(function () { .ready(function () {
this.props = { this.props = {
...@@ -316,7 +317,11 @@ ...@@ -316,7 +317,11 @@
sort_column_list, sort_column_list,
i, i,
j, j,
result_queue = new RSVP.Queue(); result_queue = new RSVP.Queue(),
button_selector_list = ['button[name="Sort"]', 'button[name="Hide"]',
'button[name="Configure"]',
'button[name="SelectRows"]'],
button;
/* /*
if (modification_dict.hasOwnProperty('error_text') && this.state.error_text !== undefined) { if (modification_dict.hasOwnProperty('error_text') && this.state.error_text !== undefined) {
...@@ -348,7 +353,16 @@ ...@@ -348,7 +353,16 @@
}); });
} }
if (modification_dict.hasOwnProperty('disabled')) {
// Mark buttons as enabled/disabled
// so that Zelenium can explicitely wait for enabled button
for (i = 0; i < button_selector_list.length; i += 1) {
button = gadget.element.querySelector(button_selector_list[i]);
if (button !== null) {
button.disabled = gadget.state.disabled;
}
}
}
if ((modification_dict.hasOwnProperty('sort_list_json')) || if ((modification_dict.hasOwnProperty('sort_list_json')) ||
(modification_dict.hasOwnProperty('column_list_json')) || (modification_dict.hasOwnProperty('column_list_json')) ||
...@@ -426,7 +440,8 @@ ...@@ -426,7 +440,8 @@
configure_class: gadget.state.configure_class, configure_class: gadget.state.configure_class,
title: gadget.state.title, title: gadget.state.title,
hide_button_text: hide_button_text, hide_button_text: hide_button_text,
hide_button_name: hide_button_name hide_button_name: hide_button_name,
disabled: gadget.state.disabled ? 'disabled' : ''
})), })),
gadget.translateHtml(listbox_thead_template({ gadget.translateHtml(listbox_thead_template({
head_value: head_value_list, head_value: head_value_list,
...@@ -819,6 +834,12 @@ ...@@ -819,6 +834,12 @@
}, {mutex: 'changestate'}) }, {mutex: 'changestate'})
.onEvent('click', function click(evt) { .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
if (this.state.disabled) {
return;
}
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"]'),
...@@ -905,6 +926,12 @@ ...@@ -905,6 +926,12 @@
}, false, false) }, false, false)
.declareService(function enableButton() {
// click event listener is now activated
// Change the state of the gadget
return this.changeState({disabled: false});
})
.allowPublicAcquisition("notifyInvalid", function notifyInvalid() { .allowPublicAcquisition("notifyInvalid", function notifyInvalid() {
return; return;
}) })
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>967.35176.12886.11639</string> </value> <value> <string>967.44855.43962.32563</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>1526654510.2</float> <float>1526894963.13</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -624,6 +624,11 @@ ...@@ -624,6 +624,11 @@
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//button[@data-i18n='Sort']</td> <td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//button[@data-i18n='Sort']</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>waitForElementNotPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//button[@data-i18n='Sort' and @disabled]</td>
<td></td>
</tr>
<tr> <tr>
<td>click</td> <td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//button[@data-i18n='Sort']</td> <td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//button[@data-i18n='Sort']</td>
...@@ -791,6 +796,11 @@ ...@@ -791,6 +796,11 @@
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//button[@data-i18n='Configure']</td> <td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//button[@data-i18n='Configure']</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>waitForElementNotPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//button[@data-i18n='Configure' and @disabled]</td>
<td></td>
</tr>
<tr> <tr>
<td>click</td> <td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//button[@data-i18n='Configure']</td> <td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//button[@data-i18n='Configure']</td>
......
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