diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 00a195900849a58fef9acea9a8552406ebbd7b0f..cf90e649f960745d330cb14cc66fd79b105132b3 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1,4 +1,4 @@ -@charset "UTF-8"; +@charset "utf-8"; @font-face { font-family: "mnmliconsRegular"; src: url("/web/static/src/font/mnmliconsv21-webfont.eot") format("eot"); @@ -549,14 +549,6 @@ padding-top: 8px; margin-right: 4px !important; } -.openerp .btn-group.kanban_state .dropdown-menu { - min-width: 100%; - padding-right: 10px !important; -} -.openerp .btn-group.kanban_state .dropdown-menu li a, .openerp .btn-group.kanban_state .dropdown-menu li a:hover, .openerp .btn-group.kanban_state .dropdown-menu li a:focus { - padding-left: 5px; - padding-right: 0px; -} .openerp .btn-group.kanban_state a { color: #333333; } diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 29eec8fabb947fd0a07124b56f833557aadf4cc7..7834bf88ede555eb72bee9e4c9f3c3d24f5ae09b 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -498,12 +498,6 @@ $sheet-padding: 16px .btn-group.kanban_state padding-top: 8px margin-right: 4px !important - .dropdown-menu - min-width: 100% - padding-right: 10px !important - .dropdown-menu li a, .dropdown-menu li a:hover, .dropdown-menu li a:focus - padding-left: 5px - padding-right: 0px a color: #333333 // }}} diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 66e500507d9cf3772fb5627cf1671993a8cff5ba..41bc0447756d8d0d00d9e26d05db42688337ab12 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2335,26 +2335,31 @@ instance.web.form.KanbanSelection = instance.web.form.FieldChar.extend({ }, render_value: function() { var self = this; - this.record_id = self.view.datarecord.id; - this.states = self.prepare_dropdown_selection();; + this.record_id = this.view.datarecord.id; + this.states = this.prepare_dropdown_selection();; this.$el.html(QWeb.render("KanbanSelection", {'widget': self})); - this.$el.find('.oe_legend').click(self.do_action.bind(self)); + this.$el.find('li').on('click', this.set_kanban_selection.bind(this)); }, - do_action: function(e) { + /* setting the value: in view mode, perform an asynchronous call and reload + the form view; in edit mode, use set_value to save the new value that will + be written when saving the record. */ + set_kanban_selection: function (ev) { var self = this; - var li = $(e.target).closest( "li" ); + var li = $(ev.target).closest('li'); if (li.length) { - var value = {}; - value[self.name] = String(li.data('value')); - self.record_id = self.view.datarecord.id; - if (self.record_id) { - return self.view.dataset._model.call('write', [[self.record_id], value, self.view.dataset.get_context()]).done(self.reload_record.bind(self)); - } else { - return self.view.on_button_save().done(function(result) { - if (result) { - self.view.dataset._model.call('write', [[result], value, self.view.dataset.get_context()]).done(self.reload_record.bind(self)); - } - }); + var value = String(li.data('value')); + if (this.view.get('actual_mode') == 'view') { + var write_values = {} + write_values[self.name] = value; + return this.view.dataset._model.call( + 'write', [ + [self.record_id], + write_values, + self.view.dataset.get_context() + ]).done(self.reload_record.bind(self)); + } + else { + return this.set_value(value); } } }, @@ -2386,27 +2391,34 @@ instance.web.form.Priority = instance.web.form.FieldChar.extend({ }, render_value: function() { var self = this; - this.record_id = self.view.datarecord.id; - this.priorities = self.prepare_priority(); + this.record_id = this.view.datarecord.id; + this.priorities = this.prepare_priority(); this.$el.html(QWeb.render("Priority", {'widget': this})); - this.$el.find('.oe_legend').click(self.do_action.bind(self)); + this.$el.find('li').on('click', this.set_priority.bind(this)); }, - do_action: function(e) { + /* setting the value: in view mode, perform an asynchronous call and reload + the form view; in edit mode, use set_value to save the new value that will + be written when saving the record. */ + set_priority: function (ev) { var self = this; - var li = $(e.target).closest( "li" ); + var li = $(ev.target).closest('li'); if (li.length) { - var value = {}; - value[self.name] = String(li.data('value')); - if (self.record_id) { - return self.view.dataset._model.call('write', [[self.record_id], value, self.view.dataset.get_context()]).done(self.reload_record.bind(self)); - } else { - return self.view.on_button_save().done(function(result) { - if (result) { - self.view.dataset._model.call('write', [[result], value, self.view.dataset.get_context()]).done(self.reload_record.bind(self)); - } - }); + var value = String(li.data('value')); + if (this.view.get('actual_mode') == 'view') { + var write_values = {} + write_values[self.name] = value; + return this.view.dataset._model.call( + 'write', [ + [self.record_id], + write_values, + self.view.dataset.get_context() + ]).done(self.reload_record.bind(self)); + } + else { + return this.set_value(value); } } + }, reload_record: function() { this.view.reload(); diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 2aeed9e60174da997765681d4f8f3d973cfe4fa3..e2a6f85a328823281546007ee2c52c23652c1344 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -962,7 +962,7 @@ <div class="btn-group kanban_state"> <t t-foreach="widget.states" t-as="rec"> <a t-if="widget.get('value') === rec.name"> - <a class="oe_legend dropdown-toggle" data-toggle="dropdown"> + <a class="dropdown-toggle" data-toggle="dropdown"> <span t-att-class="rec.state_class" t-if="widget.get('value') === rec.name" t-att-title="rec.tooltip"/> <span class="sr-only">Toggle Dropdown</span> </a> @@ -971,7 +971,7 @@ <ul class="dropdown-menu state" role="menu"> <t t-foreach="widget.states" t-as="rec"> <t t-if="widget.get('value') !== rec.name"> - <li class="oe_legend" t-att-data-value="rec.name" ><a href="#"> + <li t-att-data-value="rec.name" ><a href="#"> <span t-att-class="rec.state_class" t-att-title="rec.tooltip"/> <t t-raw="rec.state_name" /></a> </li> @@ -983,7 +983,7 @@ <t t-name="Priority"> <ul style="list-style: none; padding-left: 2px; display: inline-block;"> <t t-foreach="widget.priorities" t-as="rec" > - <li t-att-data-value="rec.click_value" class="oe_legend" style="display: inline-block;"> + <li t-att-data-value="rec.click_value" style="display: inline-block;"> <a href="#" t-att-title="rec.name"> <span t-att-class="widget.get('value') gte rec.value and 'oe_e oe_star_on' or 'oe_e oe_star_off'">7</span> </a> diff --git a/addons/web_kanban/static/src/js/kanban.js b/addons/web_kanban/static/src/js/kanban.js index e6a4b0dd1eb18999c4660921cdf9a4994f473754..d67fe5272609dd94d81e674ffadc6f32a52e6487 100644 --- a/addons/web_kanban/static/src/js/kanban.js +++ b/addons/web_kanban/static/src/js/kanban.js @@ -1295,7 +1295,7 @@ instance.web_kanban.Priority = instance.web_kanban.AbstractField.extend({ this.record_id = self.parent.id; this.priorities = self.prepare_priority(); this.$el = $(QWeb.render("Priority", {'widget': this})); - this.$el.find('.oe_legend').click(self.do_action.bind(self)); + this.$el.find('li').click(self.do_action.bind(self)); }, do_action: function(e) { var self = this; @@ -1337,7 +1337,7 @@ instance.web_kanban.KanbanSelection = instance.web_kanban.AbstractField.extend({ this.record_id = self.parent.id; this.states = self.prepare_dropdown_selection();; this.$el = $(QWeb.render("KanbanSelection", {'widget': self})); - this.$el.find('.oe_legend').click(self.do_action.bind(self)); + this.$el.find('li').click(self.do_action.bind(self)); }, do_action: function(e) { var self = this;