Commit 1237c174 authored by Tomáš Peterka's avatar Tomáš Peterka Committed by Eteri

[renderj_ui] Sort Editor shows ONLY correct sort definitions in form of "column | order"

parent 0ea8a6c0
...@@ -27,13 +27,8 @@ ...@@ -27,13 +27,8 @@
</select> </select>
<select data-wrapper-class="ui-input-has-clear" data-iconpos="left"> <select data-wrapper-class="ui-input-has-clear" data-iconpos="left">
{{#equal operator "ascending"}} <option {{#equal operator "ascending"}}selected="selected"{{/equal}} data-i18n="ascending" value="ascending">ascending</option>
<option selected="selected" data-i18n="ascending" value="ascending">ascending</option> <option {{#equal operator "descending"}}selected="selected"{{/equal}} data-i18n="descending" value="descending">descending</option>
<option data-i18n="descending" value="descending">descending</option>
{{else}}
<option data-i18n="ascending" value="ascending">ascending</option>
<option selected="selected" data-i18n="descending" value="descending">descending</option>
{{/equal}}
</select> </select>
</div> </div>
......
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.38127.32735.11195</string> </value> <value> <string>960.64833.40099.37870</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>1480342874.92</float> <float>1501087193.61</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -43,6 +43,12 @@ ...@@ -43,6 +43,12 @@
})); }));
} }
/* Valid sort item is a tuple of (column-name, ordering) */
function isValidSortItem(sort_item) {
return sort_item.length === 2 &&
(sort_item[1] === 'ascending' || sort_item[1] === 'descending');
}
gadget_klass gadget_klass
////////////////////////////////////////////// //////////////////////////////////////////////
// acquired method // acquired method
...@@ -58,17 +64,15 @@ ...@@ -58,17 +64,15 @@
return gadget.translateHtml(sort_template()) return gadget.translateHtml(sort_template())
.push(function (translated_html) { .push(function (translated_html) {
var i,
promise_list = [];
div.innerHTML = translated_html; div.innerHTML = translated_html;
for (i = 0; i < gadget.state.sort_list.length; i += 1) { return RSVP.all(gadget.state.sort_list
if (gadget.state.sort_list[i]) { .filter(isValidSortItem)
promise_list.push(createSortItemTemplate(gadget, gadget.state.sort_list[i])); .map(function (sort_item) {
} return createSortItemTemplate(gadget, sort_item);
} })
return RSVP.all(promise_list); );
}) })
.push(function (result_list) { .push(function (result_list) {
var i, var i,
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>955.38160.33114.47854</string> </value> <value> <string>960.64839.39902.53248</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1480344058.06</float> <float>1501087184.97</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<html xmlns:tal="http://xml.zope.org/namespaces/tal" <html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"> xmlns:metal="http://xml.zope.org/namespaces/metal">
<!--
Ensure default sort is shown on visible columns and in Sort Editor
- default mal-defined sort must not appear neither as an arrow nor in Sort Editor
- correctly defined sorting (ASC and DESC) will appear in both (arrow, editor)
Frontend should not suppose default sorting
-->
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test RenderJS UI</title> <title>Test RenderJS UI</title>
...@@ -11,119 +19,117 @@ ...@@ -11,119 +19,117 @@
</thead><tbody> </thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" /> <tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<!-- make the listbox to sort by Title DESC which is not the default default now --> <!-- Clean Up -->
<tr> <tr><td>open</td>
<td>open</td> <td>${base_url}/foo_module/ListBoxZuite_reset</td><td></td></tr>
<td>${base_url}/foo_module/ListBoxZuite_reset?field_sort=title+%7C+DESC</td> <!-- ?field_sort="title | DESC" --> <tr><td>assertTextPresent</td>
<td></td> <td>Reset Successfully.</td><td></td></tr>
</tr>
<tr> <!-- Shortcut for full renderjs url -->
<td>assertTextPresent</td> <tr><td>store</td>
<td>Reset Successfully.</td> <td>${base_url}/web_site_module/renderjs_runner</td>
<td></td> <td>renderjs_url</td></tr>
</tr>
<!-- Create Foo objects with IDs 0-9 --> <!-- Create Foo objects with IDs 0-9 -->
<tr> <tr><td>open</td>
<td>open</td> <td>${base_url}/foo_module/FooModule_createObjects</td><td></td></tr>
<td>${base_url}/foo_module/FooModule_createObjects</td> <tr><td>assertTextPresent</td>
<td></td> <td>Created Successfully.</td><td></td></tr>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Created Successfully.</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" /> <tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<tr> <!-- Verify ListBox behaviour with mal-formed sort definition -->
<td>open</td> <tr><td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/foo_module</td> <td>${renderjs_url}/#/foo_module</td><td></td></tr>
<td></td> <tr><td>waitForElementPresent</td>
</tr> <td>//a[@data-i18n='ID']</td><td></td></tr>
<!-- No default sort must be shown because the definition is broken "id | id" -->
<tr> <tr><td>verifyElementPresent</td>
<td>waitForElementPresent</td> <td>//th[@class='']/a[@data-i18n='ID']</td><td></td></tr>
<td>//a[@data-i18n='Title']</td> <!-- Make sure broken definitions don't appear in sort editor -->
<td></td> <tr><td>waitForElementPresent</td>
</tr> <td>//button[@data-i18n='Sort']</td><td></td></tr>
<tr><td>click</td>
<tr> <td>//button[@data-i18n='Sort']</td><td></td></tr>
<td>verifyElementPresent</td> <tr><td>waitForElementPresent</td>
<td>//th[@class='ui-icon ui-icon-arrow-down']/a[@data-i18n='Title']</td> <td>//div[@data-gadget-url='${renderjs_url}/gadget_erp5_sort_editor.html']//button[@class="plus ui-btn-c ui-override-theme ui-btn ui-icon-plus ui-btn-icon-left ui-corner-all"]</td><td></td></tr>
<td></td> <tr><td>verifyElementNotPresent</td>
</tr> <td>//div[@data-gadget-url='${renderjs_url}/gadget_erp5_sort_editor.html']//select</td><td></td></tr>
<!-- Test whether another sorting condition does keep default sort --> <!-- Let's set up the default sort correctly: id | ASC -->
<tr><td>open</td>
<tr> <td>${base_url}/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_sort=id+%7C+ASC</td><td></td></tr>
<td>waitForElementPresent</td> <tr><td>assertTextPresent</td>
<td>//button[@data-i18n='Sort']</td> <td>Set Successfully.</td><td></td></tr>
<td></td>
</tr> <!-- Verify ListBox behaviour with valid ASC sort configuration -->
<tr><td>open</td>
<tr> <td>${renderjs_url}//#/foo_module</td><td></td></tr>
<td>click</td> <tr><td>waitForElementPresent</td>
<td>//button[@data-i18n='Sort']</td> <td>//a[@data-i18n='ID']</td><td></td></tr>
<td></td> <!-- Default sort on ID column has to be ASCENDING -->
</tr> <tr><td>verifyElementPresent</td>
<td>//th[@class='ui-icon ui-icon-arrow-up']/a[@data-i18n='ID']</td><td></td></tr>
<tr> <!-- Verify that the default sort is visible in Sort Editor -->
<td>waitForElementPresent</td> <tr><td>waitForElementPresent</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]</td> <td>//button[@data-i18n='Sort']</td><td></td></tr>
<td></td> <tr><td>click</td>
</tr> <td>//button[@data-i18n='Sort']</td><td></td></tr>
<tr><td>waitForElementPresent</td>
<!-- make sure the default sort if visible in "sort editor" --> <td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]</td><td></td></tr>
<tr> <tr><td>verifyValue</td>
<td>verifyValue</td> <td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[1]</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[1]</td> <td>id</td></tr>
<td>title</td> <tr><td>verifyValue</td>
</tr> <td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[2]</td>
<td>ascending</td></tr>
<tr>
<td>verifyValue</td> <!-- Let's set up the default sort correctly: title | DESC -->
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[2]</td> <tr><td>open</td>
<td>descending</td> <td>${base_url}/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_sort=title+%7C+DESC</td><td></td></tr>
</tr> <tr><td>assertTextPresent</td>
<td>Set Successfully.</td><td></td></tr>
<!-- reset sort and our set up value is the only one to sort by -->
<tr> <!-- Verify ListBox behaviour with valid DESC sort configuration -->
<td>select</td> <tr><td>open</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[1]</td> <td>${renderjs_url}/#/foo_module</td><td></td></tr>
<td>index=0</td> <!-- select id --> <tr><td>waitForElementPresent</td>
</tr> <td>//a[@data-i18n='Title']</td><td></td></tr>
<!-- Default sort on Title column has to be DESCENDING -->
<tr> <tr><td>verifyElementPresent</td>
<td>click</td> <td>//th[@class='ui-icon ui-icon-arrow-down']/a[@data-i18n='Title']</td><td></td></tr>
<td>//button[@class="submit responsive ui-last-child ui-btn ui-btn-icon-left ui-icon-check"]</td> <!-- No other sort must be shown -->
<td></td> <tr><td>verifyElementPresent</td>
</tr> <td>//th[@class='']/a[@data-i18n='ID']</td><td></td></tr>
<!-- Verify that the default sort is visible in Sort Editor -->
<tr><td>waitForElementPresent</td>
<td>//button[@data-i18n='Sort']</td><td></td></tr>
<tr><td>click</td>
<td>//button[@data-i18n='Sort']</td><td></td></tr>
<tr><td>waitForElementPresent</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]</td><td></td></tr>
<tr><td>verifyValue</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[1]</td>
<td>title</td></tr>
<tr><td>verifyValue</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[2]</td>
<td>descending</td></tr>
<!-- Change sort using the Sort Editor -->
<tr><td>select</td>
<td>//div[@class='sort_item_container ui-controlgroup ui-corner_all']/div[1]//select[1]</td>
<td>index=0</td><!-- select ID --></tr>
<tr><td>click</td>
<td>//button[@class="submit responsive ui-last-child ui-btn ui-btn-icon-left ui-icon-check"]</td><td></td></tr>
<!-- Wait for the Filters to be applied --> <!-- Wait for the Filters to be applied -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<!-- Check that default sort arrow disappeared --> <!-- Verify that default sort arrow disappeared -->
<tr> <tr><td>verifyElementPresent</td>
<td>verifyElementNotPresent</td> <td>//th[@class='']/a[@data-i18n='Title']</td><td></td></tr>
<td>//th[@class='ui-icon ui-icon-arrow-up']/a[@data-i18n='Title']</td> <tr><td>verifyElementPresent</td>
<td></td> <td>//th[@class='ui-icon ui-icon-arrow-down']/a[@data-i18n='ID']</td><td></td></tr>
</tr>
<tr>
<td>verifyElementNotPresent</td>
<td>//th[@class='ui-icon ui-icon-arrow-up']/a[@data-i18n='ID']</td>
<td></td>
</tr>
<tr>
<td>verifyElementPresent</td>
<td>//th[@class='ui-icon ui-icon-arrow-down']/a[@data-i18n='ID']</td>
<td></td>
</tr>
</tbody></table> </tbody></table>
</body> </body>
......
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