[IMP] kpi_dashboard: Allow to edit context using items

This commit is contained in:
Enric Tobella
2020-07-29 14:05:48 +02:00
committed by Brian McMaster
parent 4a56338fef
commit 569c56e7f2
5 changed files with 164 additions and 5 deletions

View File

@@ -16,6 +16,12 @@ odoo.define('kpi_dashboard.DashboardRenderer', function (require) {
var widget = new Widget(this, kpi);
return widget;
},
_onClickModifyContext: function (modify_context_expression, event) {
this.trigger_up('modify_context', {
context: modify_context_expression,
event: event,
})
},
_renderView: function () {
this.$el.html($(qweb.render('dashboard_kpi.dashboard')));
this.$el.css(
@@ -31,6 +37,12 @@ odoo.define('kpi_dashboard.DashboardRenderer', function (require) {
element.css('background-color', kpi.color);
element.css('color', kpi.font_color);
self.$grid.append(element);
if (kpi.modify_context) {
element.on("click", self._onClickModifyContext.bind(
self, kpi.modify_context_expression));
element.css('cursor', 'pointer');
// We want to set it show as clickable
}
self.kpi_widget[kpi.id] = self._getDashboardWidget(kpi);
self.kpi_widget[kpi.id].appendTo(element);
});