Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
f84bf44550
|
@ -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,11 +80,12 @@ 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;
|
||||
}
|
||||
|
||||
if (observation.observationTypeFk)
|
||||
types.push(observation.observationTypeFk);
|
||||
|
||||
if (isNewObservation && observation.observationTypeFk && observation.description) {
|
||||
|
|
|
@ -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,5 +1,4 @@
|
|||
<mg-ajax path="/item/api/items/1/getLog"></mg-ajax>
|
||||
<!-- <mg-ajax path="/item/api/history/{{edit.params.id}}/sumAmount" options="mgEdit"></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>
|
||||
|
@ -15,19 +14,17 @@
|
|||
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>
|
||||
</vn-horizontal>
|
||||
</vn-one>
|
||||
<vn-one class="text-center pad-small-v" ng-if="index.model.count === 0" translate>No results</vn-one>
|
||||
<vn-horizontal vn-one class="list list-footer text-center">
|
||||
<vn-one pad-medium-h></vn-one>
|
||||
<vn-two pad-medium-h></vn-two>
|
||||
<vn-one pad-medium-h></vn-one>
|
||||
</vn-horizontal>
|
||||
<vn-paging margin-large-top vn-one index="index" total="index.model.count"></vn-paging>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
|
|
12
gulpfile.js
12
gulpfile.js
|
@ -11,6 +11,10 @@ const exec = require('child_process').exec;
|
|||
// Configuration
|
||||
|
||||
const isWindows = /^win/.test(process.platform);
|
||||
|
||||
if (gutil.env.NODE_ENV)
|
||||
process.env.NODE_ENV = gutil.env.NODE_ENV;
|
||||
|
||||
const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'development';
|
||||
|
||||
const langs = ['es', 'en'];
|
||||
|
@ -118,17 +122,17 @@ 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}'],
|
||||
container_name: `\${BRANCH_NAME}-${service.name}`,
|
||||
image: `${service.name}:\${TAG}`,
|
||||
build: {
|
||||
context: `./services/${service.name}`,
|
||||
context: `./services`,
|
||||
dockerfile: dockerFile
|
||||
},
|
||||
ports: [`${defaultPort}:${service.port}`]
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
FROM node:8.9.4
|
||||
|
||||
COPY . /app
|
||||
COPY ../loopback /loopback
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install
|
||||
RUN npm -g install pm2
|
||||
|
||||
CMD ["pm2-docker", "./server/server.js"]
|
|
@ -0,0 +1,12 @@
|
|||
FROM node:8.9.4
|
||||
|
||||
COPY . /app
|
||||
COPY ../loopback /loopback
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install
|
||||
RUN npm -g install pm2
|
||||
|
||||
CMD ["pm2-docker", "./server/server.js"]
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
FROM node:8.9.4
|
||||
|
||||
COPY . /app
|
||||
COPY ../loopback /loopback
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install
|
||||
RUN npm -g install pm2
|
||||
|
||||
CMD ["pm2-docker", "./server/server.js"]
|
||||
|
|
@ -1,27 +1,19 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('itemLog', {
|
||||
description: 'Returns the item changes log',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
description: 'The item id',
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
arg: 'data',
|
||||
type: ['Object'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/itemLog`,
|
||||
verb: 'get'
|
||||
}
|
||||
});
|
||||
Self.installMethod('getLog', filterParams);
|
||||
|
||||
Self.itemLog = itemFk => {
|
||||
let query = `SELECT * FROM vn.itemLog WHERE itemFk = ?`;
|
||||
return Self.rawSql(query, [itemFk]);
|
||||
function filterParams(params) {
|
||||
return {
|
||||
where: {
|
||||
itemFk: params.itemFk
|
||||
},
|
||||
skip: (params.page - 1) * 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'});
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function(Self) {
|
||||
require('../methods/item/getLog.js')(Self);
|
||||
};
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"name": "ItemLog",
|
||||
"base": "VnModel",
|
||||
"options": {
|
||||
"mysql": {
|
||||
"table": "itemLog",
|
||||
"database": "vn"
|
||||
}
|
||||
},
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "Date"
|
||||
},
|
||||
"description": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
"origin": {
|
||||
"type": "belongsTo",
|
||||
"model": "Origin",
|
||||
"foreignKey": "originFk"
|
||||
},
|
||||
"user": {
|
||||
"type": "belongsTo",
|
||||
"model": "User",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,5 +34,8 @@
|
|||
},
|
||||
"Tag": {
|
||||
"dataSource": "vn"
|
||||
},
|
||||
"ItemLog": {
|
||||
"dataSource": "vn"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
FROM node:8.9.4
|
||||
|
||||
COPY . /app
|
||||
COPY ../loopback /loopback
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install
|
||||
RUN npm -g install pm2
|
||||
|
||||
CMD ["pm2-docker", "./server/server.js"]
|
|
@ -0,0 +1,11 @@
|
|||
FROM node:8.9.4
|
||||
|
||||
COPY . /app
|
||||
COPY ../loopback /loopback
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install
|
||||
RUN npm -g install pm2
|
||||
|
||||
CMD ["pm2-docker", "./server/server.js"]
|
|
@ -0,0 +1,11 @@
|
|||
FROM node:8.9.4
|
||||
|
||||
COPY . /app
|
||||
COPY ../loopback /loopback
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install
|
||||
RUN npm -g install pm2
|
||||
|
||||
CMD ["pm2-docker", "./server/server.js"]
|
|
@ -0,0 +1,11 @@
|
|||
FROM node:8.9.4
|
||||
|
||||
COPY . /app
|
||||
COPY ../loopback /loopback
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install
|
||||
RUN npm -g install pm2
|
||||
|
||||
CMD ["pm2-docker", "./server/server.js"]
|
|
@ -0,0 +1,11 @@
|
|||
FROM node:8.9.4
|
||||
|
||||
COPY . /app
|
||||
COPY ../loopback /loopback
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN npm install
|
||||
RUN npm -g install pm2
|
||||
|
||||
CMD ["pm2-docker", "./server/server.js"]
|
|
@ -36,4 +36,3 @@ jasmine.addReporter(new SpecReporter({
|
|||
}));
|
||||
|
||||
jasmine.execute();
|
||||
|
||||
|
|
Loading…
Reference in New Issue