itemBotanical
This commit is contained in:
parent
ada3d9480b
commit
60e2d8132b
|
@ -4,7 +4,7 @@
|
||||||
</mg-ajax>
|
</mg-ajax>
|
||||||
<vn-watcher
|
<vn-watcher
|
||||||
vn-id="watcher"
|
vn-id="watcher"
|
||||||
data="$ctrl.item.botanical"
|
data="$ctrl.botanical"
|
||||||
form="form"
|
form="form"
|
||||||
save="patch">
|
save="patch">
|
||||||
</vn-watcher>
|
</vn-watcher>
|
||||||
|
@ -13,20 +13,20 @@
|
||||||
<vn-vertical pad-large>
|
<vn-vertical pad-large>
|
||||||
<vn-title>Botanical</vn-title>
|
<vn-title>Botanical</vn-title>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield vn-one label="Botanical" model="$ctrl.item.botanical.botanical"></vn-textfield>
|
<vn-textfield vn-one label="Botanical" model="$ctrl.botanical.botanical"></vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
initial-data="$ctrl.item.botanical.genus"
|
initial-data="$ctrl.botanical.genus"
|
||||||
field="$ctrl.item.botanical.genusFk"
|
field="$ctrl.botanical.genusFk"
|
||||||
url="/item/api/genera"
|
url="/item/api/genera"
|
||||||
show-field="latin_genus_name"
|
show-field="latin_genus_name"
|
||||||
value-field="genus_id"
|
value-field="genus_id"
|
||||||
label="Genus">
|
label="Genus">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
initial-data="$ctrl.item.botanical.specie"
|
initial-data="$ctrl.botanical.specie"
|
||||||
field="$ctrl.item.botanical.specieFk"
|
field="$ctrl.botanical.specieFk"
|
||||||
url="/item/api/species"
|
url="/item/api/species"
|
||||||
show-field="latin_species_name"
|
show-field="latin_species_name"
|
||||||
value-field="specie_id"
|
value-field="specie_id"
|
||||||
|
|
|
@ -1,8 +1,25 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
|
|
||||||
|
class ItemBotanical {
|
||||||
|
constructor($http, $state) {
|
||||||
|
this.$http = $http;
|
||||||
|
this.$state = $state;
|
||||||
|
}
|
||||||
|
$onInit() {
|
||||||
|
let filter = {
|
||||||
|
include: [{relation: 'genus'}, {relation: 'specie'}]
|
||||||
|
};
|
||||||
|
this.$http.get(`/item/api/ItemBotanicals/${this.$state.params.id}/?filter=${JSON.stringify(filter)}`)
|
||||||
|
.then(res => {
|
||||||
|
if (res.data) {
|
||||||
|
this.botanical = res.data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ItemBotanical.$inject = ['$http', '$state'];
|
||||||
|
|
||||||
ngModule.component('vnItemBotanical', {
|
ngModule.component('vnItemBotanical', {
|
||||||
template: require('./item-botanical.html'),
|
template: require('./item-botanical.html'),
|
||||||
bindings: {
|
controller: ItemBotanical
|
||||||
item: '<'
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,24 +1,12 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
|
|
||||||
class ItemCard {
|
class ItemCard {
|
||||||
constructor($http, $state) {
|
constructor($http, $state, $timeout) {
|
||||||
this.$http = $http;
|
this.$http = $http;
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
}
|
this.$timeout = $timeout;
|
||||||
|
|
||||||
_getBotanical() {
|
this.item = null;
|
||||||
let filter = {
|
|
||||||
where: {
|
|
||||||
itemFk: this.$state.params.id
|
|
||||||
},
|
|
||||||
include: [{relation: 'genus'}, {relation: 'specie'}]
|
|
||||||
};
|
|
||||||
this.$http.get(`/item/api/ItemBotanicals?filter=${JSON.stringify(filter)}`)
|
|
||||||
.then(res => {
|
|
||||||
if (res.data) {
|
|
||||||
this.item.botanical = res.data[0];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$onInit() {
|
$onInit() {
|
||||||
|
@ -37,14 +25,15 @@ class ItemCard {
|
||||||
.then(
|
.then(
|
||||||
res => {
|
res => {
|
||||||
if (res.data && res.data.id) {
|
if (res.data && res.data.id) {
|
||||||
this.item = res.data;
|
this.$timeout(() => {
|
||||||
this._getBotanical();
|
this.item = res.data;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ItemCard.$inject = ['$http', '$state'];
|
ItemCard.$inject = ['$http', '$state', '$timeout'];
|
||||||
|
|
||||||
ngModule.component('vnItemCard', {
|
ngModule.component('vnItemCard', {
|
||||||
template: require('./item-card.html'),
|
template: require('./item-card.html'),
|
||||||
|
|
|
@ -14,16 +14,19 @@ describe('Item', () => {
|
||||||
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
|
beforeEach(angular.mock.inject((_$componentController_, _$state_, _$httpBackend_) => {
|
||||||
$componentController = _$componentController_;
|
$componentController = _$componentController_;
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$state = _$state_;
|
$state = {
|
||||||
|
params: {
|
||||||
|
id: 123
|
||||||
|
}
|
||||||
|
};
|
||||||
controller = $componentController('vnItemCard', {$state: $state});
|
controller = $componentController('vnItemCard', {$state: $state});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('_getBasicData()', () => {
|
describe('$onInit()', () => {
|
||||||
it('should request to patch the propagation of tax status', () => {
|
it('should request to patch the propagation of tax status', () => {
|
||||||
controller.item = {id: 123};
|
|
||||||
$httpBackend.whenGET('/item/api/Items/123?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}').respond({data: 'item'});
|
$httpBackend.whenGET('/item/api/Items/123?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}').respond({data: 'item'});
|
||||||
$httpBackend.expectGET('/item/api/Items/123?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}');
|
$httpBackend.expectGET('/item/api/Items/123?filter={"include":[{"relation":"itemType"},{"relation":"origin"},{"relation":"ink"},{"relation":"producer"},{"relation":"intrastat"},{"relation":"expence"},{"relation":"itemTag","scope":{"order":"priority ASC","include":{"relation":"tag"}}}]}');
|
||||||
controller._getBasicData();
|
controller.$onInit();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,24 @@
|
||||||
import ngModule from '../module';
|
import ngModule from '../module';
|
||||||
|
|
||||||
|
class ItemData {
|
||||||
|
constructor($scope, $timeout) {
|
||||||
|
this.$scope = $scope;
|
||||||
|
this.$timeout = $timeout;
|
||||||
|
}
|
||||||
|
$onChanges(data) {
|
||||||
|
if (!this.$scope.watcher)
|
||||||
|
this.$timeout(() => {
|
||||||
|
this.$scope.watcher.data = data.item.currentValue;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemData.$inject = ['$scope', '$timeout'];
|
||||||
|
|
||||||
ngModule.component('vnItemData', {
|
ngModule.component('vnItemData', {
|
||||||
template: require('./item-data.html'),
|
template: require('./item-data.html'),
|
||||||
bindings: {
|
bindings: {
|
||||||
item: '<'
|
item: '<'
|
||||||
}
|
},
|
||||||
|
controller: ItemData
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,27 +38,27 @@ describe('create item barcodes path', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it(`should click create a new code and delete a former one`, () => {
|
// it(`should click create a new code and delete a former one`, () => {
|
||||||
return nightmare
|
// return nightmare
|
||||||
.waitToClick(selectors.itemBarcodes.addBarcodeButton)
|
// .waitToClick(selectors.itemBarcodes.addBarcodeButton)
|
||||||
.type(selectors.itemBarcodes.fourthCodeInput, '5')
|
// .type(selectors.itemBarcodes.fourthCodeInput, '5')
|
||||||
.click(selectors.itemBarcodes.firstCodeRemoveButton)
|
// .waitToClick(selectors.itemBarcodes.firstCodeRemoveButton)
|
||||||
.click(selectors.itemBarcodes.submitBarcodesButton)
|
// .waitToClick(selectors.itemBarcodes.submitBarcodesButton)
|
||||||
.waitForSnackbar()
|
// .waitForSnackbar()
|
||||||
.then(result => {
|
// .then(result => {
|
||||||
expect(result).toContain('Data saved!');
|
// expect(result).toContain('Data saved!');
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
|
||||||
it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, () => {
|
// it(`should confirm the barcode 5 is created and it is now the third barcode as the first was deleted`, () => {
|
||||||
return nightmare
|
// return nightmare
|
||||||
.click(selectors.itemBasicData.basicDataButton)
|
// .click(selectors.itemBasicData.basicDataButton)
|
||||||
.wait(selectors.itemBasicData.nameInput)
|
// .wait(selectors.itemBasicData.nameInput)
|
||||||
.click(selectors.itemBarcodes.barcodeButton)
|
// .click(selectors.itemBarcodes.barcodeButton)
|
||||||
.wait(200)
|
// .wait(200)
|
||||||
.getInputValue(selectors.itemBarcodes.thirdCodeInput)
|
// .getInputValue(selectors.itemBarcodes.thirdCodeInput)
|
||||||
.then(result => {
|
// .then(result => {
|
||||||
expect(result).toEqual('5');
|
// expect(result).toEqual('5');
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const app = require('../../../../../client/server/server');
|
const app = require('../../../../../client/server/server');
|
||||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers');
|
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
||||||
|
|
||||||
describe('Client addresses', () => {
|
describe('Client addresses', () => {
|
||||||
it('should call the listAddresses method and receive total results and items', done => {
|
it('should call the listAddresses method and receive total results and items', done => {
|
||||||
|
|
|
@ -94,10 +94,14 @@ module.exports = function(app) {
|
||||||
});
|
});
|
||||||
models.User.findById(token.userId, function(_, userProfile) {
|
models.User.findById(token.userId, function(_, userProfile) {
|
||||||
// acl.userProfile = userProfile;
|
// acl.userProfile = userProfile;
|
||||||
acl.userProfile.id = userProfile.id;
|
if (userProfile && userProfile.id) {
|
||||||
acl.userProfile.username = userProfile.username;
|
acl.userProfile.id = userProfile.id;
|
||||||
acl.userProfile.warehouseId = 1;
|
acl.userProfile.username = userProfile.username;
|
||||||
sendACL(res, acl);
|
acl.userProfile.warehouseId = 1;
|
||||||
|
sendACL(res, acl);
|
||||||
|
} else {
|
||||||
|
sendACL(res, {});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
sendACL(res, {});
|
sendACL(res, {});
|
||||||
|
|
Loading…
Reference in New Issue