#996 worker.descriptor

This commit is contained in:
Juan Ferrer 2019-01-29 21:00:27 +01:00
parent d46575a072
commit e553d63492
10 changed files with 86 additions and 36 deletions

View File

@ -7,24 +7,19 @@
}
},
"properties": {
"code": {
"userFk": {
"type": "Number",
"id": true,
"description": "The user id",
"mysql": {
"columnName": "extension"
"columnName": "user_id"
}
},
"password": {
"type": "string",
"mysql": {
"columnName": "secret"
}
"extension": {
"type": "String"
},
"name": {
"type": "string",
"mysql": {
"columnName": "caller_id"
}
"secret": {
"type": "String"
}
},
"relations": {

View File

@ -73,7 +73,7 @@ describe('Ticket Create new tracking state path', () => {
.waitToClick(selectors.createStateView.saveStateButton)
.waitForLastSnackbar();
expect(result).toEqual(`You don't have enough privileges to change the state of this ticket`);
expect(result).toEqual(`You don't have enough privileges`);
});
it(`should attempt to create an state for the type salesPerson has rights but fail as worker is blank`, async() => {

View File

@ -45,10 +45,11 @@ function backWatch(done) {
// XXX: Workaround to avoid nodemon bug
// https://github.com/remy/nodemon/issues/1346
let sleepBin = isWindows ? '' : 'sleep 1 &&';
let commands = ['node --inspect ./node_modules/gulp/bin/gulp.js'];
if (!isWindows) commands.unshift('sleep 1');
nodemon({
exec: `${sleepBin}node --inspect ./node_modules/gulp/bin/gulp.js`,
exec: commands.join(' && '),
args: ['backOnly'],
watch: backSources,
done: done

View File

@ -29,6 +29,6 @@
"You can't make changes on the basic data of an confirmed order or with rows": "You can't make changes on the basic data of an confirmed order or with rows",
"You can't create a ticket for a inactive client": "You can't create a ticket for a inactive client",
"Worker cannot be blank": "Worker cannot be blank",
"You don't have enough privileges to change the state of this ticket": "You don't have enough privileges to change the state of this ticket",
"You must delete the claim id %d first": "You must delete the claim id %d first"
"You must delete the claim id %d first": "You must delete the claim id %d first",
"You don't have enough privileges": "You don't have enough privileges"
}

View File

@ -37,7 +37,6 @@
"The grade must be an integer greater than or equal to zero": "El grade debe ser un entero mayor o igual a cero",
"Sample type cannot be blank": "El tipo de plantilla no puede quedar en blanco",
"Description cannot be blank": "Se debe rellenar el campo de texto",
"You don't have enough privileges to change the state of this ticket": "No tienes permisos para cambiar el estado de este ticket",
"The new quantity should be smaller than the old one": "La nueva cantidad debe de ser menor que la anterior",
"The value should not be greater than 100%": "El valor no debe de ser mayor de 100%",
"The value should be a number": "El valor debe ser un numero",

View File

@ -4,12 +4,15 @@ module.exports = Self => {
Self.remoteMethodCtx('changeState', {
description: 'Change the state of a ticket',
accessType: 'WRITE',
accepts: [{
arg: 'params',
description: 'ticketFk, stateFk',
type: 'object',
required: true
}],
accepts: [
{
arg: 'data',
description: 'Model instance data',
type: 'Object',
required: true,
http: {source: 'body'}
}
],
returns: {
type: 'string',
root: true
@ -20,13 +23,13 @@ module.exports = Self => {
}
});
Self.changeState = async(ctx, params) => {
Self.changeState = async(ctx, data) => {
let userId = ctx.req.accessToken.userId;
let models = Self.app.models;
let isEditable = await models.Ticket.isEditable(params.ticketFk);
let isEditable = await models.Ticket.isEditable(data.ticketFk);
let assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}});
let isAssigned = assignedState.id === params.stateFk;
let isAssigned = assignedState.id === data.stateFk;
let isProduction = await models.Account.hasRole(userId, 'production');
let isSalesPerson = await models.Account.hasRole(userId, 'salesPerson');
@ -37,9 +40,9 @@ module.exports = Self => {
if (!isAssigned) {
let worker = await models.Worker.findOne({where: {userFk: userId}});
params.workerFk = worker.id;
data.workerFk = worker.id;
}
return await models.TicketTracking.create(params);
return await models.TicketTracking.create(data);
};
};

View File

@ -21,6 +21,9 @@
"type": "string",
"required": true
},
"phone": {
"type" : "String"
},
"userFk": {
"type" : "Number",
"required": true
@ -37,6 +40,11 @@
"model": "Client",
"foreignKey": "userFk"
},
"sip": {
"type": "belongsTo",
"model": "Sip",
"foreignKey": "userFk"
},
"department": {
"type": "belongsTo",
"model": "WorkerDepartment",

View File

@ -14,7 +14,25 @@ class Controller {
reload() {
let query = `api/Workers/${this.$stateParams.id}`;
this.$http.get(query).then(res => {
let filter = {
include: [
{
relation: 'user',
scope: {fields: ['name', 'email']}
}, {
relation: 'client',
scope: {fields: ['fi']}
}, {
relation: 'department',
scope: {fields: ['department']}
}, {
relation: 'sip',
scope: {fields: ['extension']}
}
]
};
this.$http.get(query, {params: {filter}}).then(res => {
this.worker = res.data;
});
}

View File

@ -9,13 +9,39 @@
<span></span>
</vn-horizontal>
<div class="body">
<vn-one>
<div class="attributes">
<h5>{{::$ctrl.worker.firstName}} {{::$ctrl.worker.name}}</h5>
<vn-label-value label="Id"
value="{{$ctrl.worker.id}}">
value="{{::$ctrl.worker.id}}">
</vn-label-value>
<vn-label-value label="Name"
value="{{$ctrl.worker.name}}">
<vn-label-value label="User"
value="{{::$ctrl.worker.user.name}}">
</vn-label-value>
</vn-one>
<vn-label-value label="Email"
value="{{::$ctrl.worker.user.email}}">
</vn-label-value>
<vn-label-value label="Fiscal identifier"
value="{{::$ctrl.worker.client.fi}}">
</vn-label-value>
<vn-label-value label="Department"
value="{{::$ctrl.worker.department.department}}">
</vn-label-value>
<vn-label-value label="Phone"
value="{{::$ctrl.worker.phone}}">
</vn-label-value>
<vn-label-value label="Extension"
value="{{::$ctrl.worker.sip.phone}}">
</vn-label-value>
</div>
<div class="quicklinks">
<a
ui-sref="client.card.summary({id: $ctrl.worker.userFk})"
vn-tooltip="Go to client">
<vn-icon
class="mdl-button mdl-js-button mdl-button--colored"
icon="person">
</vn-icon>
</a>
</div>
</div>
</div>

View File

@ -18,7 +18,7 @@
</vn-card>
<vn-card margin-medium-v>
<a ng-repeat="worker in workers track by worker.id"
ui-sref="worker.card.summary({ id: {{::worker.id}} })"
ui-sref="worker.card.summary({id: worker.id})"
translate-attr="{title: 'View worker'}"
class="vn-list-item">
<vn-horizontal ng-click="$ctrl.onClick($event)">