this.currently_dragging = {};
this.limit = options.limit || 40;
this.add_group_mutex = new $.Mutex();
+ this.last_position = 'static';
},
view_loading: function(r) {
return this.load_kanban(r);
return false;
}
self.nb_records = 0;
- var remaining = groups.length - 1,
- groups_array = [];
+ var groups_array = [];
return $.when.apply(null, _.map(groups, function (group, index) {
var def = $.when([]);
var dataset = new instance.web.DataSetSearch(self, self.dataset.model,
self.nb_records += records.length;
self.dataset.ids.push.apply(self.dataset.ids, dataset.ids);
groups_array[index] = new instance.web_kanban.KanbanGroup(self, records, group, dataset);
- if (!remaining--) {
- self.dataset.index = self.dataset.size() ? 0 : null;
- return self.do_add_groups(groups_array);
- }
});
})).then(function () {
if(!self.nb_records) {
self.no_result();
}
+ if (self.dataset.index >= self.nb_records){
+ self.dataset.index = self.dataset.size() ? 0 : null;
+ }
+ return self.do_add_groups(groups_array);
});
});
},
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(self.dataset.ids) && (self.dataset.index === null || self.dataset.index >= self.dataset.ids.length)) {
+ self.dataset.index = 0;
+ } else if (_.isEmpty(self.dataset.ids)){
+ self.dataset.index = null;
+ }
self.do_add_groups([kgroup]).done(function() {
if (_.isEmpty(records)) {
self.no_result();
var self = this;
if (this.group_by) {
// Kanban cards drag'n'drop
- var prev_widget,is_folded,record;
+ var prev_widget, is_folded, record;
var $columns = this.$el.find('.oe_kanban_column .oe_kanban_column_cards, .oe_kanban_column .oe_kanban_folded_column_cards');
$columns.sortable({
handle : '.oe_kanban_draghandle',
});
record = ui.item.data('widget');
record.$el.bind('mouseup',function(ev,ui){
- if(is_folded)record.$el.hide();
+ if (is_folded) {
+ record.$el.hide();
+ }
record.$el.unbind('mouseup');
})
ui.placeholder.height(ui.item.height());
var parent = $(event.target).parent();
prev_widget.highlight(false);
is_folded = parent.hasClass('oe_kanban_group_folded');
- if(is_folded){
+ if (is_folded) {
var widget = parent.data('widget');
widget.highlight(true);
prev_widget = widget;
stop: function(event, ui) {
var stop_index = ui.item.index();
if (start_index !== stop_index) {
- var $start_column = $('.oe_kanban_groups_records .oe_kanban_column').eq(start_index);
- var $stop_column = $('.oe_kanban_groups_records .oe_kanban_column').eq(stop_index);
+ var $start_column = self.$('.oe_kanban_groups_records .oe_kanban_column').eq(start_index);
+ var $stop_column = self.$('.oe_kanban_groups_records .oe_kanban_column').eq(stop_index);
var method = (start_index > stop_index) ? 'insertBefore' : 'insertAfter';
$start_column[method]($stop_column);
var tmp_group = self.groups.splice(start_index, 1)[0];
this.dataset.write(record.id, data, {}).done(function() {
record.do_reload();
new_group.do_save_sequences();
- if(new_group.state.folded){
+ if (new_group.state.folded) {
new_group.do_action_toggle_fold();
record.prependTo(new_group.$records.find('.oe_kanban_column_cards'));
}
}).fail(function(error, evt) {
evt.preventDefault();
- alert(_t("An error has occured while moving the record to this group: ") + data.message);
+ alert(_t("An error has occured while moving the record to this group: ") + error.data.message);
self.do_reload(); // TODO: use draggable + sortable in order to cancel the dragging when the rcp fails
});
}
|| (!this.options.action.help && !this.options.action.get_empty_list_help)) {
return;
}
+ this.last_position = this.$el.find('table:first').css("position");
this.$el.find('table:first').css("position", "absolute");
$(QWeb.render('KanbanView.nocontent', { content : this.options.action.get_empty_list_help || this.options.action.help})).insertAfter(this.$('table:first'));
this.$el.find('.oe_view_nocontent').click(function() {
});
},
remove_no_result: function() {
- this.$el.find('table:first').css("position", false);
- this.$el.find('.oe_view_nocontent').remove();
+ this.$el.find('table:first').css("position", this.last_position);
+ this.$el.find('.oe_view_nocontent').remove();
},
/*
} catch(e) {}
}
_.each(this.view.aggregates, function(value, key) {
- self.aggregates[value] = group.get('aggregates')[key];
+ self.aggregates[value] = instance.web.format_value(group.get('aggregates')[key], {type: 'float'});
});
}
var color = this.kanban_getcolor(variable);
return color === '' ? '' : 'oe_kanban_color_' + color;
},
- kanban_gravatar: function(email, size) {
- size = size || 22;
- email = _.str.trim(email || '').toLowerCase();
- var default_ = _.str.isBlank(email) ? 'mm' : 'identicon';
- var email_md5 = $.md5(email);
- return 'http://www.gravatar.com/avatar/' + email_md5 + '.png?s=' + size + '&d=' + default_;
- },
kanban_image: function(model, field, id, cache, options) {
options = options || {};
var url;
*/
instance.web_kanban.QuickCreate = instance.web.Widget.extend({
template: 'KanbanView.quick_create',
-
+
/**
* close_btn: If true, the widget will display a "Close" button able to trigger
* a "close" event.