diff --git a/CHANGELOG b/CHANGELOG index d831c1071d..aac25afb2a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Manage active field on search widget * Add position and length on list view * Reset record to its original state when discarding the popup window * Add support of expand attribute on group tag diff --git a/src/screen.js b/src/screen.js index 1775285e9e..57460f3f49 100644 --- a/src/screen.js +++ b/src/screen.js @@ -51,6 +51,17 @@ 'class': 'glyphicon glyphicon-search' })); + this.but_active = jQuery('', { + type: 'button', + 'class': 'btn btn-default hidden-xs', + 'aria-expanded': false, + }).append(jQuery('', { + 'class': 'glyphicon glyphicon-compressed', + 'aria-hidden': true, + })); + this._set_active_tooltip(); + this.but_active.click(this.search_active.bind(this)); + this.but_bookmark = jQuery('', { type: 'button', 'class': 'btn btn-default dropdown-toggle', @@ -107,6 +118,7 @@ 'class': 'input-group-btn' }).append(but_submit) .append(this.but_star) + .append(this.but_active) .append(this.but_bookmark) .append(dropdown_bookmark)) .appendTo(jQuery('
', { @@ -294,6 +306,21 @@ search_next: function() { this.screen.search_next(this.get_text()); }, + search_active: function() { + this.but_active.toggleClass('active'); + this._set_active_tooltip(); + this.screen.search_filter(this.get_text()); + }, + _set_active_tooltip: function() { + var tooltip; + if (this.but_active.hasClass('active')) { + tooltip = Sao.i18n.gettext('Show active records'); + } else { + tooltip = Sao.i18n.gettext('Show inactive records'); + } + this.but_active.attr('aria-label', tooltip); + this.but_active.attr('title', tooltip); + }, get_tab_domain: function() { if (!this.tab) { return []; @@ -825,13 +852,16 @@ if (!jQuery.isEmptyObject(tab_domain)) { domain = ['AND', domain, tab_domain]; } - + var context = this.context(); + if (this.screen_container.but_active.hasClass('active')) { + context.active_test = false; + } var grp_prm = this.model.find(domain, this.offset, this.limit, - this.order, this.context()); + this.order, context); var count_prm = jQuery.when(this.search_count); if (!only_ids) { count_prm = this.model.execute('search_count', [domain], - this.context()); + context); } count_prm.done(function(count) { this.search_count = count; @@ -877,6 +907,13 @@ } else { domain = this.attributes.domain || []; } + if (this.screen_container.but_active.hasClass('active')) { + if (!jQuery.isEmptyObject(domain)) { + domain = [domain, ['active', '=', false]]; + } else { + domain = [['active', '=', false]]; + } + } if (this.current_view && this.current_view.view_type == 'calendar') { if (!jQuery.isEmptyObject(domain)) { @@ -1388,6 +1425,12 @@ fields = dom_fields; } + if ('active' in view_tree.fields) { + this.screen_container.but_active.show(); + } else { + this.screen_container.but_active.hide(); + } + // Add common fields [ ['id', Sao.i18n.gettext('ID'), 'integer'],