You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.4 KiB

  1. openerp.web_search_with_and = function (instance) {
  2. instance.web.SearchView = instance.web.SearchView.extend({
  3. select_completion: function (e, ui) {
  4. var self = this;
  5. if (e.shiftKey) {
  6. e.preventDefault();
  7. var input_index = _(this.input_subviews).indexOf(
  8. this.subviewForRoot(
  9. this.$('div.oe_searchview_input:focus')[0]));
  10. this.query.add(ui.item.facet, {at: input_index / 2, shiftKey: true});
  11. } else {
  12. this._super(e, ui);
  13. }
  14. },
  15. });
  16. instance.web.search.SearchQuery = instance.web.search.SearchQuery.extend({
  17. add: function (values, options) {
  18. options = options || {};
  19. if (!values) {
  20. values = [];
  21. } else if (!(values instanceof Array)) {
  22. values = [values];
  23. }
  24. if (options.shiftKey) {
  25. delete options.shiftKey;
  26. _(values).each(function (value) {
  27. var model = this._prepareModel(value, options);
  28. Backbone.Collection.prototype.add.call(this, model, options);
  29. }, this);
  30. return this;
  31. }
  32. else {
  33. return this.constructor.__super__.add.apply(this, arguments);
  34. }
  35. },
  36. });
  37. };