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