From aaf07abb8814bc8d81741c4c2760e2ba53342e43 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 2 May 2012 16:23:32 +0200 Subject: [PATCH 1/3] [imp] small modifications to the way invisibility is handled for future improvement regarding buttons bzr revid: nicolas.vanhoren@openerp.com-20120502142332-tpu6cntjta28wpaz --- addons/web/static/src/js/view_form.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 09dd69074d8..5f76a08821b 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1118,8 +1118,6 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt // invisibility transfer var field_modifiers = JSON.parse($child.attr('modifiers') || '{}'); var invisible = field_modifiers.invisible; - field_modifiers.invisible = undefined; - $child.attr('modifiers', JSON.stringify(field_modifiers)); self.handle_common_properties($td, $("").attr("modifiers", JSON.stringify({invisible: invisible}))); $tr.append($td.append($child)); @@ -1371,17 +1369,27 @@ instance.web.form.InvisibilityChangerMixin = { instance.web.form.compute_domain(this._ic_invisible_modifier, this._ic_field_manager.fields); this.set({"invisible": result}); }); - this.set({invisible: this._ic_invisible_modifier === true}); + this.set({invisible: this._ic_invisible_modifier === true, force_invisible: false}); + var check = function() { + if (this.get("invisible") || this.get('force_invisible')) { + this.set({"effective_invisible": true}); + } else { + this.set({"effective_invisible": false}); + } + }; + this.on('change:invisible', this, check); + this.on('change:force_invisible', this, check); + _.bind(check, this)(); }, start: function() { var check_visibility = function() { - if (this.get("invisible")) { + if (this.get("effective_invisible")) { this.$element.hide(); } else { this.$element.show(); } }; - this.on("change:invisible", this, check_visibility); + this.on("change:effective_invisible", this, check_visibility); _.bind(check_visibility, this)(); }, }; From 975bb56fb6bb06f0b0f26d56ff31011d7a2ce895 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Wed, 2 May 2012 16:34:38 +0200 Subject: [PATCH 2/3] [imp] made buttons disappear in edit mode bzr revid: nicolas.vanhoren@openerp.com-20120502143438-oz8dn88982f7iyg6 --- addons/web/static/src/js/view_form.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 5f76a08821b..9b85c597962 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -13,6 +13,8 @@ instance.web.form = {}; * Properties: * - display_invalid_fields : if true, all fields where is_valid() return true should * be displayed as invalid. + * - buttons_invisible: boolean. If true, all buttons should be switched to invisible (TODO: clean + * this later, should be replaced with a better "mode" property) * Events: * - view_content_has_changed : when the values of the fields have changed. When * this event is triggered all fields should reprocess their modifiers. @@ -80,6 +82,10 @@ instance.web.FormView = instance.web.View.extend(_.extend({}, instance.web.form. this.reload_mutex = new $.Mutex(); this.rendering_engine = new instance.web.form.FormRenderingEngineReadonly(this); this.qweb = null; // A QWeb instance will be created if the view is a QWeb template + var _check_buttons = function() { + this.set({"buttons_invisible": this.get("mode") !== "view"}); + }; + this.on("change:mode", this, _check_buttons); }, destroy: function() { _.each(this.get_widgets(), function(w) { @@ -1523,6 +1529,11 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ this.view.default_focus_button = this; } this.view.on('view_content_has_changed', this, this.check_disable); + var _check_invisible = function() { + this.set({"force_invisible": this.view.get("buttons_invisible")}); + }; + this.view.on("change:buttons_invisible", this, _check_invisible); + _.bind(_check_invisible, this)(); }, start: function() { this._super.apply(this, arguments); From b1e48d1b6a20909dd816ef13d5e524bdb6d78b66 Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Thu, 10 May 2012 17:22:53 +0200 Subject: [PATCH 3/3] removed buttons invisible but keep other changes bzr revid: nicolas.vanhoren@openerp.com-20120510152253-f2er58k6b0kb5kvg --- addons/web/static/src/js/view_form.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 9b85c597962..5f76a08821b 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -13,8 +13,6 @@ instance.web.form = {}; * Properties: * - display_invalid_fields : if true, all fields where is_valid() return true should * be displayed as invalid. - * - buttons_invisible: boolean. If true, all buttons should be switched to invisible (TODO: clean - * this later, should be replaced with a better "mode" property) * Events: * - view_content_has_changed : when the values of the fields have changed. When * this event is triggered all fields should reprocess their modifiers. @@ -82,10 +80,6 @@ instance.web.FormView = instance.web.View.extend(_.extend({}, instance.web.form. this.reload_mutex = new $.Mutex(); this.rendering_engine = new instance.web.form.FormRenderingEngineReadonly(this); this.qweb = null; // A QWeb instance will be created if the view is a QWeb template - var _check_buttons = function() { - this.set({"buttons_invisible": this.get("mode") !== "view"}); - }; - this.on("change:mode", this, _check_buttons); }, destroy: function() { _.each(this.get_widgets(), function(w) { @@ -1529,11 +1523,6 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({ this.view.default_focus_button = this; } this.view.on('view_content_has_changed', this, this.check_disable); - var _check_invisible = function() { - this.set({"force_invisible": this.view.get("buttons_invisible")}); - }; - this.view.on("change:buttons_invisible", this, _check_invisible); - _.bind(_check_invisible, this)(); }, start: function() { this._super.apply(this, arguments);