summaryrefslogtreecommitdiff
path: root/addons/pos_restaurant/static/src
diff options
context:
space:
mode:
authorJoseph Caburnay <jcb@odoo.com>2020-06-22 11:55:04 +0000
committerJoseph Caburnay <jcb@odoo.com>2020-08-19 07:34:04 +0000
commit18651864dd3bf27fd1c910888f5dbbed4046d42b (patch)
treec6fd1a531ffac995e15ab5d457334c381cf15af5 /addons/pos_restaurant/static/src
parente2cac8339492cb8b38b15c45a4a1e7086f013477 (diff)
[FIX] pos_restaurant: selectedTable can change during user input
In this commit, we make sure that the selectedTable doesn't change even during the popup is shown to the user. During testing, there might be rouge clicks that click the .floor-map element which deselects the selected floor, making the value of this.selectedTable to be false, causing runtime error.
Diffstat (limited to 'addons/pos_restaurant/static/src')
-rw-r--r--addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js b/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js
index 1a4a1a2f14d..587fe6e2d7c 100644
--- a/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js
+++ b/addons/pos_restaurant/static/src/js/Screens/FloorScreen/FloorScreen.js
@@ -87,17 +87,18 @@ odoo.define('pos_restaurant.FloorScreen', function (require) {
}
}
async _changeSeatsNum() {
- if (!this.selectedTable) return;
+ const selectedTable = this.selectedTable
+ if (!selectedTable) return;
const { confirmed, payload: inputNumber } = await this.showPopup('NumberPopup', {
- startingValue: this.selectedTable.seats,
+ startingValue: selectedTable.seats,
cheap: true,
title: this.env._t('Number of Seats ?'),
});
if (!confirmed) return;
- const newSeatsNum = parseInt(inputNumber, 10) || this.selectedTable.seats;
- if (newSeatsNum !== this.selectedTable.seats) {
- this.selectedTable.seats = newSeatsNum;
- await this._save(this.selectedTable);
+ const newSeatsNum = parseInt(inputNumber, 10) || selectedTable.seats;
+ if (newSeatsNum !== selectedTable.seats) {
+ selectedTable.seats = newSeatsNum;
+ await this._save(selectedTable);
}
}
async _changeShape() {
@@ -107,15 +108,16 @@ odoo.define('pos_restaurant.FloorScreen', function (require) {
await this._save(this.selectedTable);
}
async _renameTable() {
- if (!this.selectedTable) return;
+ const selectedTable = this.selectedTable;
+ if (!selectedTable) return;
const { confirmed, payload: newName } = await this.showPopup('TextInputPopup', {
- startingValue: this.selectedTable.name,
+ startingValue: selectedTable.name,
title: this.env._t('Table Name ?'),
});
if (!confirmed) return;
- if (newName !== this.selectedTable.name) {
- this.selectedTable.name = newName;
- await this._save(this.selectedTable);
+ if (newName !== selectedTable.name) {
+ selectedTable.name = newName;
+ await this._save(selectedTable);
}
}
async _setTableColor({ detail: color }) {