this.filter_menu = undefined;
this.groupby_menu = undefined;
- this.favorite_menu = undefined
+ this.favorite_menu = undefined;
+ this.action_id = this.options && this.options.action && this.options.action.id;
},
start: function() {
if (this.headless) {
view_loaded: function (r) {
var self = this;
this.fields_view_get = r;
+ this.view_id = this.view_id || r.view_id;
this.prepare_search_inputs();
if (this.$buttons) {
this.groupby_menu = new my.GroupByMenu(this, this.groupbys, fields_def);
this.filter_menu = new my.FilterMenu(this, this.filters, fields_def);
- this.favorite_menu = new my.FavoriteMenu(this, this.query, this.dataset.model);
+ this.favorite_menu = new my.FavoriteMenu(this, this.query, this.dataset.model, this.action_id);
this.filter_menu.appendTo(this.$buttons);
this.groupby_menu.appendTo(this.$buttons);
return instance.web.date_to_str(facetValue.get('value'));
},
complete: function (needle) {
- var d = Date.parse(needle);
- if (!d) { return $.when(null); }
+ var m = moment(needle);
+ if (!m.isValid()) { return $.when(null); }
+ var d = m.toDate();
var date_string = instance.web.format_value(d, this.attrs);
var label = _.str.sprintf(_.str.escapeHTML(
_t("Search %(field)s at: %(value)s")), {
var values = facet.values;
if (_.isEmpty(this.attrs.context) && values.length === 1) {
var c = {};
- c['default_' + this.attrs.name] = values.at(0).get('value');
+ var v = values.at(0);
+ if (v.get('operator') !== 'ilike') {
+ c['default_' + this.attrs.name] = v.get('value');
+ }
return c;
}
return this._super(facet);
prop.$el.hide();
});
},
+ update_max_height: function () {
+ var max_height = $(window).height() - this.$menu[0].getBoundingClientRect().top - 10;
+ this.$menu.css('max-height', max_height);
+ },
toggle_custom_filter_menu: function (is_open) {
this.$add_filter
.toggleClass('closed-menu', !is_open)
this.append_proposition();
}
this.$('.oe-filter-condition').toggle(is_open);
+ this.update_max_height();
},
append_proposition: function () {
var self = this;
self.propositions.push(prop);
prop.insertBefore(self.$add_filter_menu);
self.$apply_filter.prop('disabled', false);
+ self.update_max_height();
return prop;
});
},
this.close_menus();
},
},
- init: function (parent, query, target_model) {
+ init: function (parent, query, target_model, action_id) {
this._super.apply(this,arguments);
this.searchview = parent;
this.query = query;
this.model = new instance.web.Model('ir.filters');
this.filters = {};
this.$filters = {};
- var action = instance.client.action_manager.inner_action;
- this.action_id = action && action.id;
+ this.action_id = action_id;
},
start: function () {
var self = this;
}
})
.on('reset', this.proxy('clear_selection'));
+ if (!this.action_id) {
+ this.prepare_dropdown_menu([]);
+ return $.when();
+ }
return this.model.call('get_filters', [this.target_model, this.action_id])
.done(this.proxy('prepare_dropdown_menu'));
},
ev.preventDefault();
return;
}
+ // ENTER is caugth at KeyUp rather than KeyDown to avoid firing
+ // before all regular keystrokes have been processed
+ if (ev.which === $.ui.keyCode.ENTER) {
+ if (self.current_result && self.get_search_string().length) {
+ self.select_item(ev);
+ }
+ return;
+ }
if (!self.searching) {
self.searching = true;
return;
});
this.$input.on('keydown', function (ev) {
switch (ev.which) {
+ // TAB and direction keys are handled at KeyDown because KeyUp
+ // is not guaranteed to fire.
+ // See e.g. https://github.com/aef-/jquery.masterblaster/issues/13
case $.ui.keyCode.TAB:
- case $.ui.keyCode.ENTER:
if (self.current_result && self.get_search_string().length) {
self.select_item(ev);
}