route delivery days now gets params from url

This commit is contained in:
Carlos Jimenez Ruiz 2021-07-01 12:08:48 +02:00
parent 5d38488ac1
commit 8cf2b241cd
4 changed files with 80 additions and 33 deletions

View File

@ -22,17 +22,20 @@
"abstract": true,
"component": "vn-order",
"description": "Orders"
}, {
},
{
"url": "/index?q",
"state": "order.index",
"component": "vn-order-index",
"description": "Orders"
}, {
},
{
"url": "/:id",
"state": "order.card",
"abstract": true,
"component": "vn-order-card"
}, {
},
{
"url": "/summary",
"state": "order.card.summary",
"component": "vn-order-summary",
@ -40,7 +43,8 @@
"params": {
"order": "$ctrl.order"
}
}, {
},
{
"url": "/catalog?q&categoryId&typeId&tagGroups",
"state": "order.card.catalog",
"component": "vn-order-catalog",
@ -48,7 +52,8 @@
"params": {
"order": "$ctrl.order"
}
}, {
},
{
"url": "/volume",
"state": "order.card.volume",
"component": "vn-order-volume",
@ -56,7 +61,8 @@
"params": {
"order": "$ctrl.order"
}
}, {
},
{
"url": "/line",
"state": "order.card.line",
"component": "vn-order-line",
@ -64,12 +70,14 @@
"params": {
"order": "$ctrl.order"
}
}, {
},
{
"url": "/create?clientFk",
"state": "order.create",
"component": "vn-order-create",
"description": "New order"
}, {
},
{
"url": "/basic-data",
"state": "order.card.basicData",
"component": "vn-order-basic-data",

View File

@ -5,24 +5,28 @@
</vn-zone-calendar>
</div>
<vn-side-menu side="right">
<form ng-submit="$ctrl.onSubmit()" class="vn-pa-md">
<form ng-submit="$ctrl.fetchData()" class="vn-pa-md">
<vn-radio
label="Pick up"
val="pickUp"
ng-model="$ctrl.deliveryMethodFk">
ng-model="$ctrl.deliveryMethodFk"
on-change="$ctrl.agencyModeFk = null"
tabindex="-1">
</vn-radio>
<vn-radio
label="Delivery"
val="delivery"
ng-model="$ctrl.deliveryMethodFk"
class="vn-mb-sm">
on-change="$ctrl.agencyModeFk = null"
class="vn-mb-sm"
tabindex="-1">
</vn-radio>
<vn-autocomplete
vn-one
ng-if="$ctrl.deliveryMethodFk === 'delivery'"
vn-focus
label="Postcode"
ng-model="params.geoFk"
ng-model="$ctrl.geoFk"
url="Postcodes/location"
fields="['code','townFk']"
order="code, townFk"
@ -39,7 +43,7 @@
</vn-autocomplete>
<vn-autocomplete
label="{{$ctrl.deliveryMethodFk == 'delivery' ? 'Agency' : 'Warehouse'}}"
ng-model="params.agencyModeFk"
ng-model="$ctrl.agencyModeFk"
url="AgencyModes/isActive"
where="$ctrl.agencyFilter"
vn-id="agencymode">

View File

@ -4,20 +4,44 @@ import './style.scss';
class Controller extends Section {
$onInit() {
this.$.params = {};
this.setParams();
}
$postLink() {
this.deliveryMethodFk = 'delivery';
}
onSubmit() {
setParams() {
const hasParams = this.$params.deliveryMethodFk || this.$params.geoFk || this.$params.agencyModeFk;
if (hasParams) {
if (this.$params.deliveryMethodFk)
this.deliveryMethodFk = this.$params.deliveryMethodFk;
if (this.$params.geoFk)
this.geoFk = this.$params.geoFk;
if (this.$params.agencyModeFk)
this.agencyModeFk = this.$params.agencyModeFk;
this.fetchData();
}
}
fetchData() {
const params = {
deliveryMethodFk: this.deliveryMethodFk,
geoFk: this.geoFk,
agencyModeFk: this.agencyModeFk
};
this.$.data = null;
this.$http.get(`Zones/getEvents`, {params: this.$.params})
this.$http.get(`Zones/getEvents`, {params})
.then(res => {
let data = res.data;
this.$.data = data;
if (!data.events.length)
this.vnApp.showMessage(this.$t('No service for the specified zone'));
this.$state.go(this.$state.current.name, params);
});
}
@ -27,16 +51,16 @@ class Controller extends Section {
set deliveryMethodFk(value) {
this._deliveryMethodFk = value;
this.$.params.agencyModeFk = null;
let filter;
if (value === 'pickUp') {
if (value === 'pickUp')
filter = {where: {code: 'PICKUP'}};
this.$.agencymode.focus();
} else
else
filter = {where: {code: {inq: ['DELIVERY', 'AGENCY']}}};
this.$http.get(`DeliveryMethods`, {filter}).then(res => {
let deliveryMethods = res.data.map(deliveryMethod => deliveryMethod.id);
const deliveryMethods = res.data.map(deliveryMethod => deliveryMethod.id);
this.agencyFilter = {deliveryMethodFk: {inq: deliveryMethods}};
});
}

View File

@ -28,33 +28,39 @@
"abstract": true,
"component": "vn-zone",
"description": "Zones"
}, {
},
{
"url": "/index?q",
"state": "zone.index",
"component": "vn-zone-index",
"description": "Zones"
}, {
"url": "/delivery-days?q",
},
{
"url": "/delivery-days?q&deliveryMethodFk&geoFk&agencyModeFk",
"state": "zone.deliveryDays",
"component": "vn-zone-delivery-days",
"description": "Delivery days"
}, {
},
{
"url": "/upcoming-deliveries",
"state": "zone.upcomingDeliveries",
"component": "vn-upcoming-deliveries",
"description": "Upcoming deliveries"
}, {
},
{
"url": "/create",
"state": "zone.create",
"component": "vn-zone-create",
"description": "New zone"
}, {
},
{
"url": "/:id",
"state": "zone.card",
"component": "vn-zone-card",
"abstract": true,
"description": "Detail"
}, {
},
{
"url": "/summary",
"state": "zone.card.summary",
"component": "vn-zone-summary",
@ -62,7 +68,8 @@
"params": {
"zone": "$ctrl.zone"
}
}, {
},
{
"url": "/basic-data",
"state": "zone.card.basicData",
"component": "vn-zone-basic-data",
@ -70,17 +77,20 @@
"params": {
"zone": "$ctrl.zone"
}
}, {
},
{
"url": "/warehouses",
"state": "zone.card.warehouses",
"component": "vn-zone-warehouses",
"description": "Warehouses"
}, {
},
{
"url": "/events",
"state": "zone.card.events",
"component": "vn-zone-events",
"description": "Calendar"
}, {
},
{
"url": "/location?q",
"state": "zone.card.location",
"component": "vn-zone-location",
@ -88,7 +98,8 @@
"params": {
"zone": "$ctrl.zone"
}
}, {
},
{
"url" : "/log",
"state": "zone.card.log",
"component": "vn-zone-log",