this.currently_dragging = {};
this.limit = options.limit || 40;
this.add_group_mutex = new $.Mutex();
+ if (!this.options.$buttons || !this.options.$buttons.length) {
+ this.options.$buttons = false;
+ }
},
view_loading: function(r) {
return this.load_kanban(r);
if (unsorted && default_order) {
this.dataset.set_sort(default_order.split(','));
}
-
this.$el.addClass(this.fields_view.arch.attrs['class']);
this.$buttons = $(QWeb.render("KanbanView.buttons", {'widget': this}));
if (this.options.$buttons) {
this.$buttons.appendTo(this.options.$buttons);
} else {
- this.$el.find('.oe_kanban_buttons').replaceWith(this.$buttons);
+ this.$('.oe_kanban_buttons').replaceWith(this.$buttons);
}
this.$buttons
.on('click', 'button.oe_kanban_button_new', this.do_add_record)
case 'button':
case 'a':
var type = node.attrs.type || '';
- if (_.indexOf('action,object,edit,open,delete'.split(','), type) !== -1) {
+ if (_.indexOf('action,object,edit,open,delete,url'.split(','), type) !== -1) {
_.each(node.attrs, function(v, k) {
if (_.indexOf('icon,type,name,args,string,context,states,kanban_states'.split(','), k) != -1) {
node.attrs['data-' + k] = v;
}
}];
}
- if (node.tag == 'a') {
+ if (node.tag == 'a' && node.attrs['data-type'] != "url") {
node.attrs.href = '#';
} else {
node.attrs.type = 'button';
self.fields_keys = _.unique(self.fields_keys.concat(grouping_fields));
}
var grouping = new instance.web.Model(self.dataset.model, context, domain).query(self.fields_keys).group_by(grouping_fields);
- return self.alive($.when(grouping)).done(function(groups) {
+ return self.alive($.when(grouping)).then(function(groups) {
self.remove_no_result();
if (groups) {
- self.do_process_groups(groups);
+ return self.do_process_groups(groups);
} else {
- self.do_process_dataset();
+ return self.do_process_dataset();
}
});
});
var self = this;
this.$el.find('table:first').show();
this.$el.removeClass('oe_kanban_ungrouped').addClass('oe_kanban_grouped');
- this.add_group_mutex.exec(function() {
+ return this.add_group_mutex.exec(function() {
self.do_clear_groups();
self.dataset.ids = [];
if (!groups.length) {
self.no_result();
- return false;
+ return $.when();
}
self.nb_records = 0;
var groups_array = [];
if (self.dataset.index >= self.nb_records){
self.dataset.index = self.dataset.size() ? 0 : null;
}
- return self.do_add_groups(groups_array);
+ return self.do_add_groups(groups_array).done(function() {
+ self.trigger('kanban_groups_processed');
+ });
});
});
},
var self = this;
this.$el.find('table:first').show();
this.$el.removeClass('oe_kanban_grouped').addClass('oe_kanban_ungrouped');
+ var def = $.Deferred();
this.add_group_mutex.exec(function() {
- var def = $.Deferred();
self.do_clear_groups();
self.dataset.read_slice(self.fields_keys.concat(['__last_update']), { 'limit': self.limit }).done(function(records) {
var kgroup = new instance.web_kanban.KanbanGroup(self, records, null, self.dataset);
if (_.isEmpty(records)) {
self.no_result();
}
+ self.trigger('kanban_dataset_processed');
def.resolve();
});
}).done(null, function() {
def.reject();
});
- return def;
});
+ return def;
},
do_reload: function() {
this.do_search(this.search_domain, this.search_context, this.search_group_by);
},
do_show: function() {
- if (this.$buttons) {
+ if (this.options.$buttons) {
this.$buttons.show();
}
this.do_push_state({});
* open on form/edit view : oe_kanban_global_click_edit
*/
on_card_clicked: function(ev) {
- if(this.$el.find('.oe_kanban_global_click_edit').size()>0)
+ if (this.$el.find('.oe_kanban_global_click').size() > 0 && this.$el.find('.oe_kanban_global_click').data('routing')) {
+ instance.web.redirect(this.$el.find('.oe_kanban_global_click').data('routing') + "/" + this.id);
+ }
+ else if (this.$el.find('.oe_kanban_global_click_edit').size()>0)
this.do_action_edit();
else
this.do_action_open();
var button_attrs = $action.data();
this.view.do_execute_action(button_attrs, this.view.dataset, this.id, this.do_reload);
},
+ do_action_url: function($action) {
+ return instance.web.redirect($action.attr("href"));
+ },
do_reload: function() {
var self = this;
this.view.dataset.read_ids([this.id], this.view.fields_keys.concat(['__last_update'])).done(function(records) {