summaryrefslogtreecommitdiff
path: root/addons/lunch/static/src/js/lunch_controller_common.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/lunch/static/src/js/lunch_controller_common.js')
-rw-r--r--addons/lunch/static/src/js/lunch_controller_common.js51
1 files changed, 8 insertions, 43 deletions
diff --git a/addons/lunch/static/src/js/lunch_controller_common.js b/addons/lunch/static/src/js/lunch_controller_common.js
index 27ce66ec49c..8cd09316220 100644
--- a/addons/lunch/static/src/js/lunch_controller_common.js
+++ b/addons/lunch/static/src/js/lunch_controller_common.js
@@ -27,7 +27,6 @@ var LunchControllerCommon = {
*/
init: function () {
this._super.apply(this, arguments);
- this.userId = null;
this.editMode = false;
this.updated = false;
this.widgetData = null;
@@ -60,30 +59,16 @@ var LunchControllerCommon = {
},
});
},
- _fetchWidgetData: function () {
- var self = this;
-
- return this._rpc({
+ _fetchWidgetData: async function () {
+ this.widgetData = await this._rpc({
route: '/lunch/infos',
params: {
- user_id: this.userId,
+ user_id: this.searchModel.get('userId'),
context: this.context,
},
- }).then(function (data) {
- self.widgetData = data;
- return self.model._updateLocation(data.user_location[0]);
});
},
/**
- * Override to add the location domain (coming from the LunchWidget)
- * to the searchDomain (coming from the controlPanel).
- *
- * @override
- */
- _getViewDomain: async function () {
- return this.model.getLocationDomain();
- },
- /**
* Renders and appends the lunch banner widget.
*
* @private
@@ -140,28 +125,14 @@ var LunchControllerCommon = {
});
},
_onLocationChanged: function (ev) {
- var self = this;
-
ev.stopPropagation();
-
- this._rpc({
- route: '/lunch/user_location_set',
- params: {
- user_id: this.userId,
- location_id: ev.data.locationId,
- context: this.context,
- },
- }).then(function () {
- self.model._updateLocation(ev.data.locationId).then(function () {
- self.reload();
- });
- });
+ this.searchModel.dispatch('setLocationId', ev.data.locationId);
},
_onOpenWizard: function (ev) {
var self = this;
ev.stopPropagation();
- var ctx = this.userId ? {default_user_id: this.userId} : {};
+ var ctx = this.searchModel.get('userId') ? {default_user_id: this.searchModel.get('userId')} : {};
var options = {
on_close: function () {
@@ -197,7 +168,7 @@ var LunchControllerCommon = {
this._rpc({
route: '/lunch/pay',
params: {
- user_id: this.userId,
+ user_id: this.searchModel.get('userId'),
context: this.context,
},
}).then(function (isPaid) {
@@ -224,13 +195,7 @@ var LunchControllerCommon = {
},
_onUserChanged: function (ev) {
ev.stopPropagation();
-
- var self = this;
-
- this.userId = ev.data.userId;
- this.model._updateUser(ev.data.userId).then(function () {
- self.reload();
- });
+ this.searchModel.dispatch('updateUserId', ev.data.userId);
},
_onUnlinkOrder: function (ev) {
var self = this;
@@ -239,7 +204,7 @@ var LunchControllerCommon = {
this._rpc({
route: '/lunch/trash',
params: {
- user_id: this.userId,
+ user_id: this.searchModel.get('userId'),
context: this.context,
},
}).then(function () {