1823 - Added independent order object from card
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2021-01-19 13:57:04 +01:00
parent 727fcddc3d
commit 6d35a4a160
2 changed files with 26 additions and 6 deletions

View File

@ -25,8 +25,15 @@ class Controller extends Section {
}
$onChanges() {
if (this.order && this.order.isConfirmed)
this.$state.go('order.card.line');
this.getData().then(() => {
if (this.order && this.order.isConfirmed)
this.$state.go('order.card.line');
});
}
getData() {
return this.$http.get(`Orders/${this.$params.id}`)
.then(res => this.order = res.data);
}
/**
@ -366,8 +373,5 @@ class Controller extends Section {
ngModule.vnComponent('vnOrderCatalog', {
template: require('./index.html'),
controller: Controller,
bindings: {
order: '<'
}
controller: Controller
});

View File

@ -28,6 +28,22 @@ describe('Order', () => {
};
}));
describe('getData()', () => {
it(`should make a query an fetch the order data`, () => {
controller._order = null;
$httpBackend.expect('GET', `Orders/4`).respond(200, {id: 4, isConfirmed: true});
$httpBackend.expect('GET', `Orders/4/getItemTypeAvailable?itemCategoryId=1`).respond();
controller.getData();
$httpBackend.flush();
const order = controller.order;
expect(order.id).toEqual(4);
expect(order.isConfirmed).toBeTruthy();
});
});
describe('order() setter', () => {
it(`should call scope $applyAsync() method and apply filters from state params`, () => {
$httpBackend.expect('GET', `Orders/4/getItemTypeAvailable?itemCategoryId=1`).respond();