refs #5250 solucion error WorkerObserv
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Satorres 2023-03-24 12:11:42 +01:00
parent fde854f5c2
commit c68c78cc5b
5 changed files with 63 additions and 3 deletions

View File

@ -8,3 +8,7 @@ CREATE TABLE `vn`.`workerObservation` (
CONSTRAINT `workerFk_workerObservation_FK` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE,
CONSTRAINT `userFk_workerObservation_FK` FOREIGN KEY (`userFk`) REFERENCES `account`.`user`(`id`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci COMMENT='Todas las observaciones referentes a un trabajador';
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES
('WorkerObservation', '*', '*', 'ALLOW', 'ROLE', 'hr');

View File

@ -53,6 +53,9 @@
"Worker": {
"dataSource": "vn"
},
"WorkerObservation": {
"dataSource": "vn"
},
"WorkerConfig": {
"dataSource": "vn"
},

View File

@ -0,0 +1,13 @@
module.exports = function(Self) {
Self.validate('text', isEnabled, {message: 'Description cannot be blank'});
function isEnabled(err) {
if (!this.text) err();
}
Self.observe('before save', async function(ctx) {
ctx.instance.created = new Date();
let token = ctx.options.accessToken;
let userId = token && token.userId;
ctx.instance.userFk = userId;
});
};

View File

@ -0,0 +1,39 @@
{
"name": "WorkerObservation",
"base": "VnModel",
"options": {
"mysql": {
"table": "workerObservation"
}
},
"properties": {
"id": {
"id": true,
"type": "number"
},
"workerFk": {
"type": "number"
},
"userFk": {
"type": "number"
},
"text": {
"type": "string"
},
"created": {
"type": "date"
}
},
"relations": {
"worker": {
"type": "belongsTo",
"model": "Worker",
"foreignKey": "workerFk"
},
"user":{
"type": "belongsTo",
"model": "Account",
"foreignKey": "userFk"
}
}
}

View File

@ -1,8 +1,9 @@
<vn-crud-model
vn-id="model"
url="workerObservations"
url="WorkerObservations"
filter="$ctrl.filter"
link="{workerFk: $ctrl.$params.id}"
include="{relation: 'user'}"
data="notes"
auto-load="true">
</vn-crud-model>
@ -14,7 +15,7 @@
ng-repeat="note in notes"
class="note vn-pa-sm border-solid border-radius vn-mb-md">
<vn-horizontal class="vn-mb-sm" style="color: #666">
<vn-one>{{::note.worker.user.nickname}}</vn-one>
<vn-one>{{::note.user.nickname}}</vn-one>
<vn-auto>{{::note.created | date:'dd/MM/yyyy HH:mm'}}</vn-auto>
</vn-horizontal>
<vn-horizontal class="text">