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.

77 lines
2.9 KiB

  1. /**********************************************************************************
  2. *
  3. * Copyright (C) 2017 MuK IT GmbH
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as
  7. * published by the Free Software Foundation, either version 3 of the
  8. * License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. **********************************************************************************/
  19. odoo.define('muk_web_searchpanel.KanbanController', function (require) {
  20. "use strict";
  21. var core = require('web.core');
  22. var session = require('web.session');
  23. var view_dialogs = require('web.view_dialogs');
  24. var viewUtils = require('web.viewUtils');
  25. var Domain = require('web.Domain');
  26. var Context = require('web.Context');
  27. var KanbanController = require('web.KanbanController');
  28. var _t = core._t;
  29. var QWeb = core.qweb;
  30. KanbanController.include({
  31. custom_events: _.extend({}, KanbanController.prototype.custom_events, {
  32. search_panel_domain_updated: '_onSearchPanelDomainUpdated',
  33. }),
  34. init: function (parent, model, renderer, params) {
  35. this._super.apply(this, arguments);
  36. this._searchPanel = params.searchPanel;
  37. this.controlPanelDomain = params.controlPanelDomain || [];
  38. this.searchPanelDomain = this._searchPanel ? this._searchPanel.getDomain() : [];
  39. },
  40. start: function () {
  41. if (this._searchPanel) {
  42. this.$el.addClass('o_kanban_with_searchpanel');
  43. this.$el.prepend(this._searchPanel.$el);
  44. }
  45. return this._super.apply(this, arguments);
  46. },
  47. update: function (params) {
  48. if (!this._searchPanel) {
  49. return this._super.apply(this, arguments);
  50. }
  51. var self = this;
  52. if (params.domain) {
  53. this.controlPanelDomain = params.domain;
  54. }
  55. params.noRender = true;
  56. params.domain = this.controlPanelDomain.concat(this.searchPanelDomain);
  57. var superProm = this._super.apply(this, arguments);
  58. var searchPanelProm = this._updateSearchPanel();
  59. return $.when(superProm, searchPanelProm).then(function () {
  60. return self.renderer.render();
  61. });
  62. },
  63. _updateSearchPanel: function () {
  64. return this._searchPanel.update({searchDomain: this.controlPanelDomain});
  65. },
  66. _onSearchPanelDomainUpdated: function (ev) {
  67. this.searchPanelDomain = ev.data.domain;
  68. this.reload({offset: 0});
  69. },
  70. });
  71. });