diff --git a/CHANGELOG b/CHANGELOG index a8958e243c..25e61daa8b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 --git a/src/view/tree.js b/src/view/tree.js index 7afb3daddc..960562ebc8 100644 --- a/src/view/tree.js +++ b/src/view/tree.js @@ -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('', { '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(); + } } });