diff options
| author | Xavier Morel <xmo@openerp.com> | 2012-07-10 16:32:28 +0200 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2012-07-10 16:32:28 +0200 |
| commit | 46da3547cabfeb8e8ab3c501f2049c2046a9bcb3 (patch) | |
| tree | ab7db8a2cfddb985a7cfd26cdc9a1c79060cae89 /addons/web/static/src | |
| parent | 5b6df7ebebbc80c83ed094388f7b85459dae8668 (diff) | |
[IMP] move saving a row from per-row buttons to a single global button replacing [Create]
bzr revid: xmo@openerp.com-20120710143228-mqfuaxw894x9khkc
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/css/base.css | 23 | ||||
| -rw-r--r-- | addons/web/static/src/css/base.sass | 15 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list.js | 2 | ||||
| -rw-r--r-- | addons/web/static/src/js/view_list_editable.js | 38 | ||||
| -rw-r--r-- | addons/web/static/src/xml/base.xml | 13 |
5 files changed, 41 insertions, 50 deletions
diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 6061113642a..8a2020cba47 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -1999,6 +1999,15 @@ .openerp .oe_form .oe_form_field_many2many > .oe-listview .oe_list_pager_single_page { display: none; } +.openerp .oe_list_buttons .oe_list_save { + display: none; +} +.openerp .oe_list_buttons.oe_editing .oe_list_add, .openerp .oe_list_buttons.oe_editing .oe_alternative { + display: none; +} +.openerp .oe_list_buttons.oe_editing .oe_list_save { + display: inline-block; +} .openerp .oe-listview { position: relative; } @@ -2115,20 +2124,6 @@ .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 a55d1155859..9377c11e2c2 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -1587,6 +1587,15 @@ $colour4: #8a89ba display: none // }}} // ListView {{{ + .oe_list_buttons + .oe_list_save + display: none + &.oe_editing + .oe_list_add, .oe_alternative + display: none + .oe_list_save + display: inline-block + .oe-listview position: relative .oe_form .oe_form_field @@ -1666,12 +1675,6 @@ $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.js b/addons/web/static/src/js/view_list.js index 27b39a40b22..aa7ffdb66d4 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -285,7 +285,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi } this.$buttons.find('.oe_list_add') .click(this.proxy('do_add_record')) - .prop('disabled', grouped && this.options.editable); + .prop('disabled', grouped); this.$buttons.on('click', '.oe_list_button_import', function() { self.on_sidebar_import(); return false; diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 61ee6698452..7bc12b325fc 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -29,7 +29,14 @@ openerp.web.list_editable = function (instance) { self.configure_pager(self.dataset); self.compute_aggregates(); } - }) + }); + + this.on('edit:after', this, function () { + self.$element.add(self.$buttons).addClass('oe_editing'); + }); + this.on('save:after cancel:after', this, function () { + self.$element.add(self.$buttons).removeClass('oe_editing'); + }); }, destroy: function () { instance.web.bus.off('resize', this, this.resizeFields); @@ -93,6 +100,10 @@ openerp.web.list_editable = function (instance) { this.options.editable = ! this.options.read_only && (data.arch.attrs.editable || this.options.editable); var result = this._super(data, grouped); if (this.options.editable) { + // FIXME: any hook available to ensure this is only done once? + this.$buttons + .off('click', 'button.oe_list_save') + .on('click', 'button.oe_list_save', this.proxy('saveEdition')); // Editor is not restartable due to formview not being // restartable this.editor = this.makeEditor(); @@ -498,33 +509,12 @@ 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); } - this.edit_record($(event.currentTarget).data('id')); - }, - /** - * Edits record currently selected via dataset - */ - edit_record: function (record_id) { - return this.view.startEdition( - record_id ? this.records.get(record_id) : null); + var record_id = $(event.currentTarget).data('id'); + this.view.startEdition(record_id ? this.records.get(record_id) : null); }, /** * If a row mapping to the record (@data-id matching the record's id or diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 66a1c02e448..ec5f9c6d9de 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -619,7 +619,9 @@ <button type="button" class="oe_button oe_list_add oe_highlight"> <t t-esc="widget.options.addable"/> </button> - <span class="oe_fade">or</span> <a href="#" class="oe_bold oe_list_button_import">Import</a> + <span class="oe_alternative"> + <span class="oe_fade">or</span> <a href="#" class="oe_bold oe_list_button_import">Import</a> + </span> </t> </div> <t t-name="ListView.pager"> @@ -663,10 +665,11 @@ </td> </tr> -<t t-name="ListView.row.save"> - <td> - <button class='oe_i oe-edit-row-save' type='button' name='save'>S</button> - </td> +<t t-extend="ListView.buttons"> + <t t-jquery="button.oe_list_add" t-operation="after"> + <button class="oe_button oe_list_save oe_highlight" + type="button">Save Row</button> + </t> </t> <t t-name="FormView"> |
