diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 99ae452ffa2..99aec4b3880 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -340,22 +340,6 @@ openerp.web.SearchView = openerp.web.Widget.extend(/** @lends openerp.web.Search self.vs.searchQuery.reset(_(arguments).compact()); self.ready.resolve(); }); - - // for extended search view - var ext = new openerp.web.search.ExtendedSearch(this, this.model); - lines.push([ext]); - this.extended_search = ext; - - // start() all the widgets - var widget_starts = _(lines).chain().flatten().map(function (widget) { - return widget.start(); - }).value(); - - $.when.apply(null, widget_starts).then(function () { - self.ready.resolve(); - }); - - this.reload_managed_filters(); }, reload_managed_filters: function() { var self = this; @@ -513,8 +497,7 @@ openerp.web.SearchView = openerp.web.Widget.extend(/** @lends openerp.web.Search * * @param e jQuery event object coming from the "Search" button */ - do_search: function (e) { - var self = this; + do_search: function () { var domains = [], contexts = [], groupbys = [], errors = []; this.vs.searchQuery.each(function (facet) { @@ -575,51 +558,6 @@ openerp.web.SearchView = openerp.web.Widget.extend(/** @lends openerp.web.Search */ on_invalid: function (errors) { this.do_notify(_t("Invalid Search"), _t("triggered from search view")); - }, - /** - * @param {Boolean} [reload_view=true] - */ - do_clear: function (reload_view) { - this.$element.find('.filter_label, .filter_icon').removeClass('enabled'); - this.enabled_filters.splice(0); - var string = $('a.searchview_group_string'); - _.each(string, function(str){ - $(str).closest('div.searchview_group').removeClass("expanded").addClass('folded'); - }); - this.$element.find('table:last').hide(); - - $('.searchview_extended_groups_list').empty(); - return $.async_when.apply( - null, _(this.inputs).invoke('clear')).pipe( - reload_view !== false ? this.on_clear : null); - }, - /** - * Triggered when the search view gets cleared - * - * @event - */ - on_clear: function () { - this.do_search(); - }, - /** - * Called by a filter propagating its state changes - * - * @param {openerp.web.search.Filter} filter a filter which got toggled - * @param {Boolean} default_enabled filter got enabled through the default values, at render time. - */ - do_toggle_filter: function (filter, default_enabled) { - if (default_enabled || filter.is_enabled()) { - this.enabled_filters.push(filter); - } else { - this.enabled_filters = _.without( - this.enabled_filters, filter); - } - - if (!default_enabled) { - // selecting a filter after initial loading automatically - // triggers refresh - this.$element.find('form').submit(); - } } }); @@ -680,43 +618,6 @@ openerp.web.search.Widget = openerp.web.OldWidget.extend( /** @lends openerp.web init: function (view) { this._super(view); this.view = view; - }, - /** - * Sets and returns a globally unique identifier for the widget. - * - * If a prefix is specified, the identifier will be appended to it. - * - * @params prefix prefix sections, empty/falsy sections will be removed - */ - make_id: function () { - this.element_id = _.uniqueId( - ['search'].concat( - _.compact(_.toArray(arguments)), - ['']).join('_')); - return this.element_id; - }, - /** - * "Starts" the widgets. Called at the end of the rendering, this allows - * widgets to hook themselves to their view sections. - * - * On widgets, if they kept a reference to a view and have an element_id, - * will fetch and set their root element on $element. - */ - start: function () { - this._super(); - if (this.view && this.element_id) { - // id is unique, and no getElementById on elements - this.$element = $(document.getElementById( - this.element_id)); - } - }, - /** - * "Stops" the widgets. Called when the view destroys itself, this - * lets the widgets clean up after themselves. - */ - destroy: function () { - delete this.view; - this._super(); } }); openerp.web.search.add_expand_listener = function($root) { @@ -733,15 +634,6 @@ openerp.web.search.Group = openerp.web.search.Widget.extend({ this.attrs = view_section.attrs; this.lines = view.make_widgets( view_section.children, fields); - this.make_id('group'); - }, - start: function () { - this._super(); - openerp.web.search.add_expand_listener(this.$element); - var widget_starts = _(this.lines).chain().flatten() - .map(function (widget) { return widget.start(); }) - .value(); - return $.when.apply(null, widget_starts); } }); @@ -804,11 +696,7 @@ openerp.web.search.Input = openerp.web.search.Widget.extend( /** @lends openerp. } } this.attrs = attrs; - }, - /** - * Specific clearing operations, if any - */ - clear: function () {} + } }); openerp.web.search.FilterGroup = openerp.web.search.Input.extend(/** @lends openerp.web.search.FilterGroup# */{ template: 'SearchView.filters', @@ -825,7 +713,6 @@ openerp.web.search.FilterGroup = openerp.web.search.Input.extend(/** @lends open init: function (filters, view) { this._super(view); this.filters = filters; - this.make_id('filters'); }, facet_for_defaults: function (defaults) { var fs = _(this.filters).filter(function (f) { @@ -930,7 +817,6 @@ openerp.web.search.Field = openerp.web.search.Input.extend( /** @lends openerp.w return new openerp.web.search.Filter( filter_node, view); })), view); - this.make_id('input', field.type, this.attrs.name); }, facet_for: function (value) { return $.when(new VS.model.SearchFacet({ @@ -941,10 +827,6 @@ openerp.web.search.Field = openerp.web.search.Input.extend( /** @lends openerp.w app: this.view.vs })); }, - start: function () { - this._super(); - this.filters.start(); - }, get_value: function (facet) { return facet.value(); }, @@ -1119,22 +1001,6 @@ openerp.web.search.SelectionField = openerp.web.search.Field.extend(/** @lends o }, get_value: function (facet) { return facet.get('json'); - }, - clear: function () { - var self = this, d = $.Deferred(), selection = this.attrs.selection; - for(var index=0; index actual auto-completed id if (facet.get('json')) { diff --git a/doc/search-view.rst b/doc/search-view.rst index a5780a22859..aeef238ff75 100644 --- a/doc/search-view.rst +++ b/doc/search-view.rst @@ -229,14 +229,26 @@ As a result, while the external API used to interact with the search view does not change many internal details — including the interaction between the search view and its widgets — were significantly altered: +Internal operations ++++++++++++++++++++ + +* :js:func:`openerp.web.SearchView.do_clear` has been removed +* :js:func:`openerp.web.SearchView.do_toggle_filter` has been removed + Widgets API +++++++++++ * :js:func:`openerp.web.search.Widget.render` has been removed +* :js:func:`openerp.web.search.Widget.make_id` has been removed + * Search field objects are not openerp widgets anymore, their ``start`` is not generally called +* :js:func:`~openerp.web.search.Input.clear` has been removed since + clearing the search view now simply consists of removing all search + facets from VisualSearch + * :js:func:`~openerp.web.search.Input.get_domain` and :js:func:`~openerp.web.search.Input.get_context` now take a :js:class:`~VS.model.SearchFacet` as parameter, from which it's