Merge branch 'dev'
This commit is contained in:
commit
7f98e1dd2f
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
|
|
@ -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 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()', () => {
|
||||
|
|
|
@ -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-vertical pad-medium>
|
||||
<vn-title vn-one margin-large-bottom>Item history</vn-title>
|
||||
|
@ -14,8 +14,8 @@
|
|||
class="list list-element text-center"
|
||||
pad-small-bottom
|
||||
ng-repeat="itemLog in index.model.instances track by itemLog.id">
|
||||
<vn-one pad-medium-h>{{::itemLog.originFk}}</vn-one>
|
||||
<vn-two pad-medium-h>{{::itemLog.userFk}}</vn-two>
|
||||
<vn-one pad-medium-h>{{::itemLog.origin.name}}</vn-one>
|
||||
<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.creationDate | date:'dd/MM/yyyy HH:mm'}}</vn-one>
|
||||
<vn-one pad-medium-h>{{::itemLog.description}}</vn-one>
|
||||
|
|
|
@ -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}'],
|
||||
|
|
|
@ -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"
|
||||
}]
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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'});
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
}
|
||||
},
|
||||
"relations": {
|
||||
"originFk": {
|
||||
"origin": {
|
||||
"type": "belongsTo",
|
||||
"model": "Origin",
|
||||
"foreignKey": "originFk"
|
||||
},
|
||||
"userFk": {
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "User",
|
||||
"foreignKey": "userFk"
|
||||
|
|
Loading…
Reference in New Issue