[MERGE] [FIX] web_kanban_gauge: check the value entered in the forecast

[IMP] web_kanban_sparkline: added an option to add a suffix in the sparkline tooltips

bzr revid: tde@openerp.com-20131205160010-8ecv8b618fa6rywj
This commit is contained in:
Thibault Delavallée 2013-12-05 17:00:10 +01:00
commit 84375d5a3e
3 changed files with 18 additions and 10 deletions

View File

@ -440,7 +440,7 @@ instance.web_kanban.KanbanView = instance.web.View.extend({
new_group.do_save_sequences();
}).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
});
}

View File

@ -4,6 +4,8 @@ openerp.web_kanban_gauge = function (instance) {
* Kanban widgets: GaugeWidget
*
*/
var _t = instance.web._t,
_lt = instance.web._lt;
instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
className: "oe_gauge",
@ -77,13 +79,18 @@ instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
$input.focus()
.keydown(function (event) {
event.stopPropagation();
if (event.keyCode == 13 || event.keyCode == 9) {
if ($input.val() != value) {
parent.view.dataset.call(self.options.action_change, [parent.id, $input.val()]).then(function () {
parent.do_reload();
});
} else {
$div.remove();
if(isNaN($input.val())){
self.do_warn(_t("Wrong value entered!"), _t("Only Integer Value should be valid."));
$div.remove();
} else {
if (event.keyCode == 13 || event.keyCode == 9) {
if ($input.val() != value) {
parent.view.dataset.call(self.options.action_change, [parent.id, $input.val()]).then(function () {
parent.do_reload();
});
} else {
$div.remove();
}
}
}
})

View File

@ -13,6 +13,7 @@ instance.web_kanban.SparklineBarWidget = instance.web_kanban.AbstractField.exten
setTimeout(function () {
var value = _.pluck(self.field.value, 'value');
var tooltips = _.pluck(self.field.value, 'tooltip');
var suffix = self.options.tooltip_suffix || "";
var sparkline_options = _.extend({
type: 'bar',
barWidth: 5,
@ -20,14 +21,14 @@ instance.web_kanban.SparklineBarWidget = instance.web_kanban.AbstractField.exten
barWidth: 4,
barSpacing: 1,
barColor: '#96d854',
tooltipFormat: '{{offset:offset}} {{value}} ' + suffix,
chartRangeMin: 0,
tooltipFormat: '{{offset:offset}} {{value}}',
tooltipValueLookups: {
'offset': tooltips
}
}, self.options);
self.$el.sparkline(value, sparkline_options);
self.$el.tipsy({'delayIn': 0, 'html': true, 'title': function(){return title}, 'gravity': 'n'});
self.$el.tipsy({'delayIn': self.options.delayIn || 0, 'html': true, 'title': function(){return title}, 'gravity': 'n'});
}, 0);
},
});