Merge branch 'dev' of https://git.verdnatura.es/salix into dev

This commit is contained in:
gerard 2018-08-07 15:41:42 +02:00
commit 4c45db1c16
16 changed files with 272 additions and 17 deletions

1
client/claim/index.js Normal file
View File

@ -0,0 +1 @@
export * from './src';

37
client/claim/routes.json Normal file
View File

@ -0,0 +1,37 @@
{
"module": "claim",
"name": "Claims",
"icon": "icon-claims",
"validations": true,
"routes": [
{
"url": "/claim",
"state": "claim",
"abstract": true,
"component": "ui-view",
"description": "Claims"
},
{
"url": "/index?q",
"state": "claim.index",
"component": "vn-claim-index",
"description": "Listado",
"acl": ["developer"]
},
{
"url": "/:id",
"state": "claim.card",
"abstract": true,
"component": "vn-claim-card"
},
{
"url": "/summary",
"state": "claim.card.summary",
"component": "vn-claim-summary",
"description": "Summary",
"params": {
"claim": "$ctrl.claim"
}
}
]
}

View File

@ -0,0 +1,7 @@
export * from './module';
import './index/';
/*
import './card';
import './descriptor';
import './summary'; */

View File

@ -0,0 +1,59 @@
<vn-crud-model
vn-id="model"
url="/claim/api/Claims"
filter="::$ctrl.filter"
limit="20"
data="claims"
auto-load="false">
</vn-crud-model>
<div margin-medium>
<div class="vn-list">
<vn-card pad-medium-h>
<vn-searchbar
panel="vn-ticket-search-panel"
model="model"
expr-builder="$ctrl.exprBuilder(param, value)">
</vn-searchbar>
</vn-card>
</div>
<vn-card margin-medium-v pad-medium>
<vn-table model="model">
<vn-thead>
<vn-tr>
<vn-th field="id" number>Id</vn-th>
<vn-th field="clientFk" number>Client Id</vn-th>
<vn-th field="clientFk">Client</vn-th>
<vn-th field="created">Created</vn-th>
<vn-th field="workerFk">Worker</vn-th>
<vn-th field="observation">Observation</vn-th>
<vn-th field="claimResponsibleFk">Responsible</vn-th>
<vn-th field="claimStateFk">State</vn-th>
<vn-th></vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr ng-repeat="claim in claims">
<vn-td number>{{::claim.id}}</vn-td>
<vn-td number>{{::claim.client.id}}</vn-td>
<vn-td>{{::claim.client.name}}</vn-td>
<vn-td>{{::claim.created | date:'dd/MM/yyyy'}}</vn-td>
<vn-td>{{::claim.worker.firstName}} {{::claim.worker.name}}</vn-td>
<vn-td>{{::claim.observation}}</vn-td>
<vn-td>{{::claim.claimResponsible.description}}</vn-td>
<vn-td>{{::claim.claimState.description}}</vn-td>
<vn-td>
<vn-icon-button
ng-click="$ctrl.preview($event, ticket)"
vn-tooltip="Preview"
icon="desktop_windows">
</vn-icon-button>
</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
</vn-card>
<vn-pagination
model="model"
scroll-selector="ui-view">
</vn-pagination>
</div>

View File

@ -0,0 +1,45 @@
import ngModule from '../module';
export default class Controller {
constructor($scope) {
this.$ = $scope;
this.ticketSelected = null;
this.filter = {
include: [
{
relation: 'client',
scope: {
fields: ['name']
}
},
{
relation: 'worker',
scope: {
fields: ['firstName', 'name']
}
},
{
relation: 'claimResponsible',
scope: {
fields: ['description']
}
},
{
relation: 'claimState',
scope: {
fields: ['description']
}
}
],
order: 'claimStateFk ASC, created DESC'
};
}
}
Controller.$inject = ['$scope'];
ngModule.component('vnClaimIndex', {
template: require('./index.html'),
controller: Controller
});

View File

@ -0,0 +1,9 @@
#Ordenar alfabeticamente
Client Id: Id cliente
Observation: Observación
Responsible: Responsable
#sections
Claims: Reclamaciones
List: Listado
Summary: Vista previa

View File

@ -0,0 +1,5 @@
import {ng} from 'vendor';
import 'core';
const ngModule = ng.module('claim', ['vnCore']);
export default ngModule;

View File

@ -8,3 +8,4 @@ salix: []
#route: []
ticket: [item, client]
order: [item, ticket]
claim: [item, client]

View File

@ -9,14 +9,14 @@
"state": "order",
"abstract": true,
"component": "ui-view",
"description": "Orders",
"acl": ["developer"]
"description": "Orders"
},
{
"url": "/index?q",
"state": "order.index",
"component": "vn-order-index",
"description": "List"
"description": "List",
"acl": ["developer"]
},
{
"url": "/:id",

View File

@ -5,9 +5,10 @@ Client Frozen: Cliente congelado
Client has debt: Cliente con riesgo
Client inactive: Cliente inactivo
Client not checked: Cliente no comprobado
Clients: Clientes
credit: Crédito
creditInsurance: Crédito Asegurado
Clients: Clientes
Claims: Reclamaciones
Data saved!: ¡Datos guardados!
Home: Inicio
Items: Artículos
@ -16,13 +17,13 @@ Logout: Cerrar sesión
Modules access : Acceso a módulos
Notifications: Notificaciones
name: Nombre
Orders: Pedidos
phone: Teléfono
Preview: Vista previa
Production : Producción
Profile: Perfil
Production : Producción
Push on applications menu: Para abrir un módulo pulsa en el menú de aplicaciones
Return to module index: Volver a la página principal del módulo
Routes: Rutas
What is new: Novedades de la versión
Web Account inactive: Sin acceso Web
Orders: Pedidos

View File

@ -12,5 +12,7 @@ export default {
ticket:
cb => require.ensure([], () => cb(require('ticket'))),
order:
cb => require.ensure([], () => cb(require('order')))
cb => require.ensure([], () => cb(require('order'))),
claim:
cb => require.ensure([], () => cb(require('claim')))
};

View File

@ -0,0 +1,15 @@
const app = require(`${servicesDir}/client/server/server`);
describe('loopback model Account', () => {
it('should return true if the user has the given role', async() => {
let result = await app.models.Account.hasRole(1, 'employee');
expect(result).toBeTruthy();
});
it('should return false if the user doesnt have the given role', async() => {
let result = await app.models.Account.hasRole(1, 'administrator');
expect(result).toBeFalsy();
});
});

View File

@ -0,0 +1,38 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket model TicketTracking', () => {
let ticketTrackingId;
afterAll(async() => {
await app.models.TicketPackaging.destroyById(ticketTrackingId);
});
it('should save a ticketTraing as the quantity is greater than 0', async() => {
let result = await app.models.TicketPackaging.create({ticketFk: 1, quantity: 1, packagingFk: 1});
expect(result).toBeTruthy();
ticketTrackingId = result.id;
});
it('should return an error as the quantity is 0', async() => {
let error;
try {
await app.models.TicketPackaging.create({ticketFk: 1, quantity: 0, packagingFk: 1});
} catch (e) {
error = e;
}
expect(error.message).toContain('Enter an integer different to zero');
});
it('should return an error as the quantity isnt a number', async() => {
let error;
try {
await app.models.TicketPackaging.create({ticketFk: 1, quantity: 'random string', packagingFk: 1});
} catch (e) {
error = e;
}
expect(error.message).toContain('Enter an integer different to zero');
});
});

View File

@ -0,0 +1,24 @@
const app = require(`${servicesDir}/ticket/server/server`);
describe('ticket model TicketTracking', () => {
let ticketTrackingId;
afterAll(async() => {
await app.models.TicketTracking.destroyById(ticketTrackingId);
});
it('should store the worker id into the instance', async() => {
let originalTrackings = await app.models.TicketTracking.find({where: {ticketFk: 1}});
expect(originalTrackings.length).toEqual(1);
await app.models.TicketTracking.create({ticketFk: 1, stateFk: 20});
let result = await app.models.TicketTracking.find({where: {ticketFk: 1}});
let workerFk = result[1].workerFk;
ticketTrackingId = result[1].id;
expect(result.length).toEqual(2);
expect(workerFk).toEqual(1);
});
});

View File

@ -6,9 +6,9 @@ module.exports = function(Self) {
Self.observe('before save', async function(ctx) {
let models = Self.app.models;
let token = ctx.options.accessToken;
let userId = token && token.userId;
let currentUserId = token && token.userId;
let user = await models.Worker.findOne({where: {userFk: userId}});
ctx.instance.workerFk = user.id;
let worker = await models.Worker.findOne({where: {userFk: currentUserId}});
ctx.instance.workerFk = worker.id;
});
};

View File

@ -1,3 +1,4 @@
const fs = require('fs-extra');
process.on('warning', warning => {
console.log(warning.name);
console.log(warning.message);
@ -18,15 +19,25 @@ let environment = require('gulp-env');
environment(".env.json");
let serviceList = fs.readdirSync(servicesDir);
let serviceSpecs = [
'auth/server/**/*[sS]pec.js'
];
const exclude = ['auth', 'salix'];
for (let service of serviceList) {
try {
let serviceDir = fs.readdirSync(`${servicesDir}/${service}`);
for (let file of serviceDir) {
if (file === 'server' && exclude.indexOf(service) == -1)
serviceSpecs.push(`${service}/common/**/*[sS]pec.js`);
}
} catch (e) {}
}
jasmine.loadConfig({
spec_dir: 'services',
spec_files: [
'auth/server/**/*[sS]pec.js',
'client/common/**/*[sS]pec.js',
'item/common/**/*[sS]pec.js',
'ticket/common/**/*[sS]pec.js',
'loopback/common/**/*[sS]pec.js'
],
spec_files: serviceSpecs,
helpers: [
'/services/utils/jasmineHelpers.js'
]