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() {
|
||||
this.observations.push({observationTypeFk: null, description: null, showAddIcon: true});
|
||||
this.observations.push({observationTypeFk: null, addressFk: this.address.id, description: null, showAddIcon: true});
|
||||
this._setIconAdd();
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ export default class Controller {
|
|||
}
|
||||
}
|
||||
_submitObservations(objectObservations) {
|
||||
return this.$http.post('/client/api/crudAddressObservations', objectObservations);
|
||||
return this.$http.post(`/client/api/AddressObservations/crudAddressObservations`, objectObservations);
|
||||
}
|
||||
|
||||
submit() {
|
||||
|
@ -66,9 +66,9 @@ export default class Controller {
|
|||
let submitObservations;
|
||||
let repeatedTypes = false;
|
||||
let observationsObj = {
|
||||
remove: this.observationsRemoved,
|
||||
news: [],
|
||||
modified: []
|
||||
delete: this.observationsRemoved,
|
||||
create: [],
|
||||
update: []
|
||||
};
|
||||
|
||||
for (let i = 0; i < this.observations.length; i++) {
|
||||
|
@ -84,16 +84,16 @@ export default class Controller {
|
|||
break;
|
||||
}
|
||||
|
||||
this.observationsDictionary[observation.observationTypeFk] = observation;
|
||||
|
||||
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) {
|
||||
observationsObj.modified.push(observation);
|
||||
observationsObj.update.push(observation);
|
||||
}
|
||||
|
||||
this.observationsDictionary[observation.observationTypeFk] = observation;
|
||||
}
|
||||
|
||||
submitObservations = observationsObj.modified.length > 0 || observationsObj.news.length > 0 || observationsObj.remove.length > 0;
|
||||
submitObservations = observationsObj.update.length > 0 || observationsObj.create.length > 0 || observationsObj.delete.length > 0;
|
||||
|
||||
if (repeatedTypes) {
|
||||
this.vnApp.showMessage(
|
||||
|
@ -125,8 +125,8 @@ export default class Controller {
|
|||
};
|
||||
this.$http.get(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).then(res => {
|
||||
this.observations = res.data;
|
||||
this.observations.forEach(item => {
|
||||
this.observationsDictionary[item.observationTypeFk] = {id: item.id, description: item.description};
|
||||
res.data.forEach(item => {
|
||||
this.observationsDictionary[item.observationTypeFk] = Object.assign({}, item);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,19 +15,19 @@ describe('Client', () => {
|
|||
$componentController = _$componentController_;
|
||||
$state = _$state_;
|
||||
$httpBackend = _$httpBackend_;
|
||||
$state.params.addressId = '1234';
|
||||
$state.params.addressId = '1';
|
||||
controller = $componentController('vnAddressEdit', {$state: $state});
|
||||
}));
|
||||
|
||||
it('should define and set address property', () => {
|
||||
expect(controller.address.id).toBe(1234);
|
||||
expect(controller.address.id).toBe(1);
|
||||
});
|
||||
|
||||
describe('$onInit()', () => {
|
||||
it('should perform a GET query to receive the address observations', () => {
|
||||
let filter = {where: {addressFk: 1234}, include: [{relation: 'observationType'}]};
|
||||
let json = {data: 'some notes'};
|
||||
$httpBackend.when('GET', `/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).respond(json);
|
||||
let filter = {where: {addressFk: 1}, include: {relation: 'observationType'}};
|
||||
let res = ['some notes'];
|
||||
$httpBackend.when('GET', `/client/api/AddressObservations?filter=${JSON.stringify(filter)}`).respond(res);
|
||||
$httpBackend.expectGET(`/client/api/AddressObservations?filter=${JSON.stringify(filter)}`);
|
||||
controller.$onInit();
|
||||
$httpBackend.flush();
|
||||
|
|
|
@ -149,6 +149,8 @@ export default class Watcher extends Component {
|
|||
|
||||
updateOriginalData() {
|
||||
this.orgData = this.copyInNewObject(this.data);
|
||||
if (this.form && this.form.$dirty)
|
||||
this.form.$setPristine();
|
||||
}
|
||||
|
||||
copyInNewObject(data) {
|
||||
|
|
|
@ -31,12 +31,10 @@
|
|||
order="description ASC"
|
||||
filter-search="{where: {description: {regexp: 'search'}} }"
|
||||
>
|
||||
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
|
||||
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-textfield vn-one label="Relevancy" field="$ctrl.item.relevancy" type="number"></vn-textfield>
|
||||
|
||||
</vn-horizontal>
|
||||
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one
|
||||
url="/item/api/Origins"
|
||||
|
@ -45,9 +43,13 @@
|
|||
value-field="id"
|
||||
field="$ctrl.item.originFk"
|
||||
></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-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
|
|
|
@ -27,12 +27,6 @@ describe('Item', () => {
|
|||
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()', () => {
|
||||
it(`should call submit() on the watcher then expect a callback`, () => {
|
||||
spyOn($state, 'go');
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Artículo: Items
|
|
@ -26,7 +26,7 @@ describe('Production', () => {
|
|||
it('should request to update the ticket state', () => {
|
||||
let ids = [1, 2, 3, 4];
|
||||
let stateId = 1;
|
||||
let stateName = 'the state!';
|
||||
let stateName = 'state';
|
||||
let index = [];
|
||||
controller.tickets = ['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),
|
||||
(4, 1, 4, 'Gamoras hideout', 2),
|
||||
(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