diff --git a/db/changes/10162-fallas/00-acl.sql b/db/changes/10162-fallas/00-acl.sql new file mode 100644 index 000000000..376788af1 --- /dev/null +++ b/db/changes/10162-fallas/00-acl.sql @@ -0,0 +1 @@ +INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('WorkerLog', '*', 'READ', 'ALLOW', 'ROLE', 'hr'); diff --git a/db/changes/10162-fallas/00-workerLog.sql b/db/changes/10162-fallas/00-workerLog.sql new file mode 100644 index 000000000..730b60aa5 --- /dev/null +++ b/db/changes/10162-fallas/00-workerLog.sql @@ -0,0 +1,6 @@ +ALTER TABLE `vn`.`workerLog` + ADD COLUMN `changedModel` VARCHAR(45) NULL DEFAULT NULL AFTER `description`, + ADD COLUMN `oldInstance` text CHARACTER SET utf8 COLLATE utf8_unicode_ci, + ADD COLUMN `newInstance` text CHARACTER SET utf8 COLLATE utf8_unicode_ci, + ADD COLUMN `changedModelId` int(11) DEFAULT NULL, + ADD COLUMN `changedModelValue` varchar(45) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL; \ No newline at end of file diff --git a/modules/travel/back/models/travel.json b/modules/travel/back/models/travel.json index 0eafe4010..aebf4e3cd 100644 --- a/modules/travel/back/models/travel.json +++ b/modules/travel/back/models/travel.json @@ -7,7 +7,7 @@ }, "options": { "mysql": { - "table": "travel" + "table": "travel" } }, "properties": { diff --git a/modules/worker/back/model-config.json b/modules/worker/back/model-config.json index 884759bc9..e91e8b0fc 100644 --- a/modules/worker/back/model-config.json +++ b/modules/worker/back/model-config.json @@ -52,5 +52,11 @@ }, "Device": { "dataSource": "vn" + }, + "WorkerLog": { + "dataSource": "vn" } } + + + diff --git a/modules/worker/back/models/worker-log.json b/modules/worker/back/models/worker-log.json new file mode 100644 index 000000000..f100f3486 --- /dev/null +++ b/modules/worker/back/models/worker-log.json @@ -0,0 +1,58 @@ +{ + "name": "WorkerLog", + "base": "VnModel", + "options": { + "mysql": { + "table": "workerLog" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "forceId": false + }, + "originFk": { + "type": "Number", + "required": true + }, + "userFk": { + "type": "Number" + }, + "action": { + "type": "String", + "required": true + }, + "changedModel": { + "type": "String" + }, + "oldInstance": { + "type": "Object" + }, + "newInstance": { + "type": "Object" + }, + "creationDate": { + "type": "Date" + }, + "changedModelId": { + "type": "String" + }, + "changedModelValue": { + "type": "String" + }, + "description": { + "type": "String" + } + }, + "relations": { + "user": { + "type": "belongsTo", + "model": "Account", + "foreignKey": "userFk" + } + }, + "scope": { + "order": ["creationDate DESC", "id DESC"] + } +} diff --git a/modules/worker/back/models/worker.json b/modules/worker/back/models/worker.json index 7456a3caa..6af7e8608 100644 --- a/modules/worker/back/models/worker.json +++ b/modules/worker/back/models/worker.json @@ -1,7 +1,11 @@ { "name": "Worker", "description": "Company employees", - "base": "VnModel", + "base": "Loggable", + "log": { + "model":"WorkerLog", + "showField": "firstName" + }, "options": { "mysql": { "table": "worker" diff --git a/modules/worker/front/basic-data/index.html b/modules/worker/front/basic-data/index.html index 67439b350..bdc309c00 100644 --- a/modules/worker/front/basic-data/index.html +++ b/modules/worker/front/basic-data/index.html @@ -1,10 +1,9 @@ + + save="patch">
diff --git a/modules/worker/front/basic-data/index.js b/modules/worker/front/basic-data/index.js index 28107dc12..bf38ce848 100644 --- a/modules/worker/front/basic-data/index.js +++ b/modules/worker/front/basic-data/index.js @@ -6,7 +6,7 @@ class Controller { } onSubmit() { - this.$.watcher.submit() + return this.$.watcher.submit() .then(() => this.card.reload()); } } diff --git a/modules/worker/front/index.js b/modules/worker/front/index.js index f703e7c21..00b4bdaa8 100644 --- a/modules/worker/front/index.js +++ b/modules/worker/front/index.js @@ -13,6 +13,7 @@ import './department'; import './calendar'; import './time-control'; import './log'; +import './worker-log'; import './dms/index'; import './dms/create'; import './dms/edit'; diff --git a/modules/worker/front/locale/es.yml b/modules/worker/front/locale/es.yml index 3fa727801..82535fe4e 100644 --- a/modules/worker/front/locale/es.yml +++ b/modules/worker/front/locale/es.yml @@ -18,3 +18,4 @@ Calendar: Calendario Search workers by id, firstName, lastName or user name: Buscar trabajadores por el identificador, nombre, apellidos o nombre de usuario Time control: Control de horario Data saved! User must access web: ¡Datos guardados! El usuario deberá acceder con su contraseña a la web para que los cambios surtan efecto. +Log: Historial \ No newline at end of file diff --git a/modules/worker/front/routes.json b/modules/worker/front/routes.json index d7eded94b..9aa214c5c 100644 --- a/modules/worker/front/routes.json +++ b/modules/worker/front/routes.json @@ -13,7 +13,8 @@ {"state": "worker.card.pbx", "icon": "icon-pbx"}, {"state": "worker.card.calendar", "icon": "icon-calendar"}, {"state": "worker.card.timeControl", "icon": "access_time"}, - {"state": "worker.card.dms.index", "icon": "cloud_upload"} + {"state": "worker.card.dms.index", "icon": "cloud_upload"}, + {"state": "worker.card.workerLog", "icon": "history"} ] }, "routes": [ @@ -51,6 +52,11 @@ "worker": "$ctrl.worker" }, "acl": ["hr"] + }, { + "url" : "/log", + "state": "worker.card.workerLog", + "component": "vn-worker-log", + "description": "Log" }, { "url": "/pbx", "state": "worker.card.pbx", diff --git a/modules/worker/front/worker-log/index.html b/modules/worker/front/worker-log/index.html new file mode 100644 index 000000000..090dbf2e3 --- /dev/null +++ b/modules/worker/front/worker-log/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/modules/worker/front/worker-log/index.js b/modules/worker/front/worker-log/index.js new file mode 100644 index 000000000..1f1a4f2f8 --- /dev/null +++ b/modules/worker/front/worker-log/index.js @@ -0,0 +1,7 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +ngModule.component('vnWorkerLog', { + template: require('./index.html'), + controller: Section, +});