'widget': self,
'legend_value': legend_value,
});
- self.$el.html(content);
- self.$el.find("li").click(self.execute_action.bind(self));
+ this.$el.html(content);
+ this.$el.find('li').click(self.execute_action.bind(self));
},
execute_action: function(e){
- e.preventDefault();
var self = this;
- $this = $(e.target)
- var value = $this.data('value') || $this.parent().data('value');
- return this.view.dataset.call_button(self.options.action, [this.view.datarecord.id, value, this.view.dataset.get_context()]).done(function(r) {
- self.view.reload();
- });
+ var li = $(e.target).closest( "li" );
+ if (li.length){
+ var value = li.data('value');
+ return this.view.dataset.call_button(self.options.action, [this.view.datarecord.id, value, this.view.dataset.get_context()]).done(function(r) {
+ self.view.reload();
+ });
+ }
}
});
instance.web.form.FieldID = instance.web.form.FieldChar.extend({
<ul class="dropdown-menu with-arrow">
<t t-foreach="widget.get('value')" t-as="rec">
<t t-if="legend_value !== rec.name">
- <li><a t-att-data-value="rec.name" href="#"><t t-raw="rec.body" /><t t-raw="rec.legend_name" /></a></li>
+ <li t-att-data-value="rec.name"><a href="#"><t t-raw="rec.body" /><t t-raw="rec.legend_name" /></a></li>
</t>
</t>
</ul>
<ul style="list-style: none; padding-left: 5px;">
<t t-foreach="widget.get('value')" t-as="test" >
<t t-if="legend_value gte test.name and !test_first">
- <li class="oe_left"><a t-att-data-value="test.name - 1" href="#"><t t-raw="test.body"/></a></li>
+ <li t-att-data-value="test.name - 1" class="oe_left"><a href="#"><t t-raw="test.body"/></a></li>
</t>
</t>
<t t-foreach="widget.get('value')" t-as="test" >
<t t-if="legend_value lt test.name">
- <li class="oe_left"><a t-att-data-value="test.name" href="#"><t t-raw="widget.get('value')[0].body"/></a></li>
+ <li t-att-data-value="test.name" class="oe_left"><a href="#"><t t-raw="widget.get('value')[0].body"/></a></li>
</t>
</t>
</ul>
},
});
+instance.web_kanban.Legend = instance.web_kanban.AbstractField.extend({
+ init: function(parent, field, $node) {
+ this._super.apply(this, arguments);
+ this.parent = parent;
+ this.name = $node.attr('name')
+ },
+ renderElement: function() {
+ var self = this;
+ var legend_field = this.options.legend_field;
+ var legend_field_value = this.parent.record[legend_field].raw_value
+ var content = QWeb.render("Legend." + self.name, {
+ 'widget': self,
+ 'legend_value': legend_field_value,
+ });
+ this.$el.html(content);
+ this.$el.click(self.execute_action.bind(self));
+ },
+ execute_action: function(e){
+ e.preventDefault();
+ var li = $(e.target).closest( "li" );
+ if (li.length){
+ var parent = this.parent
+ var value = li.data('value');
+ return parent.view.dataset.call_button(this.options.action, [parent.id, value, parent.view.dataset.get_context()]).done(function(r) {
+ parent.do_reload();
+ });
+ }
+ }
+});
+
+
instance.web_kanban.fields_registry = new instance.web.Registry({});
+instance.web_kanban.fields_registry.add('legend','instance.web_kanban.Legend');
};
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax: