changeset 53ff6c9d8393 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=53ff6c9d8393
description:
Click on boolean column of editable trees select the lines and toggle
the state
issue9285
review303481002
diffstat:
CHANGELOG | 2 ++
src/view/tree.js | 33 ++++++++++++++++++++++++++++++++-
2 files changed, 34 insertions(+), 1 deletions(-)
diffs (72 lines):
diff -r c0e1f841cebc -r 53ff6c9d8393 CHANGELOG
--- a/CHANGELOG Sun May 10 11:34:47 2020 +0200
+++ b/CHANGELOG Mon May 18 13:53:59 2020 +0200
@@ -1,3 +1,5 @@
+* Allow changes to editable tree checkboxes without first selecting the line
+
Version 5.6.0 - 2020-05-04
* Bug fixes (see mercurial logs for details)
* Support link button on form
diff -r c0e1f841cebc -r 53ff6c9d8393 src/view/tree.js
--- a/src/view/tree.js Sun May 10 11:34:47 2020 +0200
+++ b/src/view/tree.js Mon May 18 13:53:59 2020 +0200
@@ -29,6 +29,7 @@
if (!this.view.widgets[name]) {
this.view.widgets[name] = [];
}
+ column.tree = this.view;
this.view.widgets[name].push(column);
var prefixes = [], suffixes = [];
@@ -1969,6 +1970,7 @@
this.type = 'field';
this.model = model;
this.field = model.fields[attributes.name];
+ this.tree = null;
this.attributes = attributes;
this.prefixes = [];
this.suffixes = [];
@@ -2043,13 +2045,42 @@
get_cell: function() {
return jQuery('<input/>', {
'type': 'checkbox',
- 'disabled': true,
'class': this.class_,
'tabindex': 0
});
},
update_text: function(cell, record) {
cell.prop('checked', this.field.get(record));
+ },
+ render: function(record, cell) {
+ var new_cell = !cell;
+ cell = Sao.View.Tree.BooleanColumn._super.render.call(
+ this, record, cell);
+ var disabled = true;
+ if (this.tree.editable) {
+ if (new_cell) {
+ cell.on('click', null,
+ {record: record, cell:cell},
+ this.clicked.bind(this));
+ }
+ var state_attrs = this.field.get_state_attrs(record);
+ disabled = this.attributes.readonly || state_attrs.readonly;
+ }
+ cell.prop('disabled', disabled);
+ return cell;
+ },
+ clicked: function(evt) {
+ var record = evt.data.record;
+ var cell = evt.data.cell;
+ var current_record = this.tree.screen.current_record;
+ var fields = this.tree.get_fields();
+ if (!current_record || current_record.validate(
+ fields, false, false, true)) {
+ var value = cell.prop('checked');
+ this.field.set_client(record, value);
+ } else {
+ evt.preventDefault();
+ }
}
});