From d2512271076660ec8694643323721efe360594cd Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Wed, 7 Feb 2018 13:26:21 +0100 Subject: [PATCH 1/5] changes in logic address-edit --- client/client/src/address-edit/address-edit.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/client/src/address-edit/address-edit.js b/client/client/src/address-edit/address-edit.js index 90009cbe8..7cfc8bd06 100644 --- a/client/client/src/address-edit/address-edit.js +++ b/client/client/src/address-edit/address-edit.js @@ -80,12 +80,13 @@ export default class Controller { let observation = this.observations[i]; let isNewObservation = observation.id === undefined; - if (types.indexOf(observation.observationTypeFk) !== -1) { + if (observation.observationTypeFk && types.indexOf(observation.observationTypeFk) !== -1) { repeatedTypes = true; break; } - types.push(observation.observationTypeFk); + if (observation.observationTypeFk) + types.push(observation.observationTypeFk); if (isNewObservation && observation.observationTypeFk && observation.description) { observationsObj.create.push(observation); From 87d423fd52f25b257fa5be650e711ae3352895c2 Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Wed, 7 Feb 2018 14:47:08 +0100 Subject: [PATCH 2/5] new testing in address-edit --- .../client/src/address-edit/address-edit.js | 2 +- .../src/address-edit/address-edit.spec.js | 41 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/client/client/src/address-edit/address-edit.js b/client/client/src/address-edit/address-edit.js index 7cfc8bd06..3046b2733 100644 --- a/client/client/src/address-edit/address-edit.js +++ b/client/client/src/address-edit/address-edit.js @@ -61,7 +61,7 @@ export default class Controller { } _observationsEquals(ob1, ob2) { - return ob1.observationTypeFk === ob2.observationTypeFk && ob1.description === ob2.description; + return ob1.id === ob2.id && ob1.observationTypeFk === ob2.observationTypeFk && ob1.description === ob2.description; } submit() { diff --git a/client/client/src/address-edit/address-edit.spec.js b/client/client/src/address-edit/address-edit.spec.js index 18fff508f..8f14a2ec9 100644 --- a/client/client/src/address-edit/address-edit.spec.js +++ b/client/client/src/address-edit/address-edit.spec.js @@ -20,7 +20,46 @@ describe('Client', () => { })); it('should define and set address property', () => { - expect(controller.address.id).toBe(1); + expect(controller.address.id).toEqual(1); + }); + + describe('removeObservation(index)', () => { + it('should remove an observation that occupies the index given and restore showAddIcon properties', () => { + let index = 2; + controller.observations = [ + {id: 1, description: 'Spiderman rocks', showAddIcon: false}, + {id: 2, description: 'Batman sucks', showAddIcon: false}, + {id: 3, description: 'Ironman rules', showAddIcon: true} + ]; + + spyOn(controller, '_setIconAdd').and.callThrough(); + + controller.removeObservation(index); + + expect(controller._setIconAdd).toHaveBeenCalledWith(); + expect(controller.observations.length).toEqual(2); + expect(controller.observations[0].showAddIcon).toBeFalsy(); + expect(controller.observations[1].showAddIcon).toBeTruthy(); + expect(controller.observations[index]).toBe(undefined); + }); + }); + + describe('_observationsEquals', () => { + it('should return true if two observations are equals independent of control attributes', () => { + let ob1 = {id: 1, observationTypeFk: 1, description: 'Spiderman rocks', showAddIcon: true}; + let ob2 = {id: 1, observationTypeFk: 1, description: 'Spiderman rocks', showAddIcon: false}; + let equals = controller._observationsEquals(ob2, ob1); + + expect(equals).toBeTruthy(); + }); + + it('should return false if two observations are not equals independent of control attributes', () => { + let ob1 = {id: 1, observationTypeFk: 1, description: 'Spiderman rocks', showAddIcon: true}; + let ob2 = {id: 1, observationTypeFk: 1, description: 'Spiderman sucks', showAddIcon: true}; + let equals = controller._observationsEquals(ob2, ob1); + + expect(equals).toBeFalsy(); + }); }); describe('$onInit()', () => { From 2cc6dfd55353dcd8d880d47dac4cdd46502ee7ba Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Wed, 7 Feb 2018 14:48:11 +0100 Subject: [PATCH 3/5] changes in last test --- client/client/src/address-edit/address-edit.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/client/src/address-edit/address-edit.spec.js b/client/client/src/address-edit/address-edit.spec.js index 8f14a2ec9..5c41d653c 100644 --- a/client/client/src/address-edit/address-edit.spec.js +++ b/client/client/src/address-edit/address-edit.spec.js @@ -24,7 +24,7 @@ describe('Client', () => { }); describe('removeObservation(index)', () => { - it('should remove an observation that occupies the index given and restore showAddIcon properties', () => { + it('should remove an observation that occupies in the index given and restore showAddIcon properties', () => { let index = 2; controller.observations = [ {id: 1, description: 'Spiderman rocks', showAddIcon: false}, From d06ffba8b93d290f26aad288911c56aa7d630e7d Mon Sep 17 00:00:00 2001 From: Vicente Falco Date: Wed, 7 Feb 2018 15:02:16 +0100 Subject: [PATCH 4/5] gulp docker --- gulpfile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 3e36a02c2..311aa2131 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -118,10 +118,10 @@ gulp.task('docker-compose', async () => { let services = await getServices(); for (let service of services) { - let dockerFile = `${__dirname}/Dockerfile`; + let dockerFile = `${__dirname}/${service.name}/Dockerfile`; - if (await fs.exists(`./services/${service.name}/Dockerfile`)) - dockerFile = 'Dockerfile'; + // if (await fs.exists(`./services/${service.name}/Dockerfile`)) + // dockerFile = 'Dockerfile'; composeYml.services[service.name] = { environment: ['NODE_ENV=${NODE_ENV}'], From 03faa09284d1fdfe192968a52371b92e4d5dcdd1 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez <=> Date: Wed, 7 Feb 2018 15:06:21 +0100 Subject: [PATCH 5/5] item history functionality, awaiting for clientfilters refactor --- client/item/src/history/item-history.html | 6 +++--- services/item/common/methods/item/getLog.js | 8 +++++++- services/item/common/models/item.js | 1 - services/item/common/models/itemLog.json | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/client/item/src/history/item-history.html b/client/item/src/history/item-history.html index fe1c1faf7..3409dc04b 100644 --- a/client/item/src/history/item-history.html +++ b/client/item/src/history/item-history.html @@ -1,4 +1,4 @@ - + Item history @@ -14,8 +14,8 @@ class="list list-element text-center" pad-small-bottom ng-repeat="itemLog in index.model.instances track by itemLog.id"> - {{::itemLog.originFk}} - {{::itemLog.userFk}} + {{::itemLog.origin.name}} + {{::itemLog.user.name}} {{::itemLog.action}} {{::itemLog.creationDate | date:'dd/MM/yyyy HH:mm'}} {{::itemLog.description}} diff --git a/services/item/common/methods/item/getLog.js b/services/item/common/methods/item/getLog.js index 3b214e5c8..3c0c1e413 100644 --- a/services/item/common/methods/item/getLog.js +++ b/services/item/common/methods/item/getLog.js @@ -7,7 +7,13 @@ module.exports = Self => { itemFk: params.itemFk }, skip: (params.page - 1) * params.size, - limit: params.size + limit: params.size, + include: [{ + relation: "origin" + }, + { + relation: "user" + }] }; } }; diff --git a/services/item/common/models/item.js b/services/item/common/models/item.js index 3cbc622bd..2c193b587 100644 --- a/services/item/common/models/item.js +++ b/services/item/common/models/item.js @@ -1,6 +1,5 @@ module.exports = function(Self) { require('../methods/item/filter.js')(Self); - require('../methods/item/getLog.js')(Self); Self.validatesPresenceOf('name', {message: 'Cannot be blank'}); Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'}); diff --git a/services/item/common/models/itemLog.json b/services/item/common/models/itemLog.json index 63777113f..60a105dff 100644 --- a/services/item/common/models/itemLog.json +++ b/services/item/common/models/itemLog.json @@ -21,12 +21,12 @@ } }, "relations": { - "originFk": { + "origin": { "type": "belongsTo", "model": "Origin", "foreignKey": "originFk" }, - "userFk": { + "user": { "type": "belongsTo", "model": "User", "foreignKey": "userFk"