Merge pull request '2967-zone_deliverydays_keep_search_on_url' (#687) from 2967-zone_deliverydays_keep_search_on_url into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #687 Reviewed-by: Joan Sanchez <joan@verdnatura.es>
This commit is contained in:
commit
a29b1fbd8d
|
@ -22,17 +22,20 @@
|
||||||
"abstract": true,
|
"abstract": true,
|
||||||
"component": "vn-order",
|
"component": "vn-order",
|
||||||
"description": "Orders"
|
"description": "Orders"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/index?q",
|
"url": "/index?q",
|
||||||
"state": "order.index",
|
"state": "order.index",
|
||||||
"component": "vn-order-index",
|
"component": "vn-order-index",
|
||||||
"description": "Orders"
|
"description": "Orders"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/:id",
|
"url": "/:id",
|
||||||
"state": "order.card",
|
"state": "order.card",
|
||||||
"abstract": true,
|
"abstract": true,
|
||||||
"component": "vn-order-card"
|
"component": "vn-order-card"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/summary",
|
"url": "/summary",
|
||||||
"state": "order.card.summary",
|
"state": "order.card.summary",
|
||||||
"component": "vn-order-summary",
|
"component": "vn-order-summary",
|
||||||
|
@ -40,7 +43,8 @@
|
||||||
"params": {
|
"params": {
|
||||||
"order": "$ctrl.order"
|
"order": "$ctrl.order"
|
||||||
}
|
}
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/catalog?q&categoryId&typeId&tagGroups",
|
"url": "/catalog?q&categoryId&typeId&tagGroups",
|
||||||
"state": "order.card.catalog",
|
"state": "order.card.catalog",
|
||||||
"component": "vn-order-catalog",
|
"component": "vn-order-catalog",
|
||||||
|
@ -48,7 +52,8 @@
|
||||||
"params": {
|
"params": {
|
||||||
"order": "$ctrl.order"
|
"order": "$ctrl.order"
|
||||||
}
|
}
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/volume",
|
"url": "/volume",
|
||||||
"state": "order.card.volume",
|
"state": "order.card.volume",
|
||||||
"component": "vn-order-volume",
|
"component": "vn-order-volume",
|
||||||
|
@ -56,7 +61,8 @@
|
||||||
"params": {
|
"params": {
|
||||||
"order": "$ctrl.order"
|
"order": "$ctrl.order"
|
||||||
}
|
}
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/line",
|
"url": "/line",
|
||||||
"state": "order.card.line",
|
"state": "order.card.line",
|
||||||
"component": "vn-order-line",
|
"component": "vn-order-line",
|
||||||
|
@ -64,12 +70,14 @@
|
||||||
"params": {
|
"params": {
|
||||||
"order": "$ctrl.order"
|
"order": "$ctrl.order"
|
||||||
}
|
}
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/create?clientFk",
|
"url": "/create?clientFk",
|
||||||
"state": "order.create",
|
"state": "order.create",
|
||||||
"component": "vn-order-create",
|
"component": "vn-order-create",
|
||||||
"description": "New order"
|
"description": "New order"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/basic-data",
|
"url": "/basic-data",
|
||||||
"state": "order.card.basicData",
|
"state": "order.card.basicData",
|
||||||
"component": "vn-order-basic-data",
|
"component": "vn-order-basic-data",
|
||||||
|
|
|
@ -5,24 +5,28 @@
|
||||||
</vn-zone-calendar>
|
</vn-zone-calendar>
|
||||||
</div>
|
</div>
|
||||||
<vn-side-menu side="right">
|
<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
|
<vn-radio
|
||||||
label="Pick up"
|
label="Pick up"
|
||||||
val="pickUp"
|
val="pickUp"
|
||||||
ng-model="$ctrl.deliveryMethodFk">
|
ng-model="$ctrl.deliveryMethodFk"
|
||||||
|
on-change="$ctrl.agencyModeFk = null"
|
||||||
|
tabindex="-1">
|
||||||
</vn-radio>
|
</vn-radio>
|
||||||
<vn-radio
|
<vn-radio
|
||||||
label="Delivery"
|
label="Delivery"
|
||||||
val="delivery"
|
val="delivery"
|
||||||
ng-model="$ctrl.deliveryMethodFk"
|
ng-model="$ctrl.deliveryMethodFk"
|
||||||
class="vn-mb-sm">
|
on-change="$ctrl.agencyModeFk = null"
|
||||||
|
class="vn-mb-sm"
|
||||||
|
tabindex="-1">
|
||||||
</vn-radio>
|
</vn-radio>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
ng-if="$ctrl.deliveryMethodFk === 'delivery'"
|
ng-if="$ctrl.deliveryMethodFk === 'delivery'"
|
||||||
vn-focus
|
vn-focus
|
||||||
label="Postcode"
|
label="Postcode"
|
||||||
ng-model="params.geoFk"
|
ng-model="$ctrl.geoFk"
|
||||||
url="Postcodes/location"
|
url="Postcodes/location"
|
||||||
fields="['code','townFk']"
|
fields="['code','townFk']"
|
||||||
order="code, townFk"
|
order="code, townFk"
|
||||||
|
@ -39,7 +43,7 @@
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
label="{{$ctrl.deliveryMethodFk == 'delivery' ? 'Agency' : 'Warehouse'}}"
|
label="{{$ctrl.deliveryMethodFk == 'delivery' ? 'Agency' : 'Warehouse'}}"
|
||||||
ng-model="params.agencyModeFk"
|
ng-model="$ctrl.agencyModeFk"
|
||||||
url="AgencyModes/isActive"
|
url="AgencyModes/isActive"
|
||||||
where="$ctrl.agencyFilter"
|
where="$ctrl.agencyFilter"
|
||||||
vn-id="agencymode">
|
vn-id="agencymode">
|
||||||
|
|
|
@ -4,20 +4,44 @@ import './style.scss';
|
||||||
|
|
||||||
class Controller extends Section {
|
class Controller extends Section {
|
||||||
$onInit() {
|
$onInit() {
|
||||||
this.$.params = {};
|
this.setParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
$postLink() {
|
$postLink() {
|
||||||
this.deliveryMethodFk = 'delivery';
|
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.$.data = null;
|
||||||
this.$http.get(`Zones/getEvents`, {params: this.$.params})
|
this.$http.get(`Zones/getEvents`, {params})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let data = res.data;
|
let data = res.data;
|
||||||
this.$.data = data;
|
this.$.data = data;
|
||||||
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'));
|
||||||
|
|
||||||
|
this.$state.go(this.$state.current.name, params);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,16 +51,16 @@ class Controller extends Section {
|
||||||
|
|
||||||
set deliveryMethodFk(value) {
|
set deliveryMethodFk(value) {
|
||||||
this._deliveryMethodFk = value;
|
this._deliveryMethodFk = value;
|
||||||
this.$.params.agencyModeFk = null;
|
|
||||||
let filter;
|
let filter;
|
||||||
if (value === 'pickUp') {
|
|
||||||
|
if (value === 'pickUp')
|
||||||
filter = {where: {code: 'PICKUP'}};
|
filter = {where: {code: 'PICKUP'}};
|
||||||
this.$.agencymode.focus();
|
else
|
||||||
} else
|
|
||||||
filter = {where: {code: {inq: ['DELIVERY', 'AGENCY']}}};
|
filter = {where: {code: {inq: ['DELIVERY', 'AGENCY']}}};
|
||||||
|
|
||||||
this.$http.get(`DeliveryMethods`, {filter}).then(res => {
|
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}};
|
this.agencyFilter = {deliveryMethodFk: {inq: deliveryMethods}};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,46 +19,67 @@ describe('Zone Component vnZoneDeliveryDays', () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('deliveryMethodFk() setter', () => {
|
describe('deliveryMethodFk() setter', () => {
|
||||||
it(`should set the deliveryMethodFk property and check just agencymode focus`, () => {
|
it('should set the deliveryMethodFk property as pickup and then perform a query that sets the filter', () => {
|
||||||
controller.$.agencymode = {focus: jasmine.createSpy('focus')};
|
$httpBackend.expect('GET', 'DeliveryMethods').respond([{id: 999}]);
|
||||||
|
|
||||||
controller.deliveryMethodFk = 'pickUp';
|
controller.deliveryMethodFk = 'pickUp';
|
||||||
|
|
||||||
expect(controller.$.agencymode.focus).toHaveBeenCalledWith();
|
|
||||||
});
|
|
||||||
|
|
||||||
it(`should set the deliveryMethodFk property, call method http and sets the agencyfilter`, () => {
|
|
||||||
$httpBackend.when('GET', 'DeliveryMethods').respond([{id: 'id'}]);
|
|
||||||
|
|
||||||
controller.deliveryMethodFk = 'no pickUp';
|
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.agencyFilter).toEqual({deliveryMethodFk: {inq: ['id']}});
|
expect(controller.agencyFilter).toEqual({deliveryMethodFk: {inq: [999]}});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('setParams()', () => {
|
||||||
it('should make an HTTP GET query and then call the showMessage() method', () => {
|
it('should do nothing when no params are received', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showMessage');
|
controller.setParams();
|
||||||
|
|
||||||
const expectedData = {events: []};
|
expect(controller.deliveryMethodFk).toBeUndefined();
|
||||||
$httpBackend.when('GET', 'Zones/getEvents').respond({events: []});
|
expect(controller.geoFk).toBeUndefined();
|
||||||
controller.onSubmit();
|
expect(controller.agencyModeFk).toBeUndefined();
|
||||||
$httpBackend.flush();
|
|
||||||
|
|
||||||
expect(controller.$.data).toBeDefined();
|
|
||||||
expect(controller.$.data).toEqual(expectedData);
|
|
||||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No service for the specified zone');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should make an HTTP GET query and then set the data property', () => {
|
it('should set the controller properties when the params are provided', () => {
|
||||||
const expectedData = {events: [{zoneFk: 1}]};
|
controller.$params = {
|
||||||
$httpBackend.when('GET', 'Zones/getEvents').respond({events: [{zoneFk: 1}]});
|
deliveryMethodFk: 3,
|
||||||
controller.onSubmit();
|
geoFk: 2,
|
||||||
|
agencyModeFk: 1
|
||||||
|
};
|
||||||
|
controller.setParams();
|
||||||
|
|
||||||
|
expect(controller.deliveryMethodFk).toEqual(controller.$params.deliveryMethodFk);
|
||||||
|
expect(controller.geoFk).toEqual(controller.$params.geoFk);
|
||||||
|
expect(controller.agencyModeFk).toEqual(controller.$params.agencyModeFk);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('fetchData()', () => {
|
||||||
|
it('should make an HTTP GET query and then call the showMessage() method', () => {
|
||||||
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
jest.spyOn(controller.$state, 'go');
|
||||||
|
|
||||||
|
controller.agencyModeFk = 1;
|
||||||
|
controller.deliveryMethodFk = 2;
|
||||||
|
controller.geoFk = 3;
|
||||||
|
controller.$state.current.name = 'myState';
|
||||||
|
|
||||||
|
const expectedData = {events: []};
|
||||||
|
|
||||||
|
const url = 'Zones/getEvents?agencyModeFk=1&deliveryMethodFk=2&geoFk=3';
|
||||||
|
|
||||||
|
$httpBackend.when('GET', 'DeliveryMethods').respond([]);
|
||||||
|
$httpBackend.expect('GET', url).respond({events: []});
|
||||||
|
controller.fetchData();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.$.data).toBeDefined();
|
|
||||||
expect(controller.$.data).toEqual(expectedData);
|
expect(controller.$.data).toEqual(expectedData);
|
||||||
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('No service for the specified zone');
|
||||||
|
expect(controller.$state.go).toHaveBeenCalledWith(
|
||||||
|
controller.$state.current.name,
|
||||||
|
{
|
||||||
|
agencyModeFk: 1,
|
||||||
|
deliveryMethodFk: 2,
|
||||||
|
geoFk: 3
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -28,33 +28,39 @@
|
||||||
"abstract": true,
|
"abstract": true,
|
||||||
"component": "vn-zone",
|
"component": "vn-zone",
|
||||||
"description": "Zones"
|
"description": "Zones"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/index?q",
|
"url": "/index?q",
|
||||||
"state": "zone.index",
|
"state": "zone.index",
|
||||||
"component": "vn-zone-index",
|
"component": "vn-zone-index",
|
||||||
"description": "Zones"
|
"description": "Zones"
|
||||||
}, {
|
},
|
||||||
"url": "/delivery-days?q",
|
{
|
||||||
|
"url": "/delivery-days?q&deliveryMethodFk&geoFk&agencyModeFk",
|
||||||
"state": "zone.deliveryDays",
|
"state": "zone.deliveryDays",
|
||||||
"component": "vn-zone-delivery-days",
|
"component": "vn-zone-delivery-days",
|
||||||
"description": "Delivery days"
|
"description": "Delivery days"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/upcoming-deliveries",
|
"url": "/upcoming-deliveries",
|
||||||
"state": "zone.upcomingDeliveries",
|
"state": "zone.upcomingDeliveries",
|
||||||
"component": "vn-upcoming-deliveries",
|
"component": "vn-upcoming-deliveries",
|
||||||
"description": "Upcoming deliveries"
|
"description": "Upcoming deliveries"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/create",
|
"url": "/create",
|
||||||
"state": "zone.create",
|
"state": "zone.create",
|
||||||
"component": "vn-zone-create",
|
"component": "vn-zone-create",
|
||||||
"description": "New zone"
|
"description": "New zone"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/:id",
|
"url": "/:id",
|
||||||
"state": "zone.card",
|
"state": "zone.card",
|
||||||
"component": "vn-zone-card",
|
"component": "vn-zone-card",
|
||||||
"abstract": true,
|
"abstract": true,
|
||||||
"description": "Detail"
|
"description": "Detail"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/summary",
|
"url": "/summary",
|
||||||
"state": "zone.card.summary",
|
"state": "zone.card.summary",
|
||||||
"component": "vn-zone-summary",
|
"component": "vn-zone-summary",
|
||||||
|
@ -62,7 +68,8 @@
|
||||||
"params": {
|
"params": {
|
||||||
"zone": "$ctrl.zone"
|
"zone": "$ctrl.zone"
|
||||||
}
|
}
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/basic-data",
|
"url": "/basic-data",
|
||||||
"state": "zone.card.basicData",
|
"state": "zone.card.basicData",
|
||||||
"component": "vn-zone-basic-data",
|
"component": "vn-zone-basic-data",
|
||||||
|
@ -70,17 +77,20 @@
|
||||||
"params": {
|
"params": {
|
||||||
"zone": "$ctrl.zone"
|
"zone": "$ctrl.zone"
|
||||||
}
|
}
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/warehouses",
|
"url": "/warehouses",
|
||||||
"state": "zone.card.warehouses",
|
"state": "zone.card.warehouses",
|
||||||
"component": "vn-zone-warehouses",
|
"component": "vn-zone-warehouses",
|
||||||
"description": "Warehouses"
|
"description": "Warehouses"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/events",
|
"url": "/events",
|
||||||
"state": "zone.card.events",
|
"state": "zone.card.events",
|
||||||
"component": "vn-zone-events",
|
"component": "vn-zone-events",
|
||||||
"description": "Calendar"
|
"description": "Calendar"
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url": "/location?q",
|
"url": "/location?q",
|
||||||
"state": "zone.card.location",
|
"state": "zone.card.location",
|
||||||
"component": "vn-zone-location",
|
"component": "vn-zone-location",
|
||||||
|
@ -88,7 +98,8 @@
|
||||||
"params": {
|
"params": {
|
||||||
"zone": "$ctrl.zone"
|
"zone": "$ctrl.zone"
|
||||||
}
|
}
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
"url" : "/log",
|
"url" : "/log",
|
||||||
"state": "zone.card.log",
|
"state": "zone.card.log",
|
||||||
"component": "vn-zone-log",
|
"component": "vn-zone-log",
|
||||||
|
|
Loading…
Reference in New Issue