diff options
| author | Xavier Morel <xmo@openerp.com> | 2013-02-13 10:01:08 +0100 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2013-02-13 10:01:08 +0100 |
| commit | dfb7493034f2b102d647967654f5c99893450e2b (patch) | |
| tree | 7deca71ca48e43052ef5e618a01d83addf5bfeee /addons/web/static/src | |
| parent | f690a9310c6b78848a7caf95e87abfdce478baba (diff) | |
[FIX] add support for invisibility to fields (don't complete an invisible field)
bzr revid: xmo@openerp.com-20130213090108-h38emnwscgb5v1pu
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/search.js | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 8391f7a8ca5..8422f4e55fe 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -499,6 +499,7 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea */ complete_global_search: function (req, resp) { $.when.apply(null, _(this.inputs).chain() + .filter(function (input) { return input.visible(); }) .invoke('complete', req.term) .value()).then(function () { resp(_(_(arguments).compact()).flatten(true)); @@ -903,8 +904,8 @@ instance.web.search.Input = instance.web.search.Widget.extend( /** @lends instan */ init: function (view) { this._super(view); + this.load_attrs({}); this.view.inputs.push(this); - this.style = undefined; }, /** * Fetch auto-completion values for the widget. @@ -952,15 +953,19 @@ instance.web.search.Input = instance.web.search.Widget.extend( /** @lends instan "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;' - } - } + attrs.modifiers = attrs.modifiers ? JSON.parse(attrs.modifiers) : {}; this.attrs = attrs; - } + }, + /** + * Returns whether the input is "visible". The default behavior is to + * query the ``modifiers.invisible`` flag on the input's description or + * view node. + * + * @returns {Boolean} + */ + visible: function () { + return !this.attrs.modifiers.invisible; + }, }); instance.web.search.FilterGroup = instance.web.search.Input.extend(/** @lends instance.web.search.FilterGroup# */{ template: 'SearchView.filters', |
