[IMP] sale_crm: widget gage add an input to change the value
bzr revid: chm@openerp.com-20130506090019-wvq5o0qm5zn6umba
This commit is contained in:
parent
137859f01e
commit
2e2b0ec3b1
|
@ -249,7 +249,7 @@
|
|||
<xpath expr="//div[@class='oe_items_list']" position="after">
|
||||
<div class="oe_center" t-if="record.target_invoice.raw_value">
|
||||
<field name="sent_invoice_per_duration" widget="gage" style="width:160px; height: 120px;" options="{'max_field': 'target_invoice', 'label_field': 'target_duration_txt'}">Invoiced</field>
|
||||
<field name="forecast" widget="gage" style="width:160px; height: 120px;" options="{'max_field': 'target_invoice', 'label_field': 'target_duration_txt'}">Forecast</field>
|
||||
<field name="forecast" widget="gage" style="width:160px; height: 120px;" options="{'max_field': 'target_invoice', 'label_field': 'target_duration_txt', 'action_change': 'action_forecast'}">Forecast</field>
|
||||
</div>
|
||||
<div class="oe_center" style="color:#bbbbbb;" t-if="!record.target_invoice.raw_value">
|
||||
<br/>Not target invoicing defined
|
||||
|
|
|
@ -3,14 +3,12 @@ openerp.sale_crm = function(openerp) {
|
|||
openerp.sale_crm.GaugeWidget = openerp.web_kanban.AbstractField.extend({
|
||||
className: "oe_gage",
|
||||
start: function() {
|
||||
var max = 100;
|
||||
if (this.options.max_field) {
|
||||
max = this.getParent().record[this.options.max_field].raw_value;
|
||||
}
|
||||
var label = "";
|
||||
if (this.options.label_field) {
|
||||
label = this.getParent().record[this.options.label_field].raw_value;
|
||||
}
|
||||
var self = this;
|
||||
console.log("start");
|
||||
|
||||
var parent = this.getParent();
|
||||
var max = this.options.max_field ? parent.record[this.options.max_field].raw_value : 100;
|
||||
var label = this.options.label_field ? parent.record[this.options.label_field].raw_value : "";
|
||||
var title = this.$node.html();
|
||||
var val = this.field.value;
|
||||
var value = _.isArray(val) && val.length ? val[val.length-1] : val;
|
||||
|
@ -38,6 +36,51 @@ openerp.sale_crm.GaugeWidget = openerp.web_kanban.AbstractField.extend({
|
|||
"#a9d70b"
|
||||
],
|
||||
});
|
||||
|
||||
var flag_open = false;
|
||||
if (self.options.action_change) {
|
||||
self.$el.click(function (event) {
|
||||
event.stopPropagation();
|
||||
flag_open = false;
|
||||
if (!parent.view.is_action_enabled('edit')) {
|
||||
return;
|
||||
}
|
||||
if (!self.$el.find(".oe_justgage_edit").size()) {
|
||||
var $svg = self.$el.find('svg');
|
||||
$div = $('<div class="oe_justgage_edit" style="text-align: center; z-index: 1; position: absolute; width: ' + $svg.outerWidth() + 'px; top: ' + ($svg.outerHeight()/2-5) + 'px;"/>');
|
||||
$input = $('<input style="text-align: center; width: ' + ($svg.outerWidth()-40) + 'px; margin: auto;"/>').val(value);
|
||||
$div.append($input);
|
||||
self.$el.prepend($div)
|
||||
$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();
|
||||
}
|
||||
}
|
||||
})
|
||||
.click(function (event) {
|
||||
event.stopPropagation();
|
||||
flag_open = false;
|
||||
})
|
||||
.blur(function (event) {
|
||||
if(!flag_open) {
|
||||
self.$el.find(".oe_justgage_edit").remove();
|
||||
} else {
|
||||
flag_open = false;
|
||||
setTimeout(function () {$input.focus();}, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).mousedown(function () {
|
||||
flag_open = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
openerp.web_kanban.fields_registry.add("gage", "openerp.sale_crm.GaugeWidget");
|
||||
|
|
Loading…
Reference in New Issue