diff --git a/back/model-config.json b/back/model-config.json index a770a200a..057311992 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -59,12 +59,6 @@ "Postcode": { "dataSource": "vn" }, - "UserPhoneType": { - "dataSource": "vn" - }, - "UserPhone": { - "dataSource": "vn" - }, "UserLog": { "dataSource": "vn" } diff --git a/back/models/user-phone-type.json b/back/models/user-phone-type.json deleted file mode 100644 index 9410bd8db..000000000 --- a/back/models/user-phone-type.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "UserPhoneType", - "base": "VnModel", - "options": { - "mysql": { - "table": "userPhoneType" - } - }, - "properties": { - "code": { - "id": true, - "type": "String" - }, - "description": { - "type": "String" - } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] -} diff --git a/back/models/user-phone.js b/back/models/user-phone.js deleted file mode 100644 index 6f6c20049..000000000 --- a/back/models/user-phone.js +++ /dev/null @@ -1,9 +0,0 @@ -let UserError = require('vn-loopback/util/user-error'); - -module.exports = Self => { - Self.rewriteDbError(function(err) { - if (err.code === 'ER_DUP_ENTRY') - return new UserError(`This phone already exists`); - return err; - }); -}; diff --git a/back/models/user-phone.json b/back/models/user-phone.json deleted file mode 100644 index f264ff28f..000000000 --- a/back/models/user-phone.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "UserPhone", - "base": "Loggable", - "log": { - "model":"UserLog", - "relation": "user" - }, - "options": { - "mysql": { - "table": "userPhone" - } - }, - "properties": { - "id": { - "id": true, - "type": "Number" - }, - "phone": { - "type": "Number", - "required": true - }, - "typeFk": { - "type": "String", - "required": true - } - }, - "relations": { - "user": { - "type": "belongsTo", - "model": "Account", - "foreignKey": "userFk" - }, - "type": { - "type": "belongsTo", - "model": "UserPhoneType", - "foreignKey": "typeFk" - } - } -} diff --git a/db/dump/fixtures.sql b/db/dump/fixtures.sql index 395d034a8..d72b579db 100644 --- a/db/dump/fixtures.sql +++ b/db/dump/fixtures.sql @@ -68,13 +68,13 @@ INSERT INTO `account`.`user`(`id`,`name`,`nickname`, `password`,`role`,`active`, (111, 'Missing', 'Missing', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'es'), (112, 'Trash', 'Trash', 'ac754a330530832ba1bf7687f577da91', 2, 0, NULL, 'es'); -INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`) +INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`) VALUES - (106, 'LGN', 'David Charles', 'Haller', 106, 19), - (107, 'ANT', 'Hank' , 'Pym' , 107, 19), - (108, 'DCX', 'Charles' , 'Xavier', 108, 19), - (109, 'HLK', 'Bruce' , 'Banner', 109, 19), - (110, 'JJJ', 'Jessica' , 'Jones' , 110, 19); + (106, 'LGN', 'David Charles', 'Haller', 106, 19, 432978106), + (107, 'ANT', 'Hank' , 'Pym' , 107, 19, 432978107), + (108, 'DCX', 'Charles' , 'Xavier', 108, 19, 432978108), + (109, 'HLK', 'Bruce' , 'Banner', 109, 19, 432978109), + (110, 'JJJ', 'Jessica' , 'Jones' , 110, 19, 432978110); INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`, `ibanLength`) VALUES @@ -1940,73 +1940,6 @@ INSERT INTO `vn`.`queuePriority`(`id`, `priority`) (2, 'Normal'), (3, 'Baja'); -INSERT INTO `vn`.`userPhoneType` (`code`, `description`) - VALUES - ('businessPhone', 'Telefono de empresa del usuario'), - ('personalPhone', 'Telefono personal del usuario'); - -INSERT INTO `vn`.`userPhone`(`id`, `userFk`, `typeFk`, `phone`) - VALUES - (1, 101, 'personalPhone', 1111111111), - (2, 102, 'personalPhone', 1111111111), - (3, 103, 'personalPhone', 1111111111), - (4, 104, 'personalPhone', 1111111111), - (5, 105, 'personalPhone', 1111111111), - (6, 106, 'personalPhone', 1111111111), - (7, 107, 'personalPhone', 1111111111), - (8, 108, 'personalPhone', 1111111111), - (9, 109, 'personalPhone', 1111111111), - (10, 110, 'personalPhone', 1111111111), - (11, 111, 'personalPhone', 1111111111), - (12, 112, 'personalPhone', 1111111111), - (13, 1, 'personalPhone', 623111111), - (14, 2, 'personalPhone', 623111111), - (15, 3, 'personalPhone', 623111111), - (16, 5, 'personalPhone', 623111111), - (17, 6, 'personalPhone', 623111111), - (18, 9, 'personalPhone', 623111111), - (19, 13, 'personalPhone', 623111111), - (20, 15, 'personalPhone', 623111111), - (21, 16, 'personalPhone', 623111111), - (22, 17, 'personalPhone', 623111111), - (23, 18, 'personalPhone', 623111111), - (24, 19, 'personalPhone', 623111111), - (26, 21, 'personalPhone', 623111111), - (27, 22, 'personalPhone', 623111111), - (28, 30, 'personalPhone', 623111111), - (29, 31, 'personalPhone', 623111111), - (30, 32, 'personalPhone', 623111111), - (31, 34, 'personalPhone', 623111111), - (32, 35, 'personalPhone', 623111111), - (33, 36, 'personalPhone', 623111111), - (34, 37, 'personalPhone', 623111111), - (35, 38, 'personalPhone', 623111111), - (36, 39, 'personalPhone', 623111111), - (37, 40, 'personalPhone', 623111111), - (38, 41, 'personalPhone', 623111111), - (39, 42, 'personalPhone', 623111111), - (40, 43, 'personalPhone', 623111111), - (41, 44, 'personalPhone', 623111111), - (42, 45, 'personalPhone', 623111111), - (43, 47, 'personalPhone', 623111111), - (44, 48, 'personalPhone', 623111111), - (45, 50, 'personalPhone', 623111111), - (46, 51, 'personalPhone', 623111111), - (47, 52, 'personalPhone', 623111111), - (48, 54, 'personalPhone', 623111111), - (49, 55, 'personalPhone', 623111111), - (50, 56, 'personalPhone', 623111111), - (51, 57, 'personalPhone', 623111111), - (52, 58, 'personalPhone', 623111111), - (53, 59, 'personalPhone', 623111111), - (54, 60, 'personalPhone', 623111111), - (55, 61, 'personalPhone', 623111111), - (56, 65, 'personalPhone', 623111111), - (57, 66, 'personalPhone', 623111111), - (65, 107, 'businessPhone', 700987987), - (67, 106, 'businessPhone', 1111111112), - (68, 106, 'personalPhone', 1111111113); - INSERT INTO `vn`.`workerTimeControlParams` (`id`, `dayBreak`, `weekBreak`, `weekScope`, `dayWorkMax`, `dayStayMax`) VALUES (1, 43200, 129600, 734400, 43200, 50400); diff --git a/modules/client/back/methods/client/specs/sendSms.spec.js b/modules/client/back/methods/client/specs/sendSms.spec.js index 06435fdbd..b299ac3c1 100644 --- a/modules/client/back/methods/client/specs/sendSms.spec.js +++ b/modules/client/back/methods/client/specs/sendSms.spec.js @@ -1,10 +1,10 @@ const app = require('vn-loopback/server/server'); describe('client sendSms()', () => { - let clientLog; + let createdLog; afterAll(async done => { - await app.models.ClientLog.destroyById(clientLog.id); + await app.models.ClientLog.destroyById(createdLog.id); done(); }); @@ -19,7 +19,7 @@ describe('client sendSms()', () => { logId = sms.logId; - let createdLog = await app.models.ClientLog.findById(logId); + createdLog = await app.models.ClientLog.findById(logId); let json = JSON.parse(JSON.stringify(createdLog.newInstance)); expect(json.message).toEqual(message); diff --git a/modules/client/front/phones/index.html b/modules/client/front/phones/index.html deleted file mode 100644 index c0966ce0f..000000000 --- a/modules/client/front/phones/index.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - - - - -
diff --git a/modules/client/front/phones/index.js b/modules/client/front/phones/index.js deleted file mode 100644 index 9839d27d7..000000000 --- a/modules/client/front/phones/index.js +++ /dev/null @@ -1,44 +0,0 @@ -import ngModule from '../module'; -import Section from 'salix/components/section'; - -class Controller extends Section { - get client() { - return this._client; - } - - set client(value) { - this._client = value; - if (value) - this.setLink(value); - } - - setLink(value) { - this.$.$applyAsync(()=> { - this.$.model.link = {userFk: value.id}; - this.$.model.refresh(); - }); - } - - onSubmit() { - this.$.watcher.check(); - return this.$.model.save().then(() => { - this.$.watcher.updateOriginalData(); - this.$.watcher.notifySaved(); - this.card.reload(); - }); - } - - add() { - this.$.model.insert(); - } -} - - -ngModule.component('vnClientPhones', { - template: require('./index.html'), - controller: Controller, - require: {card: '^vnClientCard'}, - bindings: { - client: '<' - } -}); diff --git a/modules/client/front/phones/index.spec.js b/modules/client/front/phones/index.spec.js deleted file mode 100644 index 3d0befd68..000000000 --- a/modules/client/front/phones/index.spec.js +++ /dev/null @@ -1,50 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Component vnClientPhones', () => { - let controller; - let $element; - let $scope; - - beforeEach(ngModule('client')); - - beforeEach(angular.mock.inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - $element = angular.element('
'); - $scope.watcher = watcher; - $scope.model = { - link: 1, - save: () => {} - }; - controller = $componentController('vnClientPhones', {$element, $scope}); - controller.card = {reload: () => {}}; - })); - - describe('setLink()', () => { - it('set the link in the model and refreshes it', () => { - spyOn(controller.$, '$applyAsync'); - let value = {id: 106}; - controller.setLink(value); - - expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function)); - }); - }); - - describe('onSubmit()', () => { - it('should call watcher functions, reload the card and save the model', done => { - spyOn(controller.$.watcher, 'check'); - spyOn(controller.$.model, 'save').and.returnValue(Promise.resolve()); - - spyOn(controller.$.watcher, 'updateOriginalData'); - spyOn(controller.$.watcher, 'notifySaved'); - spyOn(controller.card, 'reload'); - controller.onSubmit(); - controller.onSubmit().then(() => { - expect(controller.$.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect(controller.$.watcher.notifySaved).toHaveBeenCalledWith(); - expect(controller.card.reload).toHaveBeenCalledWith(); - done(); - }).catch(done.fail); - }); - }); -}); diff --git a/modules/client/front/routes.json b/modules/client/front/routes.json index 068cc4a3d..ef0d8cc7a 100644 --- a/modules/client/front/routes.json +++ b/modules/client/front/routes.json @@ -285,7 +285,7 @@ "url": "/contact", "state": "client.card.contact", "component": "vn-client-contact", - "description": "Client contact", + "description": "Contacts", "params": { "client": "$ctrl.client" } diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index c5c770fcd..7456a3caa 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -54,12 +54,6 @@ "type": "hasMany", "model": "WorkerTeamCollegues", "foreignKey": "workerFk" - }, - "phones": { - "type": "hasMany", - "model": "UserPhone", - "foreignKey": "userFk", - "primaryKey": "userFk" } } } \ No newline at end of file diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index 1d0d705e7..67439b350 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -23,6 +23,14 @@ rule> + + + + diff --git a/modules/worker/front/card/index.js b/modules/worker/front/card/index.js index dd2a24448..14723947e 100644 --- a/modules/worker/front/card/index.js +++ b/modules/worker/front/card/index.js @@ -28,12 +28,6 @@ class Controller extends ModuleCard { relation: 'department' } } - }, { - relation: 'phones', - scope: { - fields: ['phone'], - order: 'typeFk ASC' - } } ] }; diff --git a/modules/worker/front/descriptor/index.html b/modules/worker/front/descriptor/index.html index 26c2f193e..d26892bfd 100644 --- a/modules/worker/front/descriptor/index.html +++ b/modules/worker/front/descriptor/index.html @@ -26,9 +26,8 @@ - + diff --git a/modules/worker/front/index.js b/modules/worker/front/index.js index 775524a3d..f703e7c21 100644 --- a/modules/worker/front/index.js +++ b/modules/worker/front/index.js @@ -13,7 +13,6 @@ import './department'; import './calendar'; import './time-control'; import './log'; -import './phones'; import './dms/index'; import './dms/create'; import './dms/edit'; diff --git a/modules/worker/front/phones/index.html b/modules/worker/front/phones/index.html deleted file mode 100644 index 95e0366c1..000000000 --- a/modules/worker/front/phones/index.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - -
- - - - - - - - - - - - - - - - - - - -
diff --git a/modules/worker/front/phones/index.js b/modules/worker/front/phones/index.js deleted file mode 100644 index 91d69ac16..000000000 --- a/modules/worker/front/phones/index.js +++ /dev/null @@ -1,48 +0,0 @@ -import ngModule from '../module'; - -class Controller { - constructor($scope) { - this.$scope = $scope; - } - - get worker() { - return this._worker; - } - - set worker(value) { - this._worker = value; - if (value) - this.setLink(value); - } - - setLink(value) { - this.$scope.$applyAsync(()=> { - this.$scope.model.link = {userFk: value.userFk}; - this.$scope.model.refresh(); - }); - } - - onSubmit() { - this.$scope.watcher.check(); - return this.$scope.model.save().then(() => { - this.$scope.watcher.updateOriginalData(); - this.$scope.watcher.notifySaved(); - this.card.reload(); - }); - } - - add() { - this.$scope.model.insert(); - } -} - -Controller.$inject = ['$scope']; - -ngModule.component('vnWorkerPhones', { - template: require('./index.html'), - controller: Controller, - require: {card: '^vnWorkerCard'}, - bindings: { - worker: '<' - } -}); diff --git a/modules/worker/front/phones/index.spec.js b/modules/worker/front/phones/index.spec.js deleted file mode 100644 index e3f6f9bf5..000000000 --- a/modules/worker/front/phones/index.spec.js +++ /dev/null @@ -1,47 +0,0 @@ -import './index'; -import watcher from 'core/mocks/watcher'; - -describe('Component vnWorkerPhones', () => { - let controller; - - beforeEach(ngModule('worker')); - - beforeEach(angular.mock.inject(($componentController, $rootScope) => { - let $scope = $rootScope.$new(); - controller = $componentController('vnWorkerPhones', $scope); - controller.$scope.watcher = watcher; - controller.$scope.model = { - link: 1, - save: () => {} - }; - controller.card = {reload: () => {}}; - })); - - describe('setLink()', () => { - it('set the link in the model and refreshes it', () => { - spyOn(controller.$scope, '$applyAsync'); - let value = {userFk: 106}; - controller.setLink(value); - - expect(controller.$scope.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function)); - }); - }); - - describe('onSubmit()', () => { - it('should call watcher functions, reload the card and save the model', done => { - spyOn(controller.$scope.watcher, 'check'); - spyOn(controller.$scope.model, 'save').and.returnValue(Promise.resolve()); - - spyOn(controller.$scope.watcher, 'updateOriginalData'); - spyOn(controller.$scope.watcher, 'notifySaved'); - spyOn(controller.card, 'reload'); - controller.onSubmit(); - controller.onSubmit().then(() => { - expect(controller.$scope.watcher.updateOriginalData).toHaveBeenCalledWith(); - expect(controller.$scope.watcher.notifySaved).toHaveBeenCalledWith(); - expect(controller.card.reload).toHaveBeenCalledWith(); - done(); - }).catch(done.fail); - }); - }); -}); diff --git a/modules/worker/front/phones/locale/es.yml b/modules/worker/front/phones/locale/es.yml deleted file mode 100644 index 8628f38ee..000000000 --- a/modules/worker/front/phones/locale/es.yml +++ /dev/null @@ -1,4 +0,0 @@ -Phones: Teléfonos -Type: Tipo -Remove phone: Eliminar teléfono -Add phone: Añadir teléfono \ No newline at end of file diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index 6414c9ed2..d7eded94b 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -13,7 +13,6 @@ {"state": "worker.card.pbx", "icon": "icon-pbx"}, {"state": "worker.card.calendar", "icon": "icon-calendar"}, {"state": "worker.card.timeControl", "icon": "access_time"}, - {"state": "worker.card.phones", "icon": "contact_phone"}, {"state": "worker.card.dms.index", "icon": "cloud_upload"} ] }, @@ -84,16 +83,6 @@ "description": "Departments", "acl": ["hr"] }, { - "url": "/phones", - "state": "worker.card.phones", - "component": "vn-worker-phones", - "description": "Phones", - "params": { - "worker": "$ctrl.worker" - }, - "acl": ["hr"] - }, - { "url": "/dms", "state": "worker.card.dms", "abstract": true, diff --git a/modules/worker/front/summary/index.html b/modules/worker/front/summary/index.html index de86c1f84..e2c93ea48 100644 --- a/modules/worker/front/summary/index.html +++ b/modules/worker/front/summary/index.html @@ -12,9 +12,8 @@ - + diff --git a/modules/worker/front/summary/index.js b/modules/worker/front/summary/index.js index f055a0903..a3fbb34f5 100644 --- a/modules/worker/front/summary/index.js +++ b/modules/worker/front/summary/index.js @@ -50,12 +50,6 @@ class Controller { relation: 'department' } } - }, { - relation: 'phones', - scope: { - fields: ['phone'], - order: 'typeFk ASC' - } } ] };