diff options
| author | Xavier Morel <xmo@openerp.com> | 2011-12-16 16:11:08 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2011-12-16 16:11:08 +0100 |
| commit | 847cbbcb2c76c854ec059a50c16dd57a87a8af4f (patch) | |
| tree | 55e4a34e245549202bd63f1ff7154fc30bca326b /addons/web/static/src | |
| parent | c380b4db89e56f132576650612171f97f97c04d1 (diff) | |
[FIX] behavior of invisible search inputs: they can still be active and should be present in the view, just not visible
bzr revid: xmo@openerp.com-20111216151108-b2x0orfy40qzw050
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/search.js | 25 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 16 |
2 files changed, 23 insertions, 18 deletions
diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 5520799527d..f7825de4411 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -68,11 +68,6 @@ openerp.web.SearchView = openerp.web.Widget.extend(/** @lends openerp.web.Search rows.push(row); var filters = []; _.each(items, function (item) { - if (item.attrs.modifiers) { - var modifiers = item.attrs.modifiers = JSON.parse( - item.attrs.modifiers); - if (modifiers.invisible) { return; } - } if (filters.length && item.tag !== 'filter') { row.push( new openerp.web.search.FilterGroup( @@ -588,6 +583,7 @@ openerp.web.search.Input = openerp.web.search.Widget.extend( /** @lends openerp. init: function (view) { this._super(view); this.view.inputs.push(this); + this.style = undefined; }, get_context: function () { throw new Error( @@ -596,6 +592,16 @@ openerp.web.search.Input = openerp.web.search.Widget.extend( /** @lends openerp. get_domain: function () { throw new Error( "get_domain not implemented for widget " + this.attrs.type); + }, + load_attrs: function (attrs) { + if (attrs.modifiers) { + attrs.modifiers = JSON.parse(attrs.modifiers); + attrs.invisible = attrs.modifiers.invisible || false; + if (attrs.invisible) { + this.style = 'display: none;' + } + } + this.attrs = attrs; } }); openerp.web.search.FilterGroup = openerp.web.search.Input.extend(/** @lends openerp.web.search.FilterGroup# */{ @@ -656,7 +662,7 @@ openerp.web.search.Filter = openerp.web.search.Input.extend(/** @lends openerp.w */ init: function (node, view) { this._super(view); - this.attrs = node.attrs; + this.load_attrs(node.attrs); this.classes = [this.attrs.string ? 'filter_label' : 'filter_icon']; this.make_id('filter', this.attrs.name); }, @@ -714,14 +720,9 @@ openerp.web.search.Field = openerp.web.search.Input.extend( /** @lends openerp.w */ init: function (view_section, field, view) { this._super(view); - this.attrs = _.extend({}, field, view_section.attrs); + this.load_attrs(_.extend({}, field, view_section.attrs)); this.filters = new openerp.web.search.FilterGroup(_.compact(_.map( view_section.children, function (filter_node) { - if (filter_node.attrs.modifiers) { - var modifiers = filter_node.attrs.modifiers = JSON.parse( - filter_node.attrs.modifiers); - if (modifiers.invisible) { return; } - } if (filter_node.attrs.string && typeof console !== 'undefined' && console.debug) { console.debug("Filter-in-field with a 'string' attribute " diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index c7b32cef6d7..20b9cb9d782 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -1210,6 +1210,7 @@ t-att-id="element_id" t-att-title="attrs.help" t-att-class="classes.join(' ')" + t-att-style="style" t-att-autofocus="attrs.default_focus === '1' ? 'autofocus' : undefined"> <img t-att-src="_s + '/web/static/src/img/icons/' + (attrs.icon || 'gtk-home') + '.png'" width="16" height="16"/> <br t-if="attrs.string"/> @@ -1222,11 +1223,12 @@ <t t-name="SearchView.field"> <label t-att-class="'oe_label' + (attrs.help ? '_help' : '')" t-att-title="attrs.help" - t-att-for="element_id"> + t-att-for="element_id" + t-att-style="style"> <t t-esc="attrs.string || attrs.name"/> <span t-if="attrs.help">?</span> </label> - <div> + <div t-att-style="style"> <input type="text" size="15" t-att-name="attrs.name" t-att-autofocus="attrs.default_focus === '1' ? 'autofocus' : undefined" t-att-id="element_id" @@ -1237,11 +1239,12 @@ <t t-name="SearchView.date"> <label t-att-class="'oe_label' + (attrs.help ? '_help' : '')" t-att-title="attrs.help" - t-att-for="element_id"> + t-att-for="element_id" + t-att-style="style"> <t t-esc="attrs.string || attrs.name"/> <span t-if="attrs.help">?</span> </label> - <div> + <div t-att-style="style"> <span t-att-id="element_id"></span> <t t-if="filters.length" t-raw="filters.render(defaults)"/> </div> @@ -1249,11 +1252,12 @@ <t t-name="SearchView.field.selection"> <label t-att-title="attrs.help" t-att-class="'oe_label' + (attrs.help ? '_help' : '')" - t-att-for="element_id"> + t-att-for="element_id" + t-att-style="style"> <t t-esc="attrs.string || attrs.name"/> <span t-if="attrs.help">?</span> </label> - <div> + <div t-att-style="style"> <select t-att-name="attrs.name" t-att-id="element_id" t-att-autofocus="attrs.default_focus === '1' || undefined"> <option t-if="prepend_empty"/> |
