Browse Source

[FIX] Missing GroupClick Functionality

pull/1090/head
Martin Nicolas Cuesta 7 years ago
committed by tarteo
parent
commit
32f54e120c
  1. 12
      web_timeline/static/src/js/timeline_controller.js
  2. 29
      web_timeline/static/src/js/timeline_renderer.js

12
web_timeline/static/src/js/timeline_controller.js

@ -10,6 +10,7 @@ var _t = core._t;
var CalendarController = AbstractController.extend({
custom_events: _.extend({}, AbstractController.prototype.custom_events, {
onGroupClick: '_onGroupClick',
onUpdate: '_onUpdate',
onRemove: '_onRemove',
onMove: '_onMove',
@ -62,6 +63,17 @@ var CalendarController = AbstractController.extend({
});
},
_onGroupClick: function (event) {
var groupField = this.renderer.last_group_bys[0];
return this.do_action({
type: 'ir.actions.act_window',
res_model: this.renderer.view.fields[groupField].relation,
res_id: event.data.item.group,
target: 'new',
views: [[false, 'form']]
});
},
_onUpdate: function(event) {
var self = this;
this.renderer = event.data.renderer;

29
web_timeline/static/src/js/timeline_renderer.js

@ -106,26 +106,6 @@ var CalendarRenderer = AbstractRenderer.extend({
}
},
_onClick: function (e) {
// handle a click on a group header
if (e.what === 'group-label') {
return self._onGroupClick(e);
}
},
_onGroupClick: function (e) {
if (e.group === -1) {
return;
}
return this.do_action({
type: 'ir.actions.act_window',
res_model: this.view.fields_view.fields[this.last_group_bys[0]].relation,
res_id: e.group,
target: 'new',
views: [[false, 'form']]
});
},
_computeMode: function() {
if (this.mode) {
var start = false, end = false;
@ -176,7 +156,7 @@ var CalendarRenderer = AbstractRenderer.extend({
if (self.mode && self['on_scale_' + self.mode + '_clicked']) {
self['on_scale_' + self.mode + '_clicked']();
}
this.timeline.on('click', self._onClick);
this.timeline.on('click', self.on_group_click);
var group_bys = this.arch.attrs.default_group_by.split(',');
this.last_group_bys = group_bys;
this.last_domains = this.modelClass.data.domain;
@ -300,6 +280,13 @@ var CalendarRenderer = AbstractRenderer.extend({
return r;
},
on_group_click: function (e) {
// handle a click on a group header
if (e.what === 'group-label' && e.group != -1) {
this._trigger(e, function(){}, 'onGroupClick');
}
},
on_update: function (item, callback) {
this._trigger(item, callback, 'onUpdate');
},

Loading…
Cancel
Save