Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2733-supplier_descriptor_icon
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
59882cca77
|
@ -0,0 +1,4 @@
|
||||||
|
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
|
||||||
|
VALUES
|
||||||
|
('Genus', '*', 'WRITE', 'ALLOW', 'ROLE', 'logisticBoss'),
|
||||||
|
('Specie', '*', 'WRITE', 'ALLOW', 'ROLE', 'logisticBoss');
|
|
@ -22,12 +22,6 @@
|
||||||
"principalType": "ROLE",
|
"principalType": "ROLE",
|
||||||
"principalId": "$everyone",
|
"principalId": "$everyone",
|
||||||
"permission": "ALLOW"
|
"permission": "ALLOW"
|
||||||
},
|
|
||||||
{
|
|
||||||
"accessType": "WRITE",
|
|
||||||
"principalType": "ROLE",
|
|
||||||
"principalId": "logisticBoss",
|
|
||||||
"permission": "ALLOW"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -22,12 +22,6 @@
|
||||||
"principalType": "ROLE",
|
"principalType": "ROLE",
|
||||||
"principalId": "$everyone",
|
"principalId": "$everyone",
|
||||||
"permission": "ALLOW"
|
"permission": "ALLOW"
|
||||||
},
|
|
||||||
{
|
|
||||||
"accessType": "WRITE",
|
|
||||||
"principalType": "ROLE",
|
|
||||||
"principalId": "logisticBoss",
|
|
||||||
"permission": "ALLOW"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -17,7 +17,8 @@
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
vn-tooltip="New genus"
|
vn-tooltip="New genus"
|
||||||
ng-click="$ctrl.showGenus($event)"
|
ng-click="$ctrl.showGenus($event)"
|
||||||
vn-acl="logisticBoss">
|
vn-acl="logisticBoss"
|
||||||
|
vn-acl-action="remove">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</append>
|
</append>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
@ -38,7 +39,8 @@
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
vn-tooltip="New species"
|
vn-tooltip="New species"
|
||||||
ng-click="$ctrl.showSpecies($event)"
|
ng-click="$ctrl.showSpecies($event)"
|
||||||
vn-acl="logisticBoss">
|
vn-acl="logisticBoss"
|
||||||
|
vn-acl-action="remove">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</append>
|
</append>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
|
@ -61,6 +63,7 @@
|
||||||
<!-- Create new genus dialog -->
|
<!-- Create new genus dialog -->
|
||||||
<vn-dialog class="edit"
|
<vn-dialog class="edit"
|
||||||
vn-id="genus"
|
vn-id="genus"
|
||||||
|
on-response="$ctrl.onGenusResponse($response)"
|
||||||
on-accept="$ctrl.onGenusAccept()"
|
on-accept="$ctrl.onGenusAccept()"
|
||||||
message="New genus">
|
message="New genus">
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
|
@ -80,6 +83,7 @@
|
||||||
<!-- Create new species dialog -->
|
<!-- Create new species dialog -->
|
||||||
<vn-dialog class="edit"
|
<vn-dialog class="edit"
|
||||||
vn-id="species"
|
vn-id="species"
|
||||||
|
on-response="$ctrl.onSpeciesResponse($response)"
|
||||||
on-accept="$ctrl.onSpeciesAccept()"
|
on-accept="$ctrl.onSpeciesAccept()"
|
||||||
message="New species">
|
message="New species">
|
||||||
<tpl-body>
|
<tpl-body>
|
||||||
|
|
|
@ -33,6 +33,7 @@ class Controller extends Section {
|
||||||
this.$http.post(`genera`, this.data).then(res => {
|
this.$http.post(`genera`, this.data).then(res => {
|
||||||
this.vnApp.showMessage(this.$t('The genus has been created'));
|
this.vnApp.showMessage(this.$t('The genus has been created'));
|
||||||
this.emit('response', {$response: res.data});
|
this.emit('response', {$response: res.data});
|
||||||
|
this.onGenusResponse(res.data);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.vnApp.showError(this.$t(e.message));
|
this.vnApp.showError(this.$t(e.message));
|
||||||
|
@ -44,11 +45,12 @@ class Controller extends Section {
|
||||||
onSpeciesAccept() {
|
onSpeciesAccept() {
|
||||||
try {
|
try {
|
||||||
if (!this.data.name)
|
if (!this.data.name)
|
||||||
throw new Error(`The name of the specie can't be empty`);
|
throw new Error(`The name of the species can't be empty`);
|
||||||
|
|
||||||
this.$http.post(`species`, this.data).then(res => {
|
this.$http.post(`species`, this.data).then(res => {
|
||||||
this.vnApp.showMessage(this.$t('The specie has been created'));
|
this.vnApp.showMessage(this.$t('The species has been created'));
|
||||||
this.emit('response', {$response: res.data});
|
this.emit('response', {$response: res.data});
|
||||||
|
this.onSpeciesResponse(res.data);
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.vnApp.showError(this.$t(e.message));
|
this.vnApp.showError(this.$t(e.message));
|
||||||
|
@ -78,6 +80,14 @@ class Controller extends Section {
|
||||||
this.$.watcher.updateOriginalData();
|
this.$.watcher.updateOriginalData();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onGenusResponse(response) {
|
||||||
|
this.botanical.genusFk = response.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSpeciesResponse(response) {
|
||||||
|
this.botanical.specieFk = response.id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnItemBotanical', {
|
ngModule.vnComponent('vnItemBotanical', {
|
||||||
|
|
|
@ -30,6 +30,11 @@ describe('vnItemBotanical', () => {
|
||||||
}};
|
}};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
const response = {data: 'MyResult'};
|
||||||
|
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond(response);
|
||||||
|
});
|
||||||
|
|
||||||
describe('showGenus()', () => {
|
describe('showGenus()', () => {
|
||||||
it('should do nothing in genus field if it default is prevented', () => {
|
it('should do nothing in genus field if it default is prevented', () => {
|
||||||
const event = {
|
const event = {
|
||||||
|
@ -45,7 +50,7 @@ describe('vnItemBotanical', () => {
|
||||||
expect(controller.$.genus.show).not.toHaveBeenCalledWith();
|
expect(controller.$.genus.show).not.toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call preventDefault() and show() in genus field when the default is not prevented', () => {
|
it('should call show function in genus field when the default is not prevented', () => {
|
||||||
const event = {
|
const event = {
|
||||||
defaultPrevented: false,
|
defaultPrevented: false,
|
||||||
preventDefault: () => {}
|
preventDefault: () => {}
|
||||||
|
@ -76,7 +81,7 @@ describe('vnItemBotanical', () => {
|
||||||
expect(controller.$.species.show).not.toHaveBeenCalledWith();
|
expect(controller.$.species.show).not.toHaveBeenCalledWith();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call preventDefault() and show() in species field when the default is not prevented', () => {
|
it('should call show function in species field when the default is not prevented', () => {
|
||||||
const event = {
|
const event = {
|
||||||
defaultPrevented: false,
|
defaultPrevented: false,
|
||||||
preventDefault: () => {}
|
preventDefault: () => {}
|
||||||
|
@ -93,7 +98,7 @@ describe('vnItemBotanical', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onGenusAccept()', () => {
|
describe('onGenusAccept()', () => {
|
||||||
it('should throw an error if there is no name in the genus name field', () => {
|
it('should throw an error if the item botanical has no genus name', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
|
||||||
controller.data = {};
|
controller.data = {};
|
||||||
|
@ -103,11 +108,9 @@ describe('vnItemBotanical', () => {
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the genus can't be empty`);
|
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the genus can't be empty`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do add the new genus', () => {
|
it('should add the new genus', () => {
|
||||||
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond({});
|
|
||||||
$httpBackend.resetExpectations();
|
|
||||||
|
|
||||||
controller.data = {
|
controller.data = {
|
||||||
|
id: 4,
|
||||||
name: 'Anilius'
|
name: 'Anilius'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,25 +118,27 @@ describe('vnItemBotanical', () => {
|
||||||
|
|
||||||
controller.onGenusAccept();
|
controller.onGenusAccept();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
controller.onGenusResponse(controller.data);
|
||||||
|
|
||||||
|
expect(controller.botanical.genusFk).toEqual(controller.data.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onSpeciesAccept()', () => {
|
describe('onSpeciesAccept()', () => {
|
||||||
it('should throw an error if there is no name in the specie name field', () => {
|
it('should throw an error if the item botanical has no species name', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showMessage');
|
jest.spyOn(controller.vnApp, 'showMessage');
|
||||||
|
|
||||||
controller.data = {};
|
controller.data = {};
|
||||||
|
|
||||||
controller.onSpeciesAccept();
|
controller.onSpeciesAccept();
|
||||||
|
|
||||||
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the specie can't be empty`);
|
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The name of the species can't be empty`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should do add the new specie', () => {
|
it('should add the new species', () => {
|
||||||
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond({});
|
|
||||||
$httpBackend.resetExpectations();
|
|
||||||
|
|
||||||
controller.data = {
|
controller.data = {
|
||||||
|
id: 2,
|
||||||
name: 'Spasiva'
|
name: 'Spasiva'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -141,20 +146,17 @@ describe('vnItemBotanical', () => {
|
||||||
|
|
||||||
controller.onSpeciesAccept();
|
controller.onSpeciesAccept();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
controller.onSpeciesResponse(controller.data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it('should make an HTTP POST request to save the genus and species data', () => {
|
it('should make HTTP POST request to save the genus and species data', () => {
|
||||||
$httpBackend.whenRoute('GET', 'ItemBotanicals').respond({});
|
|
||||||
$httpBackend.resetExpectations();
|
|
||||||
|
|
||||||
jest.spyOn(controller.$.watcher, 'updateOriginalData');
|
jest.spyOn(controller.$.watcher, 'updateOriginalData');
|
||||||
jest.spyOn(controller.$.watcher, 'check');
|
jest.spyOn(controller.$.watcher, 'check');
|
||||||
jest.spyOn(controller.$.watcher, 'notifySaved');
|
jest.spyOn(controller.$.watcher, 'notifySaved');
|
||||||
|
|
||||||
controller.botanical = [{itemFk: 5, genusFk: 3, specieFk: 2}];
|
$httpBackend.expectPATCH('ItemBotanicals').respond();
|
||||||
$httpBackend.expectPATCH('ItemBotanicals', controller.botanical).respond({});
|
|
||||||
controller.onSubmit();
|
controller.onSubmit();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
@ -165,13 +167,11 @@ describe('vnItemBotanical', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getBotanicalData()', () => {
|
describe('getBotanicalData()', () => {
|
||||||
it('should get the item data from itemBotanical', () => {
|
it('should get the species and genus data references of the item', () => {
|
||||||
const response = ['MyResult'];
|
|
||||||
$httpBackend.whenRoute('GET', `ItemBotanicals`).respond(response);
|
|
||||||
controller.getBotanicalData();
|
controller.getBotanicalData();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
||||||
expect(controller.botanical).toEqual(response[0]);
|
expect(controller.botanical).toEqual(controller.$params);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
The genus has been created: El genus ha sido creado
|
The genus has been created: El genus ha sido creado
|
||||||
The specie has been created: La especie ha sido creada
|
The species has been created: La especie ha sido creada
|
||||||
Latin species name: Nombre de la especie en latín
|
Latin species name: Nombre de la especie en latín
|
||||||
Latin genus name: Nombre del genus en latín
|
Latin genus name: Nombre del genus en latín
|
||||||
Species: Especie
|
Species: Especie
|
Loading…
Reference in New Issue