#996 worker.descriptor
This commit is contained in:
parent
d46575a072
commit
e553d63492
|
@ -7,24 +7,19 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"code": {
|
"userFk": {
|
||||||
"type": "Number",
|
"type": "Number",
|
||||||
"id": true,
|
"id": true,
|
||||||
|
"description": "The user id",
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"columnName": "extension"
|
"columnName": "user_id"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"password": {
|
"extension": {
|
||||||
"type": "string",
|
"type": "String"
|
||||||
"mysql": {
|
|
||||||
"columnName": "secret"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"name": {
|
"secret": {
|
||||||
"type": "string",
|
"type": "String"
|
||||||
"mysql": {
|
|
||||||
"columnName": "caller_id"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"relations": {
|
"relations": {
|
||||||
|
|
|
@ -73,7 +73,7 @@ describe('Ticket Create new tracking state path', () => {
|
||||||
.waitToClick(selectors.createStateView.saveStateButton)
|
.waitToClick(selectors.createStateView.saveStateButton)
|
||||||
.waitForLastSnackbar();
|
.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() => {
|
it(`should attempt to create an state for the type salesPerson has rights but fail as worker is blank`, async() => {
|
||||||
|
|
|
@ -45,10 +45,11 @@ function backWatch(done) {
|
||||||
|
|
||||||
// XXX: Workaround to avoid nodemon bug
|
// XXX: Workaround to avoid nodemon bug
|
||||||
// https://github.com/remy/nodemon/issues/1346
|
// 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({
|
nodemon({
|
||||||
exec: `${sleepBin}node --inspect ./node_modules/gulp/bin/gulp.js`,
|
exec: commands.join(' && '),
|
||||||
args: ['backOnly'],
|
args: ['backOnly'],
|
||||||
watch: backSources,
|
watch: backSources,
|
||||||
done: done
|
done: done
|
||||||
|
|
|
@ -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 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",
|
"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",
|
"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"
|
||||||
}
|
}
|
|
@ -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",
|
"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",
|
"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",
|
"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 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 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",
|
"The value should be a number": "El valor debe ser un numero",
|
||||||
|
|
|
@ -4,12 +4,15 @@ module.exports = Self => {
|
||||||
Self.remoteMethodCtx('changeState', {
|
Self.remoteMethodCtx('changeState', {
|
||||||
description: 'Change the state of a ticket',
|
description: 'Change the state of a ticket',
|
||||||
accessType: 'WRITE',
|
accessType: 'WRITE',
|
||||||
accepts: [{
|
accepts: [
|
||||||
arg: 'params',
|
{
|
||||||
description: 'ticketFk, stateFk',
|
arg: 'data',
|
||||||
type: 'object',
|
description: 'Model instance data',
|
||||||
required: true
|
type: 'Object',
|
||||||
}],
|
required: true,
|
||||||
|
http: {source: 'body'}
|
||||||
|
}
|
||||||
|
],
|
||||||
returns: {
|
returns: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
root: true
|
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 userId = ctx.req.accessToken.userId;
|
||||||
let models = Self.app.models;
|
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 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 isProduction = await models.Account.hasRole(userId, 'production');
|
||||||
let isSalesPerson = await models.Account.hasRole(userId, 'salesPerson');
|
let isSalesPerson = await models.Account.hasRole(userId, 'salesPerson');
|
||||||
|
@ -37,9 +40,9 @@ module.exports = Self => {
|
||||||
|
|
||||||
if (!isAssigned) {
|
if (!isAssigned) {
|
||||||
let worker = await models.Worker.findOne({where: {userFk: userId}});
|
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);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
"phone": {
|
||||||
|
"type" : "String"
|
||||||
|
},
|
||||||
"userFk": {
|
"userFk": {
|
||||||
"type" : "Number",
|
"type" : "Number",
|
||||||
"required": true
|
"required": true
|
||||||
|
@ -37,6 +40,11 @@
|
||||||
"model": "Client",
|
"model": "Client",
|
||||||
"foreignKey": "userFk"
|
"foreignKey": "userFk"
|
||||||
},
|
},
|
||||||
|
"sip": {
|
||||||
|
"type": "belongsTo",
|
||||||
|
"model": "Sip",
|
||||||
|
"foreignKey": "userFk"
|
||||||
|
},
|
||||||
"department": {
|
"department": {
|
||||||
"type": "belongsTo",
|
"type": "belongsTo",
|
||||||
"model": "WorkerDepartment",
|
"model": "WorkerDepartment",
|
||||||
|
|
|
@ -14,7 +14,25 @@ class Controller {
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
let query = `api/Workers/${this.$stateParams.id}`;
|
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;
|
this.worker = res.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,39 @@
|
||||||
<span></span>
|
<span></span>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<vn-one>
|
<div class="attributes">
|
||||||
|
<h5>{{::$ctrl.worker.firstName}} {{::$ctrl.worker.name}}</h5>
|
||||||
<vn-label-value label="Id"
|
<vn-label-value label="Id"
|
||||||
value="{{$ctrl.worker.id}}">
|
value="{{::$ctrl.worker.id}}">
|
||||||
</vn-label-value>
|
</vn-label-value>
|
||||||
<vn-label-value label="Name"
|
<vn-label-value label="User"
|
||||||
value="{{$ctrl.worker.name}}">
|
value="{{::$ctrl.worker.user.name}}">
|
||||||
</vn-label-value>
|
</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>
|
||||||
</div>
|
</div>
|
|
@ -18,7 +18,7 @@
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-card margin-medium-v>
|
<vn-card margin-medium-v>
|
||||||
<a ng-repeat="worker in workers track by worker.id"
|
<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'}"
|
translate-attr="{title: 'View worker'}"
|
||||||
class="vn-list-item">
|
class="vn-list-item">
|
||||||
<vn-horizontal ng-click="$ctrl.onClick($event)">
|
<vn-horizontal ng-click="$ctrl.onClick($event)">
|
||||||
|
|
Loading…
Reference in New Issue