[FIX] web: form view: priority and kanban widgets cleaning, now more like classic...
authorThibault Delavallée <tde@openerp.com>
Fri, 8 Aug 2014 14:59:48 +0000 (16:59 +0200)
committerThibault Delavallée <tde@openerp.com>
Mon, 11 Aug 2014 08:44:21 +0000 (10:44 +0200)
addons/web/static/src/css/base.css
addons/web/static/src/css/base.sass
addons/web/static/src/js/view_form.js
addons/web/static/src/xml/base.xml
addons/web_kanban/static/src/js/kanban.js

index 00a1959..cf90e64 100644 (file)
@@ -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");
   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;
 }
index 29eec8f..7834bf8 100644 (file)
@@ -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
     // }}}
index 66e5005..41bc044 100644 (file)
@@ -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();
index 2aeed9e..e2a6f85 100644 (file)
     <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>
         <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>
 <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>
index e6a4b0d..d67fe52 100644 (file)
@@ -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;