diff --git a/back/models/sip.json b/back/models/sip.json index de6af8ad8..98bcfee96 100644 --- a/back/models/sip.json +++ b/back/models/sip.json @@ -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": { diff --git a/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js b/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js index 061d67c1c..ce7f63f71 100644 --- a/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js +++ b/e2e/paths/ticket-module/05_create_new_tracking_state.spec.js @@ -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() => { diff --git a/gulpfile.js b/gulpfile.js index b4a333dc7..fce5555ce 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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 diff --git a/loopback/locale/en.json b/loopback/locale/en.json index e9395682f..06060fe67 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -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" } \ No newline at end of file diff --git a/loopback/locale/es.json b/loopback/locale/es.json index f7f128741..cc08b120e 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -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", diff --git a/modules/ticket/back/methods/ticket-tracking/changeState.js b/modules/ticket/back/methods/ticket-tracking/changeState.js index 5e99f830d..2b6aab923 100644 --- a/modules/ticket/back/methods/ticket-tracking/changeState.js +++ b/modules/ticket/back/methods/ticket-tracking/changeState.js @@ -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); }; }; diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 31106a94b..70f9bb693 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -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", diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index 1e574aa1c..2095d1351 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -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; }); } diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html index 9fdb87c1d..4222ca490 100644 --- a/modules/worker/front/descriptor/index.html +++ b/modules/worker/front/descriptor/index.html @@ -9,13 +9,39 @@
- +
+
{{::$ctrl.worker.firstName}} {{::$ctrl.worker.name}}
+ value="{{::$ctrl.worker.id}}"> - + - + + + + + + + + + + +
+
\ No newline at end of file diff --git a/modules/worker/front/index/index.html b/modules/worker/front/index/index.html index e6acf3158..342fb1de3 100644 --- a/modules/worker/front/index/index.html +++ b/modules/worker/front/index/index.html @@ -18,7 +18,7 @@