[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() {
|
$('button', doc).each(function() {
|
||||||
$(this).attr('data-button-type', $(this).attr('type')).attr('type', 'button');
|
$(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...
|
// IE's html parser is also a css parser. How convenient...
|
||||||
$('board', doc).each(function() {
|
$('board', doc).each(function() {
|
||||||
$(this).attr('layout', $(this).attr('style'));
|
$(this).attr('layout', $(this).attr('style'));
|
||||||
|
@ -1310,7 +1307,7 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt
|
||||||
var tagname = $tag[0].nodeName.toLowerCase();
|
var tagname = $tag[0].nodeName.toLowerCase();
|
||||||
if (this.tags_registry.contains(tagname)) {
|
if (this.tags_registry.contains(tagname)) {
|
||||||
this.tags_to_init.push($tag);
|
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];
|
var fn = self['process_' + tagname];
|
||||||
if (fn) {
|
if (fn) {
|
||||||
|
@ -1327,16 +1324,13 @@ instance.web.form.FormRenderingEngine = instance.web.form.FormRenderingEngineInt
|
||||||
return $tag;
|
return $tag;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
process_statbutton: function ($button) {
|
process_button: function ($button) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if ($button.children().length) {
|
$button.children().each(function() {
|
||||||
$button.children().each(function() {
|
self.process($(this));
|
||||||
self.process($(this));
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
return $button;
|
return $button;
|
||||||
},
|
},
|
||||||
|
|
||||||
process_widget: function($widget) {
|
process_widget: function($widget) {
|
||||||
this.widgets_to_init.push($widget);
|
this.widgets_to_init.push($widget);
|
||||||
return $widget;
|
return $widget;
|
||||||
|
@ -1922,6 +1916,8 @@ instance.web.form.WidgetButton = instance.web.form.FormWidget.extend({
|
||||||
template: 'WidgetButton',
|
template: 'WidgetButton',
|
||||||
init: function(field_manager, node) {
|
init: function(field_manager, node) {
|
||||||
node.attrs.type = node.attrs['data-button-type'];
|
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._super(field_manager, node);
|
||||||
this.force_disabled = false;
|
this.force_disabled = false;
|
||||||
this.string = (this.node.attrs.string || '').replace(/_/g, '');
|
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.
|
* Interface to be implemented by fields.
|
||||||
*
|
*
|
||||||
|
@ -2857,7 +2837,7 @@ instance.web.form.FieldPercentPie = instance.web.form.AbstractField.extend({
|
||||||
.donut(true)
|
.donut(true)
|
||||||
.showLegend(false)
|
.showLegend(false)
|
||||||
.showLabels(false)
|
.showLabels(false)
|
||||||
.color(['#DDD','#7C7BAD'])
|
.color(['#7C7BAD','#DDD'])
|
||||||
.donutRatio(0.62);
|
.donutRatio(0.62);
|
||||||
|
|
||||||
d3.select(svg)
|
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
|
This widget is intended to be used on stat button numeric fields. It will display
|
||||||
display a simple string "<number of linked records> <label of the field>" (obviously inspired by X2ManyCounter)
|
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() {
|
init: function() {
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
this.set("value", []);
|
this.set("value", 0);
|
||||||
},
|
},
|
||||||
render_value: function() {
|
render_value: function() {
|
||||||
var text = _.str.sprintf("%d %s", this.val().length, this.string);
|
var text = _.str.sprintf("%d %s", this.get("value") || 0, this.string);
|
||||||
this.$().html(QWeb.render("X2Many", {text: text}));
|
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`.
|
* 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',
|
'monetary': 'instance.web.form.FieldMonetary',
|
||||||
'many2many_checkboxes': 'instance.web.form.FieldMany2ManyCheckBoxes',
|
'many2many_checkboxes': 'instance.web.form.FieldMany2ManyCheckBoxes',
|
||||||
'x2many_counter': 'instance.web.form.X2ManyCounter',
|
'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({
|
instance.web.form.tags = new instance.web.Registry({
|
||||||
'button' : 'instance.web.form.WidgetButton',
|
'button' : 'instance.web.form.WidgetButton',
|
||||||
'statbutton' : 'instance.web.form.StatButton',
|
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.web.form.custom_widgets = new instance.web.Registry({
|
instance.web.form.custom_widgets = new instance.web.Registry({
|
||||||
|
|
|
@ -1356,24 +1356,26 @@
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
<t t-name="WidgetButton">
|
<t t-name="WidgetButton">
|
||||||
<button type="button" class="oe_button oe_form_button"
|
<t t-if="!widget.is_stat_button">
|
||||||
t-att-style="widget.node.attrs.style"
|
<button type="button" class="oe_button oe_form_button"
|
||||||
t-att-tabindex="widget.node.attrs.tabindex"
|
t-att-style="widget.node.attrs.style"
|
||||||
t-att-autofocus="widget.node.attrs.autofocus"
|
t-att-tabindex="widget.node.attrs.tabindex"
|
||||||
t-att-accesskey="widget.node.attrs.accesskey">
|
t-att-autofocus="widget.node.attrs.autofocus"
|
||||||
<img t-if="widget.node.attrs.icon" t-att-src="_s + widget.node.attrs.icon" width="16" height="16"/>
|
t-att-accesskey="widget.node.attrs.accesskey">
|
||||||
<span t-if="widget.string"><t t-esc="widget.string"/></span>
|
<img t-if="widget.node.attrs.icon" t-att-src="_s + widget.node.attrs.icon" width="16" height="16"/>
|
||||||
</button>
|
<span t-if="widget.string"><t t-esc="widget.string"/></span>
|
||||||
</t>
|
</button>
|
||||||
<t t-name="StatButton">
|
</t>
|
||||||
<label type="button" class="oe_stat_button btn btn-default"
|
<t t-if="widget.is_stat_button">
|
||||||
t-att-style="widget.node.attrs.style"
|
<label type="button" class="oe_stat_button btn btn-default"
|
||||||
t-att-tabindex="widget.node.attrs.tabindex"
|
t-att-style="widget.node.attrs.style"
|
||||||
t-att-autofocus="widget.node.attrs.autofocus"
|
t-att-tabindex="widget.node.attrs.tabindex"
|
||||||
t-att-accesskey="widget.node.attrs.accesskey">
|
t-att-autofocus="widget.node.attrs.autofocus"
|
||||||
<t t-if="widget.icon"><div class="stat_button_icon"><t t-raw="widget.icon"/></div></t>
|
t-att-accesskey="widget.node.attrs.accesskey">
|
||||||
<span t-if="widget.string"><t t-esc="widget.string"/></span>
|
<t t-if="widget.icon"><div class="stat_button_icon"><t t-raw="widget.icon"/></div></t>
|
||||||
</label>
|
<span t-if="widget.string"><t t-esc="widget.string"/></span>
|
||||||
|
</label>
|
||||||
|
</t>
|
||||||
</t>
|
</t>
|
||||||
<t t-name="WidgetButton.tooltip" t-extend="WidgetLabel.tooltip">
|
<t t-name="WidgetButton.tooltip" t-extend="WidgetLabel.tooltip">
|
||||||
<t t-jquery="div.oe_tooltip_string" t-operation="replace">
|
<t t-jquery="div.oe_tooltip_string" t-operation="replace">
|
||||||
|
@ -1945,7 +1947,7 @@
|
||||||
<t t-name="X2ManyCounter">
|
<t t-name="X2ManyCounter">
|
||||||
<a href="javascript:void(0)"><t t-esc="text"/></a>
|
<a href="javascript:void(0)"><t t-esc="text"/></a>
|
||||||
</t>
|
</t>
|
||||||
<t t-name="X2Many">
|
<t t-name="StatInfo">
|
||||||
<div><t t-esc="text"/></div>
|
<div><t t-esc="text"/></div>
|
||||||
</t>
|
</t>
|
||||||
</templates>
|
</templates>
|
||||||
|
|
Loading…
Reference in New Issue