Commit dbae3b09 authored by Tomáš Peterka's avatar Tomáš Peterka Committed by Romain Courteaud

[renderjs_ui] Use clojures instead of arrow functions because they are not fully supported

parent 4c403ec8
...@@ -118,6 +118,13 @@ ...@@ -118,6 +118,13 @@
)); ));
} }
/** Clojure to ease finding in lists of lists by the first item **/
function hasSameFirstItem(a) {
return function (b) {
return a[0] === b[0];
};
}
rJS(window) rJS(window)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// ready // ready
...@@ -268,7 +275,6 @@ ...@@ -268,7 +275,6 @@
.onStateChange(function (modification_dict) { .onStateChange(function (modification_dict) {
var gadget = this, var gadget = this,
sort_key = gadget.state.key + "_sort_list:json", sort_key = gadget.state.key + "_sort_list:json",
class_value,
sort_list, sort_list,
column_list, column_list,
sort_column_list, sort_column_list,
...@@ -327,12 +333,8 @@ ...@@ -327,12 +333,8 @@
// construct array of links for sortable columns, undefined otherwise // construct array of links for sortable columns, undefined otherwise
return RSVP.all(column_list.map(function (column) { return RSVP.all(column_list.map(function (column) {
function is_current_column(item) { var is_sortable = sort_column_list.find(hasSameFirstItem(column)) !== undefined,
return item[0] === column[0]; current_sort = sort_list.find(hasSameFirstItem(column)),
}
var is_sortable = sort_column_list.find(is_current_column) !== undefined,
current_sort = sort_list.find(is_current_column),
options = {}; options = {};
if (is_sortable) { if (is_sortable) {
...@@ -350,28 +352,26 @@ ...@@ -350,28 +352,26 @@
// so we can construct array of header objects to be rendered in the header template // so we can construct array of header objects to be rendered in the header template
var hide_button_text, var hide_button_text,
hide_button_name, hide_button_name,
current_sort, head_value_list = column_list.map(function (column, index) {
head_value_list = []; var current_sort = sort_list.find(hasSameFirstItem(column)),
for (i = 0; i < column_list.length; i += 1) { class_value = "";
current_sort = sort_list.find((item) => item[0] === column_list[i][0]);
class_value = undefined; if (current_sort !== undefined) {
if (current_sort[1] === 'ascending') {
if (current_sort !== undefined) { class_value = "ui-icon ui-icon-arrow-up";
if (current_sort[1] === 'ascending') { }
class_value = "ui-icon ui-icon-arrow-up"; if (current_sort[1] === 'descending') {
} class_value = "ui-icon ui-icon-arrow-down";
if (current_sort[1] === 'descending') { }
class_value = "ui-icon ui-icon-arrow-down";
} }
}
head_value_list.push({ return {
"data-i18n": column_list[i][1], "data-i18n": column[1],
"class_value": class_value, "class_value": class_value,
"sort_link": column_sort_link_list[i], "sort_link": column_sort_link_list[index],
"text": column_list[i][1] "text": column[1]
};
}); });
}
if (gadget.state.show_line_selector) { if (gadget.state.show_line_selector) {
hide_button_text = 'Submit'; hide_button_text = 'Submit';
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>960.56198.53416.29457</string> </value> <value> <string>960.57664.50157.3293</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>1500626843.31</float> <float>1500656708.46</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