2747 Zone delivery days save parameters in the url #581

Closed
Ghost wants to merge 2 commits from 2747-zone_delivery_days_url_parameters into dev
1 changed files with 6 additions and 0 deletions
Showing only changes of commit 766617f871 - Show all commits

View File

@ -7,17 +7,20 @@ class Controller extends Section {
super($element, $scope); super($element, $scope);
this.$location = $location; this.$location = $location;
} }
$onInit() { $onInit() {
this.$.params = this.$location.search(); this.$.params = this.$location.search();
if (!this.$.params) if (!this.$.params)
this.$.params = {}; this.$.params = {};
this.$.data = null; this.$.data = null;
this.$http.get(`Zones/getEvents`, {params: this.$.params}) this.$http.get(`Zones/getEvents`, {params: this.$.params})
.then(res => { .then(res => {
const data = res.data; const data = res.data;
this.$.data = data; this.$.data = data;
const agencyModeFk = this.$.params.agencyModeFk; const agencyModeFk = this.$.params.agencyModeFk;
const geoFk = this.$.params.geoFk; const geoFk = this.$.params.geoFk;
this.$location.path('/zone/delivery-days').search({agencyModeFk, geoFk}); this.$location.path('/zone/delivery-days').search({agencyModeFk, geoFk});
}); });
} }
@ -25,14 +28,17 @@ class Controller extends Section {
$postLink() { $postLink() {
this.deliveryMethodFk = 'delivery'; this.deliveryMethodFk = 'delivery';
} }
onSubmit() { onSubmit() {
this.$.data = null; this.$.data = null;
this.$http.get(`Zones/getEvents`, {params: this.$.params}) this.$http.get(`Zones/getEvents`, {params: this.$.params})
.then(res => { .then(res => {
const data = res.data; const data = res.data;
this.$.data = data; this.$.data = data;
const agencyModeFk = this.$.params.agencyModeFk; const agencyModeFk = this.$.params.agencyModeFk;
const geoFk = this.$.params.geoFk; const geoFk = this.$.params.geoFk;
this.$location.path('/zone/delivery-days').search({agencyModeFk, geoFk}); this.$location.path('/zone/delivery-days').search({agencyModeFk, geoFk});
if (!data.events.length) if (!data.events.length)
this.vnApp.showMessage(this.$t('No service for the specified zone')); this.vnApp.showMessage(this.$t('No service for the specified zone'));