[IMP] removes the 'stat_button' widget and modifies button to fulfill that role. Now, a button with a class 'oe_stat_button' will be displayed differently (look in form views) (addon web). Also removes the useless widget x2many
bzr revid: ged@openerp.com-20140314134456-wy6ya3zz72zx3yo2
This commit is contained in:
parent
500fc0790c
commit
d849c6521d
|
@ -1218,9 +1218,6 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt
|
|||
$('button', doc).each(function() {
|
||||
$(this).attr('data-button-type', $(this).attr('type')).attr('type', 'button');
|
||||
});
|
||||
$('statbutton', doc).each(function() {
|
||||
$(this).attr('data-button-type', $(this).attr('type')).attr('type', 'button');
|
||||
});
|
||||
// IE's html parser is also a css parser. How convenient...
|
||||
$('board', doc).each(function() {
|
||||
$(this).attr('layout', $(this).attr('style'));
|
||||
|
@ -1310,7 +1307,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt
|
|||
var tagname = $tag[0].nodeName.toLowerCase();
|
||||
if (this.tags_registry.contains(tagname)) {
|
||||
this.tags_to_init.push($tag);
|
||||
return (tagname === 'statbutton') ? this.process_statbutton($tag) : $tag;
|
||||
return (tagname === 'button') ? this.process_button($tag) : $tag;
|
||||
}
|
||||
var fn = self['process_' + tagname];
|
||||
if (fn) {
|
||||
|
@ -1327,16 +1324,13 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt
|
|||
return $tag;
|
||||
}
|
||||
},
|
||||
process_statbutton: function ($button) {
|
||||
process_button: function ($button) {
|
||||
var self = this;
|
||||
if ($button.children().length) {
|
||||
$button.children().each(function() {
|
||||
self.process($(this));
|
||||
});
|
||||
}
|
||||
$button.children().each(function() {
|
||||
self.process($(this));
|
||||
});
|
||||
return $button;
|
||||
},
|
||||
|
||||
process_widget: function($widget) {
|
||||
this.widgets_to_init.push($widget);
|
||||
return $widget;
|
||||
|
@ -1922,6 +1916,8 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
|
|||
template: 'WidgetButton',
|
||||
init: function(field_manager, node) {
|
||||
node.attrs.type = node.attrs['data-button-type'];
|
||||
this.is_stat_button = node.attrs.class ? _.include(node.attrs.class.split(' '), 'oe_stat_button') : false;
|
||||
this.icon = "<span class=\"fa " + node.attrs.icon + "\"></span>";
|
||||
this._super(field_manager, node);
|
||||
this.force_disabled = false;
|
||||
this.string = (this.node.attrs.string || '').replace(/_/g, '');
|
||||
|
@ -2005,22 +2001,6 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
|
|||
}
|
||||
});
|
||||
|
||||
instance.web.form.StatButton = instance.web.form.WidgetButton.extend({
|
||||
template: 'StatButton',
|
||||
|
||||
init: function(field_manager, node) {
|
||||
var icon = node.attrs.icon;
|
||||
this._super(field_manager, node);
|
||||
|
||||
// debugger;
|
||||
if (icon) {
|
||||
this.icon = "<span class=\"fa " + icon + "\"></span>";
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Interface to be implemented by fields.
|
||||
*
|
||||
|
@ -2857,7 +2837,7 @@ instance.web.form.FieldPercentPie = instance.web.form.AbstractField.extend({
|
|||
.donut(true)
|
||||
.showLegend(false)
|
||||
.showLabels(false)
|
||||
.color(['#DDD','#7C7BAD'])
|
||||
.color(['#7C7BAD','#DDD'])
|
||||
.donutRatio(0.62);
|
||||
|
||||
d3.select(svg)
|
||||
|
@ -5931,27 +5911,21 @@ instance.web.form.X2ManyCounter = instance.web.form.AbstractField.extend(instanc
|
|||
});
|
||||
|
||||
/**
|
||||
This field can be applied on many2many and one2many. It is a read-only field that will
|
||||
display a simple string "<number of linked records> <label of the field>" (obviously inspired by X2ManyCounter)
|
||||
This widget is intended to be used on stat button numeric fields. It will display
|
||||
the value many2many and one2many. It is a read-only field that will
|
||||
display a simple string "<value of field> <label of the field>"
|
||||
*/
|
||||
instance.web.form.X2Many = instance.web.form.AbstractField.extend(instance.web.form.ReinitializeFieldMixin, {
|
||||
instance.web.form.StatInfo = instance.web.form.AbstractField.extend({
|
||||
init: function() {
|
||||
this._super.apply(this, arguments);
|
||||
this.set("value", []);
|
||||
this.set("value", 0);
|
||||
},
|
||||
render_value: function() {
|
||||
var text = _.str.sprintf("%d %s", this.val().length, this.string);
|
||||
this.$().html(QWeb.render("X2Many", {text: text}));
|
||||
var text = _.str.sprintf("%d %s", this.get("value") || 0, this.string);
|
||||
this.$().html(QWeb.render("StatInfo", {text: text}));
|
||||
},
|
||||
val: function() {
|
||||
var value = this.get("value") || [];
|
||||
if (value.length >= 1 && value[0] instanceof Array) {
|
||||
value = value[0][2];
|
||||
}
|
||||
return value;
|
||||
},
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Registry of form fields, called by :js:`instance.web.FormView`.
|
||||
|
@ -5991,7 +5965,7 @@ instance.web.form.widgets = new instance.web.Registry({
|
|||
'monetary': 'instance.web.form.FieldMonetary',
|
||||
'many2many_checkboxes': 'instance.web.form.FieldMany2ManyCheckBoxes',
|
||||
'x2many_counter': 'instance.web.form.X2ManyCounter',
|
||||
'x2many': 'instance.web.form.X2Many',
|
||||
'statinfo': 'instance.web.form.StatInfo',
|
||||
});
|
||||
|
||||
/**
|
||||
|
@ -6002,7 +5976,6 @@ instance.web.form.widgets = new instance.web.Registry({
|
|||
*/
|
||||
instance.web.form.tags = new instance.web.Registry({
|
||||
'button' : 'instance.web.form.WidgetButton',
|
||||
'statbutton' : 'instance.web.form.StatButton',
|
||||
});
|
||||
|
||||
instance.web.form.custom_widgets = new instance.web.Registry({
|
||||
|
|
|
@ -1356,24 +1356,26 @@
|
|||
</div>
|
||||
</t>
|
||||
<t t-name="WidgetButton">
|
||||
<button type="button" class="oe_button oe_form_button"
|
||||
t-att-style="widget.node.attrs.style"
|
||||
t-att-tabindex="widget.node.attrs.tabindex"
|
||||
t-att-autofocus="widget.node.attrs.autofocus"
|
||||
t-att-accesskey="widget.node.attrs.accesskey">
|
||||
<img t-if="widget.node.attrs.icon" t-att-src="_s + widget.node.attrs.icon" width="16" height="16"/>
|
||||
<span t-if="widget.string"><t t-esc="widget.string"/></span>
|
||||
</button>
|
||||
</t>
|
||||
<t t-name="StatButton">
|
||||
<label type="button" class="oe_stat_button btn btn-default"
|
||||
t-att-style="widget.node.attrs.style"
|
||||
t-att-tabindex="widget.node.attrs.tabindex"
|
||||
t-att-autofocus="widget.node.attrs.autofocus"
|
||||
t-att-accesskey="widget.node.attrs.accesskey">
|
||||
<t t-if="widget.icon"><div class="stat_button_icon"><t t-raw="widget.icon"/></div></t>
|
||||
<span t-if="widget.string"><t t-esc="widget.string"/></span>
|
||||
</label>
|
||||
<t t-if="!widget.is_stat_button">
|
||||
<button type="button" class="oe_button oe_form_button"
|
||||
t-att-style="widget.node.attrs.style"
|
||||
t-att-tabindex="widget.node.attrs.tabindex"
|
||||
t-att-autofocus="widget.node.attrs.autofocus"
|
||||
t-att-accesskey="widget.node.attrs.accesskey">
|
||||
<img t-if="widget.node.attrs.icon" t-att-src="_s + widget.node.attrs.icon" width="16" height="16"/>
|
||||
<span t-if="widget.string"><t t-esc="widget.string"/></span>
|
||||
</button>
|
||||
</t>
|
||||
<t t-if="widget.is_stat_button">
|
||||
<label type="button" class="oe_stat_button btn btn-default"
|
||||
t-att-style="widget.node.attrs.style"
|
||||
t-att-tabindex="widget.node.attrs.tabindex"
|
||||
t-att-autofocus="widget.node.attrs.autofocus"
|
||||
t-att-accesskey="widget.node.attrs.accesskey">
|
||||
<t t-if="widget.icon"><div class="stat_button_icon"><t t-raw="widget.icon"/></div></t>
|
||||
<span t-if="widget.string"><t t-esc="widget.string"/></span>
|
||||
</label>
|
||||
</t>
|
||||
</t>
|
||||
<t t-name="WidgetButton.tooltip" t-extend="WidgetLabel.tooltip">
|
||||
<t t-jquery="div.oe_tooltip_string" t-operation="replace">
|
||||
|
@ -1945,7 +1947,7 @@
|
|||
<t t-name="X2ManyCounter">
|
||||
<a href="javascript:void(0)"><t t-esc="text"/></a>
|
||||
</t>
|
||||
<t t-name="X2Many">
|
||||
<t t-name="StatInfo">
|
||||
<div><t t-esc="text"/></div>
|
||||
</t>
|
||||
</templates>
|
||||
|
|
Loading…
Reference in New Issue