changeset 5dce4c85f6b8 in sao:5.2
details: https://hg.tryton.org/sao?cmd=changeset;node=5dce4c85f6b8
description:
Show dynamic readonly widget in editable tree
We must render such widget to be able to display them when they are no
more
readonly. And we must ensure they are loaded and the states is computed
when
displayed.
issue8626
review280031004
diffstat:
src/view/tree.js | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diffs (50 lines):
diff -r 90d501d3e9ed -r 5dce4c85f6b8 src/view/tree.js
--- a/src/view/tree.js Sun Aug 25 13:01:53 2019 +0200
+++ b/src/view/tree.js Sat Sep 07 23:27:37 2019 +0200
@@ -1260,15 +1260,24 @@
Sao.View.Tree.RowEditable._super.redraw.call(this, selected,
expanded);
+ var display_callback = function(widget) {
+ var record = this.record;
+ return function() {
+ var field = record.model.fields[widget.field_name];
+ field.set_state(record);
+ widget.display(record, field);
+ };
+ }.bind(this);
// The autocompletion widget do not call display thus we have to
// call it when redrawing the row
for (i = 0; i < this.tree.columns.length; i++) {
+ var column = this.tree.columns[i];
td = this._get_column_td(i);
tr = td.find('tr');
widget =
jQuery(tr.children('.widget-editable')).data('widget');
if (widget) {
- field = this.record.model.fields[widget.field_name];
- widget.display(this.record, field);
+ this.record.load(column.attributes.name).done(
+ display_callback(widget));
}
}
},
@@ -1332,18 +1341,9 @@
if (!col.field) {
continue;
}
- var state_attrs = col.field.get_state_attrs(this.record);
- var readonly = col.attributes.readonly;
- if (readonly === undefined) {
- readonly = state_attrs.readonly;
- if (readonly === undefined) {
- readonly = false;
- }
- }
-
var EditableBuilder = Sao.View.EditableTree.WIDGETS[
col.attributes.widget];
- if (!readonly && EditableBuilder) {
+ if (!col.attributes.readonly && EditableBuilder) {
var widget = new EditableBuilder(
this.tree, col.attributes);
widget.el.on('keydown', this.key_press.bind(this));