fixed itemDiary warehouseFk select #671
This commit is contained in:
parent
9aff95904d
commit
469e6f8076
|
@ -1,7 +1,7 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="item/api/Items/getDiary"
|
url="item/api/Items/getDiary"
|
||||||
filter="::$ctrl.filter"
|
filter="$ctrl.filter"
|
||||||
data="sales">
|
data="sales">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-vertical>
|
<vn-vertical>
|
||||||
|
|
|
@ -10,12 +10,11 @@ class Controller {
|
||||||
this.$window = $window;
|
this.$window = $window;
|
||||||
this.$translate = $translate;
|
this.$translate = $translate;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
$postLink() {
|
get item() {
|
||||||
if (this.item)
|
return this._item;
|
||||||
this.filterBuilder();
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
set item(value) {
|
set item(value) {
|
||||||
this._item = value;
|
this._item = value;
|
||||||
|
|
||||||
|
@ -23,14 +22,12 @@ class Controller {
|
||||||
where: {itemFk: this.$stateParams.id}
|
where: {itemFk: this.$stateParams.id}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.$scope.$$postDigest(() => {
|
||||||
if (this.$stateParams.warehouseFk)
|
if (this.$stateParams.warehouseFk)
|
||||||
this.warehouseFk = this.$stateParams.warehouseFk;
|
this.warehouseFk = this.$stateParams.warehouseFk;
|
||||||
else if (value)
|
else if (value)
|
||||||
this.warehouseFk = value.itemType.warehouseFk;
|
this.warehouseFk = value.itemType.warehouseFk;
|
||||||
}
|
});
|
||||||
|
|
||||||
get item() {
|
|
||||||
return this._item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set warehouseFk(value) {
|
set warehouseFk(value) {
|
||||||
|
@ -41,6 +38,7 @@ class Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.filter.where.warehouseFk = value;
|
this.filter.where.warehouseFk = value;
|
||||||
|
this.$scope.model.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
get warehouseFk() {
|
get warehouseFk() {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import './index.js';
|
import './index.js';
|
||||||
|
import {crudModel} from '../../../helpers/crudModelHelper';
|
||||||
|
|
||||||
describe('Item', () => {
|
describe('Item', () => {
|
||||||
describe('Component vnItemDiary', () => {
|
describe('Component vnItemDiary', () => {
|
||||||
|
@ -20,7 +21,7 @@ describe('Item', () => {
|
||||||
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
$httpBackend.when('GET', /\/locale\/\w+\/[a-z]{2}\.json/).respond({});
|
||||||
$scope = $rootScope.$new();
|
$scope = $rootScope.$new();
|
||||||
controller = $componentController('vnItemDiary', {$scope: $scope, $stateParams});
|
controller = $componentController('vnItemDiary', {$scope: $scope, $stateParams});
|
||||||
controller.$scope.model = {};
|
controller.$scope.model = crudModel;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('isToday()', () => {
|
describe('isToday()', () => {
|
||||||
|
@ -75,16 +76,24 @@ describe('Item', () => {
|
||||||
|
|
||||||
describe('set item()', () => {
|
describe('set item()', () => {
|
||||||
it(`should set warehouseFk property based on itemType warehouseFk`, () => {
|
it(`should set warehouseFk property based on itemType warehouseFk`, () => {
|
||||||
|
spyOn(controller.$scope, '$$postDigest').and.callThrough();
|
||||||
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
||||||
|
|
||||||
|
expect(controller.$scope.$$postDigest).toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
|
$scope.$digest();
|
||||||
|
|
||||||
expect(controller.warehouseFk).toEqual(1);
|
expect(controller.warehouseFk).toEqual(1);
|
||||||
expect(controller.item.id).toEqual(1);
|
expect(controller.item.id).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should set warehouseFk property based on url query warehouseFk`, () => {
|
it(`should set warehouseFk property based on url query warehouseFk`, () => {
|
||||||
|
spyOn(controller.$scope, '$$postDigest').and.callThrough();
|
||||||
controller.$stateParams.warehouseFk = 4;
|
controller.$stateParams.warehouseFk = 4;
|
||||||
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
controller.item = {id: 1, itemType: {warehouseFk: 1}};
|
||||||
|
|
||||||
|
expect(controller.$scope.$$postDigest).toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
|
$scope.$digest();
|
||||||
|
|
||||||
expect(controller.warehouseFk).toEqual(4);
|
expect(controller.warehouseFk).toEqual(4);
|
||||||
expect(controller.item.id).toEqual(1);
|
expect(controller.item.id).toEqual(1);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue