7430_devToTest #2490

Merged
alexm merged 306 commits from 7430_devToTest into test 2024-05-21 09:15:04 +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",
"description": "Employee's locker",
"base": "VnModel",
"options": {
"mysql": {
"table": "locker"
}
},
"properties": {
"code": {
"type": "string"
@ -14,12 +9,5 @@
"gender": {
"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/setPassword')(Self);
Self.validatesUniquenessOf('locker', {
message: 'This locker has already been assigned'
});
// Self.validatesUniquenessOf('locker', {
// message: 'This locker has already been assigned'
// });
};

View File

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

View File

@ -5,6 +5,12 @@
form="form"
save="patch">
</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">
<vn-card class="vn-pa-lg">
<vn-vertical>
@ -75,11 +81,15 @@
ng-model="$ctrl.worker.SSN"
rule>
</vn-textfield>
<vn-autocomplete
<!-- <vn-autocomplete
ng-if="$ctrl.$.locker"
label="Locker"
url="Lockers"
ng-model="$ctrl.locker.code">
</vn-autocomplete>
data="$ctrl.$.locker.data"
show-field="code"
value-field="id"
ng-model="$ctrl.worker.locker.id">
</vn-autocomplete> -->
<!-- {{$ctrl.$.locker}} -->
</vn-horizontal>
</vn-vertical>
</vn-card>

View File

@ -8,21 +8,27 @@ class Controller extends Section {
{code: 'M', name: this.$t('Married')},
{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() {
console.log(this.worker);
console.log(this.$.watcher.orgData);
// if(this.$.worker.locker.id != )
return this.$.watcher.submit()
.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', {

View File

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

View File

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

View File

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