diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-06-06 11:54:35 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-06-06 11:54:35 +0200 |
| commit | 71a50a2214748fec413c5a0f042d0e7172ae6ea9 (patch) | |
| tree | 2e9ee11551350e23923390d9c53baf630b6ed834 /addons/lunch/static | |
| parent | a7621137cb0d75ec545152d5e1d413c9d3548e45 (diff) | |
| parent | 409679866b2ee8352a8cb27460e7332563526924 (diff) | |
[MERGE] forward port branch saas-12.3 up to 409679866b2
Diffstat (limited to 'addons/lunch/static')
| -rw-r--r-- | addons/lunch/static/src/js/lunch_kanban_controller.js | 7 | ||||
| -rw-r--r-- | addons/lunch/static/tests/lunch_kanban_tests.js | 48 |
2 files changed, 51 insertions, 4 deletions
diff --git a/addons/lunch/static/src/js/lunch_kanban_controller.js b/addons/lunch/static/src/js/lunch_kanban_controller.js index 80a39adae96..f1acf81b301 100644 --- a/addons/lunch/static/src/js/lunch_kanban_controller.js +++ b/addons/lunch/static/src/js/lunch_kanban_controller.js @@ -77,13 +77,14 @@ var LunchKanbanController = KanbanController.extend({ */ _renderLunchKanbanWidget: function () { var self = this; - if (this.widget) { - this.widget.destroy(); - } + var oldWidget = this.widget; this.widgetData.wallet = parseFloat(this.widgetData.wallet).toFixed(2); this.widget = new LunchKanbanWidget(this, _.extend(this.widgetData, {edit: this.editMode})); return this.widget.appendTo(document.createDocumentFragment()).then(function () { self.$('.o_lunch_kanban').prepend(self.widget.$el); + if (oldWidget) { + oldWidget.destroy(); + } }); }, _showPaymentDialog: function (title) { diff --git a/addons/lunch/static/tests/lunch_kanban_tests.js b/addons/lunch/static/tests/lunch_kanban_tests.js index 32cac593dcc..8bc4879f9e5 100644 --- a/addons/lunch/static/tests/lunch_kanban_tests.js +++ b/addons/lunch/static/tests/lunch_kanban_tests.js @@ -128,6 +128,53 @@ QUnit.module('LunchKanbanView', { kanban.destroy(); }); + QUnit.test('no flickering at reload', async function (assert) { + assert.expect(2); + + const self = this; + let infosProm = Promise.resolve(); + const kanban = await createLunchKanbanView({ + View: LunchKanbanView, + model: 'product', + data: this.data, + arch: ` + <kanban> + <templates> + <t t-name="kanban-box"> + <div><field name="name"/></div> + </t> + </templates> + </kanban> + `, + mockRPC: function (route, args) { + if (route === '/lunch/user_location_get') { + return Promise.resolve(self.data['lunch.location'].records[0].id); + } + if (route === '/lunch/infos') { + return Promise.resolve(self.regularInfos); + } + var result = this._super.apply(this, arguments); + if (args.method === 'xmlid_to_res_id') { + // delay the rendering of the lunch widget + return infosProm.then(_.constant(result)); + } + return result; + }, + }); + + infosProm = testUtils.makeTestPromise(); + kanban.reload(); + + assert.strictEqual(kanban.$('.o_lunch_widget').length, 1, + "old widget should still be present"); + + await infosProm.resolve(); + + assert.strictEqual(kanban.$('.o_lunch_widget').length, 1); + + kanban.destroy(); + }); + QUnit.module('LunchKanbanWidget', function () { QUnit.test('empty cart', async function (assert) { @@ -814,7 +861,6 @@ QUnit.module('LunchKanbanView', { kanban.destroy(); }); - }); }); |
