Merge branch 'dev'

This commit is contained in:
Carlos Jimenez 2018-02-07 15:06:59 +01:00
commit 7f98e1dd2f
7 changed files with 59 additions and 14 deletions

View File

@ -61,7 +61,7 @@ export default class Controller {
} }
_observationsEquals(ob1, ob2) { _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() { submit() {
@ -80,12 +80,13 @@ export default class Controller {
let observation = this.observations[i]; let observation = this.observations[i];
let isNewObservation = observation.id === undefined; let isNewObservation = observation.id === undefined;
if (types.indexOf(observation.observationTypeFk) !== -1) { if (observation.observationTypeFk && types.indexOf(observation.observationTypeFk) !== -1) {
repeatedTypes = true; repeatedTypes = true;
break; break;
} }
types.push(observation.observationTypeFk); if (observation.observationTypeFk)
types.push(observation.observationTypeFk);
if (isNewObservation && observation.observationTypeFk && observation.description) { if (isNewObservation && observation.observationTypeFk && observation.description) {
observationsObj.create.push(observation); observationsObj.create.push(observation);

View File

@ -20,7 +20,46 @@ describe('Client', () => {
})); }));
it('should define and set address property', () => { 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 in 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()', () => { describe('$onInit()', () => {

View File

@ -1,4 +1,4 @@
<mg-ajax path="/item/api/Items/getLog" options="vnIndex"></mg-ajax> <mg-ajax path="/item/api/ItemLogs/getLog" options="vnIndex"></mg-ajax>
<vn-card pad-medium> <vn-card pad-medium>
<vn-vertical pad-medium> <vn-vertical pad-medium>
<vn-title vn-one margin-large-bottom>Item history</vn-title> <vn-title vn-one margin-large-bottom>Item history</vn-title>
@ -14,8 +14,8 @@
class="list list-element text-center" class="list list-element text-center"
pad-small-bottom pad-small-bottom
ng-repeat="itemLog in index.model.instances track by itemLog.id"> ng-repeat="itemLog in index.model.instances track by itemLog.id">
<vn-one pad-medium-h>{{::itemLog.originFk}}</vn-one> <vn-one pad-medium-h>{{::itemLog.origin.name}}</vn-one>
<vn-two pad-medium-h>{{::itemLog.userFk}}</vn-two> <vn-two pad-medium-h>{{::itemLog.user.name}}</vn-two>
<vn-one pad-medium-h>{{::itemLog.action}}</vn-one> <vn-one pad-medium-h>{{::itemLog.action}}</vn-one>
<vn-one pad-medium-h>{{::itemLog.creationDate | date:'dd/MM/yyyy HH:mm'}}</vn-one> <vn-one pad-medium-h>{{::itemLog.creationDate | date:'dd/MM/yyyy HH:mm'}}</vn-one>
<vn-one pad-medium-h>{{::itemLog.description}}</vn-one> <vn-one pad-medium-h>{{::itemLog.description}}</vn-one>

View File

@ -118,10 +118,10 @@ gulp.task('docker-compose', async () => {
let services = await getServices(); let services = await getServices();
for (let service of services) { for (let service of services) {
let dockerFile = `${__dirname}/Dockerfile`; let dockerFile = `${__dirname}/${service.name}/Dockerfile`;
if (await fs.exists(`./services/${service.name}/Dockerfile`)) // if (await fs.exists(`./services/${service.name}/Dockerfile`))
dockerFile = 'Dockerfile'; // dockerFile = 'Dockerfile';
composeYml.services[service.name] = { composeYml.services[service.name] = {
environment: ['NODE_ENV=${NODE_ENV}'], environment: ['NODE_ENV=${NODE_ENV}'],

View File

@ -7,7 +7,13 @@ module.exports = Self => {
itemFk: params.itemFk itemFk: params.itemFk
}, },
skip: (params.page - 1) * params.size, skip: (params.page - 1) * params.size,
limit: params.size limit: params.size,
include: [{
relation: "origin"
},
{
relation: "user"
}]
}; };
} }
}; };

View File

@ -1,6 +1,5 @@
module.exports = function(Self) { module.exports = function(Self) {
require('../methods/item/filter.js')(Self); require('../methods/item/filter.js')(Self);
require('../methods/item/getLog.js')(Self);
Self.validatesPresenceOf('name', {message: 'Cannot be blank'}); Self.validatesPresenceOf('name', {message: 'Cannot be blank'});
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'}); Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});

View File

@ -21,12 +21,12 @@
} }
}, },
"relations": { "relations": {
"originFk": { "origin": {
"type": "belongsTo", "type": "belongsTo",
"model": "Origin", "model": "Origin",
"foreignKey": "originFk" "foreignKey": "originFk"
}, },
"userFk": { "user": {
"type": "belongsTo", "type": "belongsTo",
"model": "User", "model": "User",
"foreignKey": "userFk" "foreignKey": "userFk"