[IMP] web_kanban: introduce field style attributes

The attribute `display` can now be set on a field in kanban.

The two possible values are
 * full: full-width field
 * right: pull-right field

The `bold` attribute is also handled with a class and not a
<strong> tag to be consistent.
This commit is contained in:
Martin Geubelle
2017-01-19 11:58:05 +01:00
parent 30958db502
commit 577311c0e1
3 changed files with 40 additions and 13 deletions
@@ -78,9 +78,24 @@ var KanbanRecord = Widget.extend({
var widget = new Widget(self, field, $field);
widget.replace($field);
self.sub_widgets.push(widget);
self._set_field_display(widget, field);
});
},
_set_field_display: function(widget, field) {
// attribute display
if (field.__attrs.display === 'right') {
widget.$el.addClass('pull-right');
} else if (field.__attrs.display === 'full') {
widget.$el.addClass('o_text_block');
}
// attribute bold
if (field.__attrs.bold) {
widget.$el.addClass('o_text_bold');
}
},
start: function() {
var self = this;
this.add_widgets();
+19 -13
View File
@@ -812,20 +812,26 @@ function transform_qweb_template (node, fvg, many2manys) {
} else if (fields_registry.contains(ftype)) {
// do nothing, the kanban record will handle it
} else {
if (node.attrs.bold) {
node.tag = 'strong';
var children_node = {
attrs: {},
children: [],
tag: qweb.prefix,
};
children_node.attrs[qweb.prefix + '-esc'] = 'record.' + node.attrs.name + '.value';
node.children.push(children_node);
} else {
node.tag = qweb.prefix;
node.attrs[qweb.prefix + '-esc'] = 'record.' + node.attrs.name + '.value';
}
node.tag = 'span';
var child_node = {
attrs: {},
children: [],
tag: qweb.prefix,
};
child_node.attrs[qweb.prefix + '-esc'] = 'record.' + node.attrs.name + '.value';
node.children.push(child_node);
// set class according to field attribute
var child_classes = [];
if (node.attrs.display === 'right') {
child_classes.push('pull-right');
} else if (node.attrs.display === 'full') {
child_classes.push('o_text_block');
}
if (node.attrs.bold) {
child_classes.push('o_text_bold');
}
node.attrs['class'] = child_classes.join(' ');
}
break;
case 'button':
@@ -130,6 +130,12 @@
color: #A61300;
font-weight: bold;
}
.o_text_bold {
font-weight: bold;
}
.o_text_block {
display: block;
}
}
.o_kanban_quick_create {