OCA-git-bot
4 years ago
12 changed files with 350 additions and 20 deletions
-
27kpi_dashboard/models/kpi_dashboard.py
-
116kpi_dashboard/models/kpi_kpi.py
-
2kpi_dashboard/security/ir.model.access.csv
-
22kpi_dashboard/static/src/js/dashboard_controller.js
-
13kpi_dashboard/static/src/js/dashboard_renderer.js
-
68kpi_dashboard/static/src/js/field_widget.js
-
7kpi_dashboard/static/src/js/widget/abstract_widget.js
-
5kpi_dashboard/static/src/xml/dashboard.xml
-
22kpi_dashboard/tests/test_formula.py
-
3kpi_dashboard/views/kpi_dashboard.xml
-
84kpi_dashboard/views/kpi_kpi.xml
-
1kpi_dashboard/views/webclient_templates.xml
@ -0,0 +1,68 @@ |
|||||
|
odoo.define('kpi_dashboard.KpiFieldWidget', function(require) { |
||||
|
"use strict"; |
||||
|
|
||||
|
var basic_fields = require('web.basic_fields'); |
||||
|
var field_registry = require('web.field_registry'); |
||||
|
var core = require('web.core'); |
||||
|
var qweb = core.qweb; |
||||
|
var registry = require('kpi_dashboard.widget_registry'); |
||||
|
|
||||
|
var KpiFieldWidget = basic_fields.FieldChar.extend({ |
||||
|
jsLibs: [ |
||||
|
'/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.js', |
||||
|
], |
||||
|
cssLibs: [ |
||||
|
'/kpi_dashboard/static/lib/gridster/jquery.dsmorse-gridster.min.css', |
||||
|
], |
||||
|
className: 'o_dashboard_view', |
||||
|
_renderReadonly: function () { |
||||
|
this.$el.html($(qweb.render('dashboard_kpi.dashboard'))); |
||||
|
var marginx = 0; |
||||
|
var marginy = 0; |
||||
|
var widgetx = 400; |
||||
|
var widgety = 400; |
||||
|
this.$el.find('.gridster').css('width', widgety); |
||||
|
this.$grid = this.$el.find('.gridster ul'); |
||||
|
var widgetVals = { |
||||
|
value: this.value, |
||||
|
col: 1, |
||||
|
row: 1, |
||||
|
sizex: 1, |
||||
|
sizey: 1, |
||||
|
name: this.recordData[this.nodeOptions.name], |
||||
|
value_last_update: this.recordData[this.nodeOptions.date] |
||||
|
} |
||||
|
var Widget = registry.getAny([ |
||||
|
this.recordData[this.nodeOptions.widget], 'abstract', |
||||
|
]); |
||||
|
this.state = { |
||||
|
specialData: { |
||||
|
margin_x: marginx, |
||||
|
margin_y: marginy, |
||||
|
widget_dimension_x: widgetx, |
||||
|
widget_dimension_y: widgety, |
||||
|
} |
||||
|
} |
||||
|
var widget = new Widget(this, widgetVals); |
||||
|
var element = $(qweb.render( |
||||
|
'kpi_dashboard.kpi', {widget: widgetVals})); |
||||
|
element.css('background-color', 'white'); |
||||
|
element.css('color', 'black'); |
||||
|
this.$grid.append(element); |
||||
|
widget.appendTo(element) |
||||
|
this.$grid.gridster({ |
||||
|
widget_margins: [ |
||||
|
marginx, |
||||
|
marginy, |
||||
|
], |
||||
|
widget_base_dimensions: [ |
||||
|
widgetx, |
||||
|
widgety, |
||||
|
], |
||||
|
cols: 1, |
||||
|
}).data('gridster').disable(); |
||||
|
}, |
||||
|
}); |
||||
|
field_registry.add('kpi', KpiFieldWidget); |
||||
|
return KpiFieldWidget; |
||||
|
}); |
Write
Preview
Loading…
Cancel
Save
Reference in new issue