From 5d5a8e85c223060262ce55073cf7d38db02870d4 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 17 Oct 2012 13:07:50 +0200 Subject: [PATCH 01/10] [FIX] group_by_no_leaf handling bzr revid: xmo@openerp.com-20121017110750-vrtx04b40e4kralm --- addons/web/static/src/js/data.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/web/static/src/js/data.js b/addons/web/static/src/js/data.js index 77583899bf1..30a8b9862fc 100644 --- a/addons/web/static/src/js/data.js +++ b/addons/web/static/src/js/data.js @@ -120,6 +120,10 @@ instance.web.Query = instance.web.Class.extend({ if (_.isEmpty(grouping)) { return null; } var self = this; + + // FIXME: when pyeval is merged + var ctx = instance.session.test_eval_contexts( + [this._model.context(this._context)]); return this._model.call('read_group', { groupby: grouping, fields: _.uniq(grouping.concat(this._fields || [])), @@ -130,6 +134,8 @@ instance.web.Query = instance.web.Class.extend({ orderby: instance.web.serialize_sort(this._order_by) || false }).pipe(function (results) { return _(results).map(function (result) { + // FIX: querygroup initialization + _.defaults(result.__context, ctx); return new instance.web.QueryGroup( self._model.name, grouping[0], result); }); From fa1aafa97d0c085e097245ae721007ce0261bae7 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 17 Oct 2012 13:58:45 +0200 Subject: [PATCH 02/10] [FIX] in-group pagination of list views bzr revid: xmo@openerp.com-20121017115845-9ch6icjjhrzycj84 --- addons/web/static/src/css/base.css | 4 +++- addons/web/static/src/css/base.sass | 2 ++ addons/web/static/src/js/view_list.js | 7 +++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 8925c3a0964..e62a01b4870 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -25,7 +25,6 @@ display: none !important; } } - .openerp.openerp_webclient_container { height: 100%; position: relative; @@ -2592,6 +2591,9 @@ min-width: 0 !important; max-width: none !important; } +.openerp .oe_list_group_name { + white-space: nowrap; +} .openerp .oe_form .oe_form_field_many2many > .oe_list .oe_list_pager_single_page { display: none; } diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index a1adfe67e75..2787535d3ab 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -2049,6 +2049,8 @@ $sheet-max-width: 860px .oe_form_field_float,.oe_form_view_integer,&.oe_form_field_datetime,&.oe_form_field_date min-width: 0 !important max-width: none !important + .oe_list_group_name + white-space: nowrap // }}} // FormView.many2many {{{ .oe_form .oe_form_field_many2many > .oe_list diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index a6aa637f655..de7f157c96d 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -1230,6 +1230,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we .replaceWith(self.render()); }); this.$row.children().last() + .addClass('oe_list_group_pagination') .append($prev) .append('') .append($next); @@ -1414,10 +1415,12 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we })) .end() .find('button[data-pager-action=previous]') - .attr('disabled', page === 0) + .css('visibility', + page === 0 ? 'hidden' : '') .end() .find('button[data-pager-action=next]') - .attr('disabled', page === pages - 1); + .css('visibility', + page === pages - 1 ? 'hidden' : ''); } } From 886767fbaa334a75f43d980eca1419a2801201bc Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 17 Oct 2012 14:16:01 +0200 Subject: [PATCH 03/10] [FIX] listview indicator positioning: position relative is UB on table elements bzr revid: xmo@openerp.com-20121017121601-g3kmxqxvoi447mkp --- addons/web/static/src/css/base.css | 15 +++++++++------ addons/web/static/src/css/base.sass | 12 +++++++----- addons/web/static/src/xml/base.xml | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index e62a01b4870..ab2b2d25322 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2653,14 +2653,17 @@ background: #eeeeee; vertical-align: top; } -.openerp .oe_list_content > thead th { - position: relative; -} .openerp .oe_list_content td, .openerp .oe_list_content th { padding: 3px 6px; line-height: 18px; } -.openerp .oe_list_content th:after { +.openerp .oe_list_content th.oe_sortable, .openerp .oe_list_content th.oe_sortable div { + cursor: pointer; +} +.openerp .oe_list_content th.oe_sortable div { + position: relative; +} +.openerp .oe_list_content th.oe_sortable div:after { position: absolute; right: 6px; content: ""; @@ -2670,12 +2673,12 @@ border-color: black transparent; visibility: hidden; } -.openerp .oe_list_content th.sortup:after { +.openerp .oe_list_content th.sortup div:after { visibility: visible; filter: alpha(opacity=60); opacity: 0.6; } -.openerp .oe_list_content th.sortdown:after { +.openerp .oe_list_content th.sortdown div:after { border-bottom: none; border-left: 4px solid transparent; border-right: 4px solid transparent; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 2787535d3ab..ecbd02d7cab 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -2100,12 +2100,14 @@ $sheet-max-width: 860px border-bottom: 2px solid #cacaca background: #eee vertical-align: top - th - position: relative td, th padding: 3px 6px line-height: 18px - th:after + th.oe_sortable, th.oe_sortable div + cursor: pointer + th.oe_sortable div + position: relative + th.oe_sortable div:after position: absolute right: 6px content: "" @@ -2114,10 +2116,10 @@ $sheet-max-width: 860px border-style: solid border-color: #000 transparent visibility: hidden - th.sortup:after + th.sortup div:after visibility: visible @include opacity(0.6) - th.sortdown:after + th.sortdown div:after border-bottom: none border-left: 4px solid transparent border-right: 4px solid transparent diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index b031ee172e2..06603ad17a5 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -631,9 +631,9 @@ + t-attf-class="oe_list_header_#{column.widget or column.type} #{((options.sortable and column.tag !== 'button') ? 'oe_sortable' : null)}">
- +
From 8e54c76845dc4bc7bffaa971ed7a4070a00eee65 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 17 Oct 2012 15:43:51 +0200 Subject: [PATCH 04/10] [FIX] fetching of table cells to match form inputs to Only fetch the table cells of the row being edited *after* having saved a pending edition. Otherwise, when re-editing the same record (e.g. click between buttons or on a readonly field), the cells are saved, the record is refreshed destroying the cells, and when trying to get the cell positions to position form fields correctly... the cells which don't exist anymore return 0, 0 as their position and nothing works correctly. bzr revid: xmo@openerp.com-20121017134351-lpmz27f1iemmsfoq --- addons/web/static/src/js/view_list_editable.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index cd6b018ea0d..3a3b06cbedf 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -190,10 +190,10 @@ openerp.web.list_editable = function (instance) { this.records.add(record, { at: this.prepends_on_create() ? 0 : null}); } - var $recordRow = this.groups.get_row_for(record); - var cells = this.get_cells_for($recordRow); return this.ensure_saved().pipe(function () { + var $recordRow = self.groups.get_row_for(record); + var cells = self.get_cells_for($recordRow); self.fields_for_resize.splice(0, self.fields_for_resize.length); return self.with_event('edit', { record: record.attributes, @@ -398,7 +398,6 @@ openerp.web.list_editable = function (instance) { setup_events: function () { var self = this; _.each(this.editor.form.fields, function(field, field_name) { - var field; var setting = false; var set_invisible = function() { if (!setting && field.get("effective_readonly")) { @@ -774,7 +773,7 @@ openerp.web.list_editable = function (instance) { return this._super.apply(this, arguments); } var record_id = $(event.currentTarget).data('id'); - this.view.start_edition( + return this.view.start_edition( record_id ? this.records.get(record_id) : null, { focus_field: $(event.target).data('field') }); From 47fbd98ff22e09c3a0e46916902990332161c2c1 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 17 Oct 2012 17:59:20 +0200 Subject: [PATCH 05/10] [FIX] basic inputs (e.g. float) in editable list views having size hardcoded to 7em bzr revid: xmo@openerp.com-20121017155920-lwmzlwbfthfzhluj --- addons/web/static/src/css/base.css | 4 ++-- addons/web/static/src/css/base.sass | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index ab2b2d25322..c75042068a9 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2579,10 +2579,10 @@ } .openerp .oe_list.oe_list_editable.oe_editing .oe_form_field.oe_form_field_float input, .openerp .oe_list.oe_list_editable.oe_editing .oe_form_field.oe_form_view_integer input { text-align: right; - width: 100%; + width: 100% !important; } .openerp .oe_list.oe_list_editable.oe_editing .oe_form_field.oe_form_field_datetime > span, .openerp .oe_list.oe_list_editable.oe_editing .oe_form_field.oe_form_field_date > span { - width: 100%; + width: 100% !important; } .openerp .oe_list.oe_list_editable.oe_editing .oe_form_field.oe_form_field_datetime input.oe_datepicker_master, .openerp .oe_list.oe_list_editable.oe_editing .oe_form_field.oe_form_field_date input.oe_datepicker_master { width: 100% !important; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index ecbd02d7cab..20d4be619ed 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -2040,10 +2040,10 @@ $sheet-max-width: 860px &.oe_form_field_float,&.oe_form_view_integer input text-align: right - width: 100% + width: 100% !important &.oe_form_field_datetime,&.oe_form_field_date > span - width: 100% + width: 100% !important input.oe_datepicker_master width: 100% !important .oe_form_field_float,.oe_form_view_integer,&.oe_form_field_datetime,&.oe_form_field_date From 0a23335aa731c8eef5bc5b90a6f2e765dd7fe52f Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 18 Oct 2012 08:37:03 +0200 Subject: [PATCH 06/10] [IMP] when editing a row, hide the list cells overlaid by form fields MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * visibility: hidden on the cell itself hides the whole cell including background and borders, looks terrible * color: transparent is supported by all supported browsers (even IE >= 9), and it avoids breaking the cell sizes (which the usual hack — text-indent -9999px does) * can probably just apply visibility:hidden to eveything below the cell itself bzr revid: xmo@openerp.com-20121018063703-scz1yl87b7nhgx94 --- addons/web/static/src/css/base.css | 6 ++++++ addons/web/static/src/css/base.sass | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index c75042068a9..e4b8885b1a1 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -2561,6 +2561,12 @@ .openerp .oe_list.oe_list_editable td.oe_list_record_delete { position: absolute; } +.openerp .oe_list.oe_list_editable.oe_editing .oe_edition .oe_list_field_cell:not(.oe_readonly) { + color: transparent; +} +.openerp .oe_list.oe_list_editable.oe_editing .oe_edition .oe_list_field_cell:not(.oe_readonly) * { + visibility: hidden; +} .openerp .oe_list.oe_list_editable.oe_editing .oe_m2o_drop_down_button { top: 5px; } diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index 20d4be619ed..a128fcec24b 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -2026,6 +2026,10 @@ $sheet-max-width: 860px td.oe_list_record_delete position: absolute .oe_list.oe_list_editable.oe_editing + .oe_edition .oe_list_field_cell:not(.oe_readonly) + * + visibility: hidden + color: transparent .oe_m2o_drop_down_button top: 5px .oe_m2o_cm_button From 8b2a07eb558af71a5132b748b34e4938fad227c3 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 18 Oct 2012 14:34:03 +0200 Subject: [PATCH 07/10] [REM] dead code bzr revid: xmo@openerp.com-20121018123403-k97t9x0hiie56f2n --- addons/web/static/src/js/search.js | 41 ------------------------------ 1 file changed, 41 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index a5e1aaeb3ae..8a6019be9d5 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -675,45 +675,6 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea return $.when(drawer_started, defaults_fetched) .then(function () { self.ready.resolve(); }) }, - /** - * Handle event when the user make a selection in the filters management select box. - */ - on_filters_management: function(e) { - var self = this; - var select = this.$el.find(".oe_search-view-filters-management"); - var val = select.val(); - switch(val) { - case 'advanced_filter': - this.extended_search.on_activate(); - break; - case '': - this.do_clear(); - } - if (val.slice(0, 4) == "get:") { - val = val.slice(4); - val = parseInt(val, 10); - var filter = this.managed_filters[val]; - this.do_clear(false).then(_.bind(function() { - select.val('get:' + val); - - var groupbys = []; - var group_by = filter.context.group_by; - if (group_by) { - groupbys = _.map( - group_by instanceof Array ? group_by : group_by.split(','), - function (el) { return { group_by: el }; }); - } - this.filter_data = { - domains: [filter.domain], - contexts: [filter.context], - groupbys: groupbys - }; - this.do_search(); - }, this)); - } else { - select.val(''); - } - }, /** * Extract search data from the view's facets. * @@ -771,8 +732,6 @@ instance.web.SearchView = instance.web.Widget.extend(/** @lends instance.web.Sea * * If at least one field failed its validation, triggers * :js:func:`instance.web.SearchView.on_invalid` instead. - * - * @param e jQuery event object coming from the "Search" button */ do_search: function (_query, options) { if (options && options.preventSearch) { From f910bc67804e185e486a8355b8ba329942a5c0eb Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 18 Oct 2012 14:40:05 +0200 Subject: [PATCH 08/10] [FIX] don't trigger search twice when a facet is removed from the query due to its values becoming empty The facet removal from its last value being removed (`this.remove(facet)` in the 'change' handler of the SearchQuery) broadcasted its `remove` event, triggering the `do_search` (and repaint) hook of the SearchView a second time right after the `change`-triggered search. Not only is this unnecessary and duplicated work (the `remove` is a sync operation, so searchview-attached events haven't yet executed by the time `remove` is called), the listview really doesn't like getting a ``search`` signal while it's already executing a search. So fix that. bzr revid: xmo@openerp.com-20121018124005-6vfi7tqasz32ai8v --- addons/web/static/src/js/search.js | 2 +- addons/web/static/test/search.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/search.js b/addons/web/static/src/js/search.js index 8a6019be9d5..80d5e57bd8f 100644 --- a/addons/web/static/src/js/search.js +++ b/addons/web/static/src/js/search.js @@ -61,7 +61,7 @@ my.SearchQuery = B.Collection.extend({ this.on('change', function (facet) { if(!facet.values.isEmpty()) { return; } - this.remove(facet); + this.remove(facet, {silent: true}); }, this); }, add: function (values, options) { diff --git a/addons/web/static/test/search.js b/addons/web/static/test/search.js index 6dc37f31d08..59353f9d22d 100644 --- a/addons/web/static/test/search.js +++ b/addons/web/static/test/search.js @@ -1044,8 +1044,12 @@ $(document).ready(function () { "second value should be clicked filter"); }); }); - asyncTest('click removing from query', 2, function () { + asyncTest('click removing from query', 4, function () { + var calls = 0; var view = makeSearchView({}, {foo2: true}); + view.on_search.add(function () { + ++calls; + }); var $fix = $('#qunit-fixture'); view.appendTo($fix) .always(start) @@ -1054,8 +1058,10 @@ $(document).ready(function () { var $fs = $fix.find('.oe_searchview_filters ul'); // sanity check equal(view.query.length, 1, "query should have default facet"); + strictEqual(calls, 0); $fs.children(':eq(1)').trigger('click'); equal(view.query.length, 0, "click should have removed facet"); + strictEqual(calls, 1, "one search should have been triggered"); }); }); From 6782c33a32fd8ccdfc6b00387beba532e64bf5cf Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 18 Oct 2012 15:41:23 +0200 Subject: [PATCH 09/10] [FIX] only reload m2m listview once after adding n records to it (via dialog) The listview does not support concurrent reload requests, either wait for the previous reload to finish before sending the new one, or just send a single reload. For m2m, can wait and do a single reload so do that. bzr revid: xmo@openerp.com-20121018134123-ox2ccq0wm3r5jwas --- addons/web/static/src/js/view_form.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 6f525f7a8b5..b2caf70dbbe 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4048,13 +4048,17 @@ instance.web.form.Many2ManyListView = instance.web.ListView.extend(/** @lends in ); var self = this; pop.on("elements_selected", self, function(element_ids) { - _.each(element_ids, function(one_id) { - if(! _.detect(self.dataset.ids, function(x) {return x == one_id;})) { - self.dataset.set_ids([].concat(self.dataset.ids, [one_id])); + var reload = false; + _(element_ids).each(function (id) { + if(! _.detect(self.dataset.ids, function(x) {return x == id;})) { + self.dataset.set_ids(self.dataset.ids.concat([id])); self.m2m_field.dataset_changed(); - self.reload_content(); + reload = true; } }); + if (reload) { + self.reload_content(); + } }); }, do_activate_record: function(index, id) { From 4223b1e786fbe6724079953825e67cf205184400 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 18 Oct 2012 16:57:12 +0200 Subject: [PATCH 10/10] [IMP] add overridable dimension-setting method on form fields bzr revid: xmo@openerp.com-20121018145712-am4y6bdnz2x14i2c --- addons/web/static/src/js/view_form.js | 21 +++++++++++++++++++ .../web/static/src/js/view_list_editable.js | 4 +--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index b2caf70dbbe..1a142b4c43b 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -2143,6 +2143,20 @@ instance.web.form.AbstractField = instance.web.form.FormWidget.extend(instance.w self.do_action(r); }); }, + + set_dimensions: function (height, width) { + // remove width css property + this.$el.css('width', ''); + // extract style (without width) + var old_style = this.$el.attr('style'); + // jQuery doesn't understand/use !important + var style = 'width:' + width + 'px !important;'; + if (old_style) { + style += old_style + } + this.$el.attr('style', style); + this.$el.css('minHeight', height); + } }); /** @@ -2521,6 +2535,13 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we focus: function($el) { this.$textarea.focus(); }, + set_dimensions: function (height, width) { + this._super(); + this.$textarea.css({ + width: width, + minHeight: height + }); + }, }); /** diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 3a3b06cbedf..9683dbd804b 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -251,12 +251,10 @@ openerp.web.list_editable = function (instance) { var $cell = $(cell); var position = $cell.position(); - // jquery does not understand !important - field.$el.attr('style', 'width: '+$cell.outerWidth()+'px !important'); + field.set_dimensions($cell.outerHeight(), $cell.outerWidth()); field.$el.css({ top: position.top, left: position.left, - minHeight: $cell.outerHeight() }); }, /**