From ae6c6eb8ec1a00071045581f45be754783160b72 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 3 Jul 2012 12:27:50 +0200 Subject: [PATCH] [ADD] save button instead of selector during edition bzr revid: xmo@openerp.com-20120703102750-1vmoljtbrnnl3lzo --- addons/web/static/src/css/base.css | 14 ++++++++++++++ addons/web/static/src/css/base.sass | 9 +++++++-- addons/web/static/src/js/view_list_editable.js | 18 +++++++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 41d48432559..6061113642a 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2115,6 +2115,20 @@ .openerp .oe-listview-content .numeric input { text-align: right; } +.openerp .oe-listview-content tr.oe_edition th.oe-record-selector { + padding: 0 6px; + font-size: 1px; + letter-spacing: -1px; + color: transparent; +} +.openerp .oe-listview-content tr.oe_edition th.oe-record-selector:before { + font: 21px "mnmliconsRegular"; + content: "S"; + color: #404040; +} +.openerp .oe-listview-content tr.oe_edition th.oe-record-selector input { + display: none; +} .openerp .oe_trad_field.touched { border: 1px solid green !important; } diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 7135b474aa3..a55d1155859 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -83,9 +83,8 @@ $colour4: #8a89ba letter-spacing: -1px color: transparent &:before - font-family: "mnmliconsRegular" + font: 21px "mnmliconsRegular" content: $icon-name - font-size: 20px color: $color // }}} @@ -1667,6 +1666,12 @@ $colour4: #8a89ba width: 82px input text-align: right + + tr.oe_edition th.oe-record-selector + padding: 0 6px + @include text-to-icon("S") + input + display: none // }}} // Translation {{{ .oe_trad_field.touched diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 0d88ddf6dee..1c477046c2b 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -169,6 +169,8 @@ openerp.web.list_editable = function (instance) { }); }], [record.attributes]); + }).then(function () { + $recordRow.addClass('oe_edition') }); }, getCellsFor: function ($row) { @@ -343,7 +345,6 @@ openerp.web.list_editable = function (instance) { return form.do_show({reload: false}); }).pipe(function () { self.record = record; - // TODO: [Save] button // TODO: save on action button? _(form.fields).each(function (field, name) { configureField(name, field); @@ -412,6 +413,21 @@ openerp.web.list_editable = function (instance) { }); instance.web.ListView.List.include(/** @lends instance.web.ListView.List# */{ + init: function () { + var self = this; + this._super.apply(this, arguments); + var selection_handler = _.find(this.$_element.data('events').click, function (h) { + return h.selector === 'th.oe-record-selector'; + }).handler; + // TODO: cleaner way to do that? + this.$_element + .off('click', 'th.oe-record-selector') + .on('click', '.oe_edition th.oe-record-selector', function (e) { + e.stopImmediatePropagation(); + self.view.saveEdition(); + }) + .on('click', 'th.oe-record-selector', selection_handler); + }, row_clicked: function (event) { if (!this.options.editable) { return this._super.apply(this, arguments);