This commit is contained in:
parent
fde854f5c2
commit
c68c78cc5b
|
@ -7,4 +7,8 @@ CREATE TABLE `vn`.`workerObservation` (
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
CONSTRAINT `workerFk_workerObservation_FK` FOREIGN KEY (`workerFk`) REFERENCES `vn`.`worker` (`id`) ON UPDATE CASCADE,
|
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
|
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';
|
) 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');
|
||||||
|
|
|
@ -53,6 +53,9 @@
|
||||||
"Worker": {
|
"Worker": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
"WorkerObservation": {
|
||||||
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
"WorkerConfig": {
|
"WorkerConfig": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
},
|
},
|
||||||
|
|
|
@ -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;
|
||||||
|
});
|
||||||
|
};
|
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
vn-id="model"
|
vn-id="model"
|
||||||
url="workerObservations"
|
url="WorkerObservations"
|
||||||
filter="$ctrl.filter"
|
filter="$ctrl.filter"
|
||||||
link="{workerFk: $ctrl.$params.id}"
|
link="{workerFk: $ctrl.$params.id}"
|
||||||
|
include="{relation: 'user'}"
|
||||||
data="notes"
|
data="notes"
|
||||||
auto-load="true">
|
auto-load="true">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
|
@ -14,7 +15,7 @@
|
||||||
ng-repeat="note in notes"
|
ng-repeat="note in notes"
|
||||||
class="note vn-pa-sm border-solid border-radius vn-mb-md">
|
class="note vn-pa-sm border-solid border-radius vn-mb-md">
|
||||||
<vn-horizontal class="vn-mb-sm" style="color: #666">
|
<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-auto>{{::note.created | date:'dd/MM/yyyy HH:mm'}}</vn-auto>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal class="text">
|
<vn-horizontal class="text">
|
||||||
|
|
Loading…
Reference in New Issue