changeset 06fc60dbe282 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=06fc60dbe282
description:
Keep column arrow up to date
When an order is set on a One2Many widget and the user reload the form,
the
selected order is lost and so the client should no more display those
arrow.
For that we update the arrows on each display using the screen order.
And we
unset the screen order when the group change as we do not know the
order of
this group.
issue7817
review70481002
diffstat:
src/screen.js | 1 +
src/view/tree.js | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
diffs (58 lines):
diff -r 9a6f271ea0a2 -r 06fc60dbe282 src/screen.js
--- a/src/screen.js Wed Jan 02 18:53:45 2019 +0100
+++ b/src/screen.js Wed Jan 02 18:56:34 2019 +0100
@@ -1032,6 +1032,7 @@
}
group.screens.push(this);
this.tree_states_done = [];
+ this.order = null;
this.group = group;
this.model = group.model;
if (group && group.length) {
diff -r 9a6f271ea0a2 -r 06fc60dbe282 src/view/tree.js
--- a/src/view/tree.js Wed Jan 02 18:53:45 2019 +0100
+++ b/src/view/tree.js Wed Jan 02 18:56:34 2019 +0100
@@ -307,6 +307,35 @@
this.screen.search_filter(search_string);
}
},
+ update_arrow: function() {
+ var order = this.screen.order,
+ name = null,
+ direction = null,
+ icon = '';
+ if (order && (order.length == 1)) {
+ name = order[0][0];
+ direction = order[0][1];
+ icon = {
+ 'ASC': 'tryton-arrow-down',
+ 'DESC': 'tryton-arrow-up',
+ }[direction];
+ }
+ this.columns.forEach(function(col) {
+ var arrow = col.arrow;
+ if (arrow) {
+ if (col.attributes.name != name) {
+ arrow.data('order', '');
+ arrow.attr('src', '');
+ } else {
+ arrow.data('order', direction);
+ Sao.common.ICONFACTORY.get_icon_url(icon)
+ .then(function(url) {
+ arrow.attr('src', url);
+ });
+ }
+ }
+ });
+ },
get_buttons: function() {
var buttons = [];
this.columns.forEach(function(column) {
@@ -454,6 +483,7 @@
this.table.removeClass('responsive-header');
}
+ this.update_arrow();
return this.redraw(selected, expanded).done(
Sao.common.debounce(this.update_sum.bind(this), 250));
},