[IMP] [FIX] kanban: updated justgage and sparklin libraries; fixed gauge widget showing 0 as value by forcing a refresh
bzr revid: tde@openerp.com-20130906093221-n94whqrrj2meknwf
This commit is contained in:
parent
60b0c0ae95
commit
a937b5679b
|
@ -36,7 +36,7 @@ This module provides the core of the OpenERP Web Client.
|
|||
"static/lib/jquery.tipsy/jquery.tipsy.js",
|
||||
"static/lib/jquery.textext/jquery.textext.js",
|
||||
"static/lib/jquery.timeago/jquery.timeago.js",
|
||||
"static/lib/justgage/justgage.1.0.1.js",
|
||||
"static/lib/justgage/justgage.js",
|
||||
"static/lib/qweb/qweb2.js",
|
||||
"static/lib/underscore/underscore.js",
|
||||
"static/lib/underscore.string/lib/underscore.string.js",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* jquery.sparkline.js
|
||||
*
|
||||
* v2.1.1
|
||||
* v2.1.2
|
||||
* (c) Splunk, Inc
|
||||
* Contact: Gareth Watts (gareth@splunk.com)
|
||||
* http://omnipotent.net/jquery.sparkline/
|
||||
|
@ -202,11 +202,11 @@
|
|||
|
||||
/*jslint regexp: true, browser: true, jquery: true, white: true, nomen: false, plusplus: false, maxerr: 500, indent: 4 */
|
||||
|
||||
(function(document, Math, undefined) { // performance/minified-size optimization
|
||||
(function(factory) {
|
||||
if(typeof define === 'function' && define.amd) {
|
||||
define(['jquery'], factory);
|
||||
}
|
||||
else {
|
||||
} else if (jQuery && !jQuery.fn.sparkline) {
|
||||
factory(jQuery);
|
||||
}
|
||||
}
|
||||
|
@ -597,19 +597,41 @@
|
|||
if (useExisting && (target = this.data('_jqs_vcanvas'))) {
|
||||
return target;
|
||||
}
|
||||
|
||||
if ($.fn.sparkline.canvas === false) {
|
||||
// We've already determined that neither Canvas nor VML are available
|
||||
return false;
|
||||
|
||||
} else if ($.fn.sparkline.canvas === undefined) {
|
||||
// No function defined yet -- need to see if we support Canvas or VML
|
||||
var el = document.createElement('canvas');
|
||||
if (!!(el.getContext && el.getContext('2d'))) {
|
||||
// Canvas is available
|
||||
$.fn.sparkline.canvas = function(width, height, target, interact) {
|
||||
return new VCanvas_canvas(width, height, target, interact);
|
||||
};
|
||||
} else if (document.namespaces && !document.namespaces.v) {
|
||||
// VML is available
|
||||
document.namespaces.add('v', 'urn:schemas-microsoft-com:vml', '#default#VML');
|
||||
$.fn.sparkline.canvas = function(width, height, target, interact) {
|
||||
return new VCanvas_vml(width, height, target);
|
||||
};
|
||||
} else {
|
||||
// Neither Canvas nor VML are available
|
||||
$.fn.sparkline.canvas = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (width === undefined) {
|
||||
width = $(this).innerWidth();
|
||||
}
|
||||
if (height === undefined) {
|
||||
height = $(this).innerHeight();
|
||||
}
|
||||
if ($.fn.sparkline.hasCanvas) {
|
||||
target = new VCanvas_canvas(width, height, this, interact);
|
||||
} else if ($.fn.sparkline.hasVML) {
|
||||
target = new VCanvas_vml(width, height, this);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
target = $.fn.sparkline.canvas(width, height, this, interact);
|
||||
|
||||
mhandler = $(this).data('_jqs_mhandler');
|
||||
if (mhandler) {
|
||||
mhandler.registerCanvas(target);
|
||||
|
@ -977,8 +999,7 @@
|
|||
mhandler.registerSparkline(sp);
|
||||
}
|
||||
};
|
||||
// jQuery 1.3.0 completely changed the meaning of :hidden :-/
|
||||
if (($(this).html() && !options.get('disableHiddenCheck') && $(this).is(':hidden')) || ($.fn.jquery < '1.3.0' && $(this).parents().is(':hidden')) || !$(this).parents('body').length) {
|
||||
if (($(this).html() && !options.get('disableHiddenCheck') && $(this).is(':hidden')) || !$(this).parents('body').length) {
|
||||
if (!options.get('composite') && $.data(this, '_jqs_pending')) {
|
||||
// remove any existing references to the element
|
||||
for (i = pending.length; i; i--) {
|
||||
|
@ -2528,20 +2549,6 @@
|
|||
// Setup a very simple "virtual canvas" to make drawing the few shapes we need easier
|
||||
// This is accessible as $(foo).simpledraw()
|
||||
|
||||
// Detect browser renderer support
|
||||
(function() {
|
||||
if (document.namespaces && !document.namespaces.v) {
|
||||
$.fn.sparkline.hasVML = true;
|
||||
document.namespaces.add('v', 'urn:schemas-microsoft-com:vml', '#default#VML');
|
||||
} else {
|
||||
$.fn.sparkline.hasVML = false;
|
||||
}
|
||||
|
||||
var el = document.createElement('canvas');
|
||||
$.fn.sparkline.hasCanvas = !!(el.getContext && el.getContext('2d'));
|
||||
|
||||
})()
|
||||
|
||||
VShape = createClass({
|
||||
init: function (target, id, type, args) {
|
||||
this.target = target;
|
||||
|
@ -3044,4 +3051,4 @@
|
|||
}
|
||||
});
|
||||
|
||||
}));
|
||||
}))}(document, Math));
|
|
@ -1276,6 +1276,7 @@ instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
|
|||
className: "oe_gauge",
|
||||
start: function() {
|
||||
var self = this;
|
||||
var parent = this.getParent();
|
||||
var max = 100;
|
||||
if (this.options.max_field) {
|
||||
max = this.getParent().record[this.options.max_field].raw_value;
|
||||
|
@ -1287,33 +1288,43 @@ instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
|
|||
var val = this.field.value;
|
||||
var value = _.isArray(val) && val.length ? val[val.length-1]['value'] : val;
|
||||
var title = this.$node.html() || this.field.string;
|
||||
// var unique_id = _.uniqueId("JustGage");
|
||||
|
||||
this.$el.empty()
|
||||
.attr('style', this.$node.attr('style') + ';position:relative; display:inline-block;');
|
||||
|
||||
this.gage = new JustGage({
|
||||
parentNode: this.$el[0],
|
||||
// id: unique_id,
|
||||
value: value,
|
||||
title: title,
|
||||
min: 0,
|
||||
max: max,
|
||||
relativeGaugeSize: true,
|
||||
humanFriendly: true,
|
||||
titleFontColor: '#333333',
|
||||
valueFontColor: '#333333',
|
||||
labelFontColor: '#000',
|
||||
label: label,
|
||||
levelColors: [
|
||||
"#ff0000",
|
||||
"#f9c802",
|
||||
"#a9d70b"
|
||||
]
|
||||
],
|
||||
});
|
||||
this.gage.refresh(value, max);
|
||||
|
||||
var flag_open = false;
|
||||
if (self.options.action_change) {
|
||||
var $svg = self.$el.find('svg');
|
||||
if (this.options.action_change) {
|
||||
var $svg = this.$el.find('svg');
|
||||
var css = {
|
||||
'text-align': 'center',
|
||||
'position': 'absolute',
|
||||
'width': self.$el.outerWidth() + 'px',
|
||||
'top': (self.$el.outerHeight()/2-5) + 'px'
|
||||
'width': this.$el.outerWidth() + 'px',
|
||||
'top': (this.$el.outerHeight()/2-5) + 'px'
|
||||
};
|
||||
|
||||
self.$el.click(function (event) {
|
||||
this.$el.click(function (event) {
|
||||
event.stopPropagation();
|
||||
flag_open = false;
|
||||
if (!parent.view.is_action_enabled('edit')) {
|
||||
|
@ -1364,7 +1375,7 @@ instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
|
|||
$svg.fadeTo(0, 0.3);
|
||||
$div = $('<div/>').text(_t("Click to change value"));
|
||||
$div.css(css);
|
||||
self.$el.append($div);
|
||||
this.$el.append($div);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue