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() { $onChanges() {
if (this.order && this.order.isConfirmed) this.getData().then(() => {
this.$state.go('order.card.line'); 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', { ngModule.vnComponent('vnOrderCatalog', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller
bindings: {
order: '<'
}
}); });

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', () => { describe('order() setter', () => {
it(`should call scope $applyAsync() method and apply filters from state params`, () => { it(`should call scope $applyAsync() method and apply filters from state params`, () => {
$httpBackend.expect('GET', `Orders/4/getItemTypeAvailable?itemCategoryId=1`).respond(); $httpBackend.expect('GET', `Orders/4/getItemTypeAvailable?itemCategoryId=1`).respond();