#5919 createLocker #2446

Merged
jorgep merged 42 commits from 5919-createLocker into dev 2024-05-13 13:10:40 +00:00
8 changed files with 47 additions and 39 deletions
Showing only changes of commit c0c3d913b7 - Show all commits

View File

@ -2,11 +2,6 @@
"name": "Locker", "name": "Locker",
"description": "Employee's locker", "description": "Employee's locker",
"base": "VnModel", "base": "VnModel",
"options": {
"mysql": {
"table": "locker"
}
},
"properties": { "properties": {
"code": { "code": {
"type": "string" "type": "string"
@ -14,12 +9,5 @@
"gender": { "gender": {
"type": "string" "type": "string"
} }
},
"relations": {
"worker": {
"type": "belongsTo",
"model": "worker",
"foreignKey": "workerFk"
}
} }
} }

View File

@ -20,7 +20,7 @@ module.exports = Self => {
require('../methods/worker/isAuthorized')(Self); require('../methods/worker/isAuthorized')(Self);
require('../methods/worker/setPassword')(Self); require('../methods/worker/setPassword')(Self);
Self.validatesUniquenessOf('locker', { // Self.validatesUniquenessOf('locker', {
message: 'This locker has already been assigned' // message: 'This locker has already been assigned'
}); // });
}; };

View File

@ -53,6 +53,9 @@
}, },
"isF11Allowed": { "isF11Allowed": {
"type" : "boolean" "type" : "boolean"
},
"sex": {
"type" : "string"
} }
}, },
"relations": { "relations": {
@ -87,9 +90,9 @@
"foreignKey": "workerFk" "foreignKey": "workerFk"
}, },
"locker": { "locker": {
"type": "belongsTo", "type": "hasOne",
"model": "Locker", "model": "Locker",
"foreignKey": "code" "foreignKey": "workerFk"
} }
} }
} }

View File

@ -5,6 +5,12 @@
form="form" form="form"
save="patch"> save="patch">
</vn-watcher> </vn-watcher>
<vn-crud-model
vn-id="locker"
url="Lockers"
filter="$ctrl.$.lockerFilter"
auto-load="false">
</vn-crud-model>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md"> <form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
<vn-card class="vn-pa-lg"> <vn-card class="vn-pa-lg">
<vn-vertical> <vn-vertical>
@ -75,11 +81,15 @@
ng-model="$ctrl.worker.SSN" ng-model="$ctrl.worker.SSN"
rule> rule>
</vn-textfield> </vn-textfield>
<vn-autocomplete <!-- <vn-autocomplete
ng-if="$ctrl.$.locker"
label="Locker" label="Locker"
url="Lockers" data="$ctrl.$.locker.data"
ng-model="$ctrl.locker.code"> show-field="code"
</vn-autocomplete> value-field="id"
ng-model="$ctrl.worker.locker.id">
</vn-autocomplete> -->
<!-- {{$ctrl.$.locker}} -->
</vn-horizontal> </vn-horizontal>
</vn-vertical> </vn-vertical>
</vn-card> </vn-card>

View File

@ -8,21 +8,27 @@ class Controller extends Section {
{code: 'M', name: this.$t('Married')}, {code: 'M', name: this.$t('Married')},
{code: 'S', name: this.$t('Single')} {code: 'S', name: this.$t('Single')}
]; ];
this.$.lockerFilter = {workerFk: null};
}
get worker() {
return this._worker;
}
set worker(value) {
this._worker = value;
console.log('VALUE', value);
if (value) {
this.$.lockerFilter = {where: {AND: [{workerFk: null}, {gender: value.sex}]}};
this.$.locker.refresh();
}
} }
onSubmit() { onSubmit() {
console.log(this.worker);
console.log(this.$.watcher.orgData);
// if(this.$.worker.locker.id != )
return this.$.watcher.submit() return this.$.watcher.submit()
.then(() => this.card.reload()); .then(() => this.card.reload());
} }
// async chooseLocker() {
// const locker =
// `SELECT l.code
// FROM worker w
// JOIN locker l ON w.sex = l.gender
// WHERE w.id = ? AND l.workerFk IS NULL;
// `[this.id];
// return locker;
// }
} }
ngModule.vnComponent('vnWorkerBasicData', { ngModule.vnComponent('vnWorkerBasicData', {

View File

@ -28,6 +28,11 @@ class Controller extends ModuleCard {
relation: 'department' relation: 'department'
} }
} }
}, {
relation: 'locker',
scope: {
fields: ['id', 'code', 'gender']
}
} }
] ]
}; };

View File

@ -58,7 +58,8 @@
phone-number="worker.client.phone" phone-number="worker.client.phone"
></vn-link-phone> ></vn-link-phone>
</vn-label-value> </vn-label-value>
<vn-label-value label="Locker" <vn-label-value
label="Locker"
value="{{worker.locker.code}}" value="{{worker.locker.code}}"
> >
</vn-label-value> </vn-label-value>

View File

@ -55,14 +55,9 @@ class Controller extends Summary {
{ {
relation: 'locker', relation: 'locker',
scope: { scope: {
fields: ['id', 'code', 'gender'], fields: ['id', 'code', 'gender']
include: {
relation: 'worker',
scope: {fields: ['id']}
} }
} }
}
] ]
}; };