Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
853b16bd81
|
@ -41,7 +41,7 @@ export default class Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
addObservation() {
|
addObservation() {
|
||||||
this.observations.push({observationTypeFk: null, description: null, showAddIcon: true});
|
this.observations.push({observationTypeFk: null, addressFk: this.address.id, description: null, showAddIcon: true});
|
||||||
this._setIconAdd();
|
this._setIconAdd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ export default class Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_submitObservations(objectObservations) {
|
_submitObservations(objectObservations) {
|
||||||
return this.$http.post('/client/api/crudAddressObservations', objectObservations);
|
return this.$http.post(`/client/api/AddressObservations/crudAddressObservations`, objectObservations);
|
||||||
}
|
}
|
||||||
|
|
||||||
submit() {
|
submit() {
|
||||||
|
@ -66,9 +66,9 @@ export default class Controller {
|
||||||
let submitObservations;
|
let submitObservations;
|
||||||
let repeatedTypes = false;
|
let repeatedTypes = false;
|
||||||
let observationsObj = {
|
let observationsObj = {
|
||||||
remove: this.observationsRemoved,
|
delete: this.observationsRemoved,
|
||||||
news: [],
|
create: [],
|
||||||
modified: []
|
update: []
|
||||||
};
|
};
|
||||||
|
|
||||||
for (let i = 0; i < this.observations.length; i++) {
|
for (let i = 0; i < this.observations.length; i++) {
|
||||||
|
@ -84,16 +84,16 @@ export default class Controller {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.observationsDictionary[observation.observationTypeFk] = observation;
|
|
||||||
|
|
||||||
if (!observation.id && observation.observationTypeFk && observation.description) {
|
if (!observation.id && observation.observationTypeFk && observation.description) {
|
||||||
observationsObj.news.push(observation);
|
observationsObj.create.push(observation);
|
||||||
} else if (observation.id && this.observationsDictionary[observation.observationTypeFk].description !== observation.description) {
|
} else if (observation.id && this.observationsDictionary[observation.observationTypeFk].description !== observation.description) {
|
||||||
observationsObj.modified.push(observation);
|
observationsObj.update.push(observation);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
submitObservations = observationsObj.modified.length > 0 || observationsObj.news.length > 0 || observationsObj.remove.length > 0;
|
this.observationsDictionary[observation.observationTypeFk] = observation;
|
||||||
|
}
|
||||||
|
|
||||||
|
submitObservations = observationsObj.update.length > 0 || observationsObj.create.length > 0 || observationsObj.delete.length > 0;
|
||||||
|
|
||||||
if (repeatedTypes) {
|
if (repeatedTypes) {
|
||||||
this.vnApp.showMessage(
|
this.vnApp.showMessage(
|
||||||
|
@ -125,8 +125,8 @@ export default class Controller {
|
||||||
};
|
};
|
||||||
this.$http.get(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).then(res => {
|
this.$http.get(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).then(res => {
|
||||||
this.observations = res.data;
|
this.observations = res.data;
|
||||||
this.observations.forEach(item => {
|
res.data.forEach(item => {
|
||||||
this.observationsDictionary[item.observationTypeFk] = {id: item.id, description: item.description};
|
this.observationsDictionary[item.observationTypeFk] = Object.assign({}, item);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,19 +15,19 @@ describe('Client', () => {
|
||||||
$componentController = _$componentController_;
|
$componentController = _$componentController_;
|
||||||
$state = _$state_;
|
$state = _$state_;
|
||||||
$httpBackend = _$httpBackend_;
|
$httpBackend = _$httpBackend_;
|
||||||
$state.params.addressId = '1234';
|
$state.params.addressId = '1';
|
||||||
controller = $componentController('vnAddressEdit', {$state: $state});
|
controller = $componentController('vnAddressEdit', {$state: $state});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should define and set address property', () => {
|
it('should define and set address property', () => {
|
||||||
expect(controller.address.id).toBe(1234);
|
expect(controller.address.id).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('$onInit()', () => {
|
describe('$onInit()', () => {
|
||||||
it('should perform a GET query to receive the address observations', () => {
|
it('should perform a GET query to receive the address observations', () => {
|
||||||
let filter = {where: {addressFk: 1234}, include: [{relation: 'observationType'}]};
|
let filter = {where: {addressFk: 1}, include: {relation: 'observationType'}};
|
||||||
let json = {data: 'some notes'};
|
let res = ['some notes'];
|
||||||
$httpBackend.when('GET', `/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).respond(json);
|
$httpBackend.when('GET', `/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).respond(res);
|
||||||
$httpBackend.expectGET(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`);
|
$httpBackend.expectGET(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`);
|
||||||
controller.$onInit();
|
controller.$onInit();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
|
|
|
@ -149,6 +149,8 @@ export default class Watcher extends Component {
|
||||||
|
|
||||||
updateOriginalData() {
|
updateOriginalData() {
|
||||||
this.orgData = this.copyInNewObject(this.data);
|
this.orgData = this.copyInNewObject(this.data);
|
||||||
|
if (this.form && this.form.$dirty)
|
||||||
|
this.form.$setPristine();
|
||||||
}
|
}
|
||||||
|
|
||||||
copyInNewObject(data) {
|
copyInNewObject(data) {
|
||||||
|
|
|
@ -34,9 +34,7 @@
|
||||||
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
|
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-textfield vn-one label="Relevancy" field="$ctrl.item.relevancy" type="number"></vn-textfield>
|
<vn-textfield vn-one label="Relevancy" field="$ctrl.item.relevancy" type="number"></vn-textfield>
|
||||||
|
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete vn-one
|
<vn-autocomplete vn-one
|
||||||
url="/item/api/Origins"
|
url="/item/api/Origins"
|
||||||
|
@ -45,9 +43,13 @@
|
||||||
value-field="id"
|
value-field="id"
|
||||||
field="$ctrl.item.originFk"
|
field="$ctrl.item.originFk"
|
||||||
></vn-autocomplete>
|
></vn-autocomplete>
|
||||||
<vn-one></vn-one>
|
<vn-autocomplete vn-one
|
||||||
|
url="/item/api/Expences"
|
||||||
|
label="Expence"
|
||||||
|
field="$ctrl.item.expenceFk"
|
||||||
|
initial-data="$ctrl.item.expence"
|
||||||
|
></vn-autocomplete>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-button-bar>
|
<vn-button-bar>
|
||||||
|
|
|
@ -27,12 +27,6 @@ describe('Item', () => {
|
||||||
controller = $componentController('vnItemCreate', {$scope: $scope});
|
controller = $componentController('vnItemCreate', {$scope: $scope});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
it('should define and set scope, state and item properties', () => {
|
|
||||||
expect(controller.$).toEqual($scope);
|
|
||||||
expect(controller.$state).toEqual($state);
|
|
||||||
expect(controller.item).toEqual({relevancy: 0});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('onSubmit()', () => {
|
describe('onSubmit()', () => {
|
||||||
it(`should call submit() on the watcher then expect a callback`, () => {
|
it(`should call submit() on the watcher then expect a callback`, () => {
|
||||||
spyOn($state, 'go');
|
spyOn($state, 'go');
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Artículo: Items
|
|
@ -26,7 +26,7 @@ describe('Production', () => {
|
||||||
it('should request to update the ticket state', () => {
|
it('should request to update the ticket state', () => {
|
||||||
let ids = [1, 2, 3, 4];
|
let ids = [1, 2, 3, 4];
|
||||||
let stateId = 1;
|
let stateId = 1;
|
||||||
let stateName = 'the state!';
|
let stateName = 'state';
|
||||||
let index = [];
|
let index = [];
|
||||||
controller.tickets = ['ticketVal'];
|
controller.tickets = ['ticketVal'];
|
||||||
$httpBackend.whenPUT('/production/api/TicketStates/1/changeState', {tickets: ids}).respond({data: 'ticketVal'});
|
$httpBackend.whenPUT('/production/api/TicketStates/1/changeState', {tickets: ids}).respond({data: 'ticketVal'});
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
module.exports = Self => {
|
||||||
|
Self.remoteMethod('crudAddressObservations', {
|
||||||
|
description: 'create, delete or update address observations',
|
||||||
|
accessType: 'WRITE',
|
||||||
|
accepts: [
|
||||||
|
{
|
||||||
|
arg: 'observations',
|
||||||
|
type: 'Object',
|
||||||
|
require: true,
|
||||||
|
description: 'object with observations to create, delete or update, Example: {delete: [], create: [], update: []}',
|
||||||
|
http: {source: 'body'}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
returns: {
|
||||||
|
arg: 'sumAmount'
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
path: `/crudAddressObservations`,
|
||||||
|
verb: 'post'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Self.crudAddressObservations = observations => {
|
||||||
|
let promises = [];
|
||||||
|
|
||||||
|
if (observations.delete.length) {
|
||||||
|
promises.push(Self.destroyAll({id: {inq: observations.delete}}));
|
||||||
|
}
|
||||||
|
if (observations.create.length) {
|
||||||
|
promises.push(Self.create(observations.create));
|
||||||
|
}
|
||||||
|
if (observations.update.length) {
|
||||||
|
observations.update.forEach(observation => {
|
||||||
|
promises.push(Self.upsert(observation));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.all(promises);
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = function(Self) {
|
||||||
|
require('../methods/address/crudAddressObservations.js')(Self);
|
||||||
|
};
|
|
@ -0,0 +1,17 @@
|
||||||
|
CREATE TABLE vn.itemLog
|
||||||
|
SELECT * FROM vn.entryLog LIMIT 0;
|
||||||
|
|
||||||
|
ALTER TABLE `vn`.`itemLog`
|
||||||
|
ADD INDEX `itemLogItemFk_idx` (`originFk` ASC),
|
||||||
|
ADD INDEX `itemLogUserFk_idx` (`userFk` ASC);
|
||||||
|
ALTER TABLE `vn`.`itemLog`
|
||||||
|
ADD CONSTRAINT `itemLogItemFk`
|
||||||
|
FOREIGN KEY (`originFk`)
|
||||||
|
REFERENCES `vn2008`.`Articles` (`Id_Article`)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE CASCADE,
|
||||||
|
ADD CONSTRAINT `itemLogUserFk`
|
||||||
|
FOREIGN KEY (`userFk`)
|
||||||
|
REFERENCES `account`.`user` (`id`)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE CASCADE;
|
|
@ -619,3 +619,7 @@ INSERT INTO `vn`.`itemTag`(`id`,`itemFk`,`tagFk`,`value`,`priority`)
|
||||||
(3, 1, 3, 'round', 3),
|
(3, 1, 3, 'round', 3),
|
||||||
(4, 1, 4, 'Gamoras hideout', 2),
|
(4, 1, 4, 'Gamoras hideout', 2),
|
||||||
(5, 1, 5, 'Gamora', 1);
|
(5, 1, 5, 'Gamora', 1);
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`clientLog` (`id`, `originFk`, `userFk`, `action`, `description`)
|
||||||
|
VALUES
|
||||||
|
('1', '1', '1', 'insert', 'We made an change!');
|
Loading…
Reference in New Issue