[FIX] lunch: remove flickering of lunch widget
closes odoo/odoo#33685 Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -128,6 +128,53 @@ QUnit.module('LunchKanbanView', {
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('no flickering at reload', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
const self = this;
|
||||
let infosProm = $.when();
|
||||
const kanban = 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 $.when(self.data['lunch.location'].records[0].id);
|
||||
}
|
||||
if (route === '/lunch/infos') {
|
||||
return $.when(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 = $.Deferred();
|
||||
kanban.reload();
|
||||
|
||||
assert.strictEqual(kanban.$('.o_lunch_widget').length, 1,
|
||||
"old widget should still be present");
|
||||
|
||||
infosProm.resolve();
|
||||
|
||||
assert.strictEqual(kanban.$('.o_lunch_widget').length, 1);
|
||||
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.module('LunchKanbanWidget', function () {
|
||||
|
||||
QUnit.test('empty cart', function (assert) {
|
||||
@@ -814,7 +861,6 @@ QUnit.module('LunchKanbanView', {
|
||||
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user