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
2.1 KiB

  1. "use strict";
  2. openerp.web_group_expand = function(openerp) {
  3. var QWeb = openerp.web.qweb;
  4. openerp.web.ViewManager.include({
  5. switch_mode: function(view_type, no_store, view_options) {
  6. if (view_type != 'list' && view_type != 'tree' ) {
  7. this.$el.find("ul#oe_group_by").remove();
  8. }
  9. if(view_type == 'tree'){
  10. this.load_expand_buttons();
  11. this.$ExpandButtons.find("a#oe_group_by_reset").click(function(){
  12. $('.oe_open .treeview-tr.oe-treeview-first').filter(function(){return ($(this).parents('tr').attr('data-level') == 1)}).click()
  13. });
  14. this.$ExpandButtons.find("a#oe_group_by_expand").click(function(){
  15. $('.treeview-tr.oe-treeview-first').filter(function(){return (!$(this).parents().is('.oe_open')) & ($(this).parents().css( "display" ) != 'none')}).click();
  16. });
  17. }
  18. return this._super.apply(this, arguments);
  19. },
  20. expand: function(domains, contexts, groupbys) {
  21. this.$el.find("ul#oe_group_by").remove();
  22. if(groupbys.length && this.active_view == 'list') {
  23. this.load_expand_buttons();
  24. this.$el.find("a#oe_group_by_reset").click(function(){
  25. $('span.ui-icon-triangle-1-s').click()
  26. });
  27. this.$el.find("a#oe_group_by_expand").click(function(){
  28. $('span.ui-icon-triangle-1-e').click()
  29. });
  30. }
  31. },
  32. load_expand_buttons:function() {
  33. var self = this;
  34. this.$ExpandButtons = $(QWeb.render("GroupExpand.Buttons", {'widget':self}));
  35. this.$el.find("ul.oe_view_manager_switch.oe_button_group.oe_right").before(this.$ExpandButtons);
  36. },
  37. setup_search_view: function(view_id, search_defaults) {
  38. var self = this;
  39. var res = this._super.apply(this, arguments);
  40. this.searchview.on('search_data', self, this.expand);
  41. return res
  42. },
  43. })
  44. }