refs #5919 fix section
gitea/salix/pipeline/head There was a failure building this commit Details
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2024-01-17 13:20:28 +01:00
parent c0c3d913b7
commit bf796c445d
6 changed files with 127 additions and 14 deletions

View File

@ -1,7 +1,12 @@
{
"name": "Locker",
"description": "Employee's locker",
"base": "VnModel",
"description": "Employee's locker",
"options": {
"mysql": {
"table": "locker"
}
},
"properties": {
"code": {
"type": "string"

View File

@ -7,7 +7,7 @@
</vn-watcher>
<vn-crud-model
vn-id="locker"
url="Lockers"
url="lockers"
filter="$ctrl.$.lockerFilter"
auto-load="false">
</vn-crud-model>

View File

@ -8,20 +8,19 @@ 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;
// 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();
}
}
// 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);

View File

@ -0,0 +1,50 @@
<div class="vn-w-md" ng-show="$ctrl.currentPDA">
<vn-card class="vn-pa-lg">
<vn-horizontal>
<vn-textfield
label="Current PDA"
ng-model="$ctrl.currentPDA.description"
disabled="true">
<append>
<vn-icon-button
icon="delete"
vn-tooltip="Deallocate PDA"
ng-click="$ctrl.deallocatePDA()"
vn-acl="hr, productionAssi">
</vn-icon-button>
</append>
</vn-textfield>
</vn-horizontal>
</vn-card>
</div>
<form name="form" ng-show="!$ctrl.currentPDA" ng-submit="$ctrl.allocatePDA()" class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-horizontal>
<vn-autocomplete
vn-acl="hr, productionAssi"
ng-model="$ctrl.newPDA"
url="DeviceProductions"
fields="['id', 'modelFk', 'serialNumber']"
where="{'stateFk': 'idle'}"
label="New PDA"
order="id"
value-field="id"
show-field="serialNumber">
<tpl-item>
<div>
ID: {{id}}
</div>
<div class="text-caption text-grey">
{{modelFk}}, {{serialNumber}}
</div>
</tpl-item>
</vn-autocomplete>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit
disabled="!$ctrl.newPDA"
label="Assign">
</vn-submit>
</vn-button-bar>
</form>

View File

@ -0,0 +1,53 @@
import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss';
class Controller extends Section {
constructor($element, $) {
super($element, $);
const filter = {
where: {userFk: this.$params.id},
include: {relation: 'deviceProduction'}
};
this.$http.get('DeviceProductionUsers', {filter}).
then(res => {
if (res.data && res.data.length > 0)
this.setCurrentPDA(res.data[0]);
});
}
deallocatePDA() {
this.$http.post(`Workers/${this.$params.id}/deallocatePDA`, {pda: this.currentPDA.deviceProductionFk})
.then(() => {
this.vnApp.showSuccess(this.$t('PDA deallocated'));
delete this.currentPDA;
});
}
allocatePDA() {
this.$http.post(`Workers/${this.$params.id}/allocatePDA`, {pda: this.newPDA})
.then(res => {
if (res.data)
this.setCurrentPDA(res.data);
this.vnApp.showSuccess(this.$t('PDA allocated'));
delete this.newPDA;
});
}
setCurrentPDA(data) {
this.currentPDA = data;
this.currentPDA.description = [];
this.currentPDA.description.push(`ID: ${this.currentPDA.deviceProductionFk}`);
this.currentPDA.description.push(`${this.$t('Model')}: ${this.currentPDA.deviceProduction.modelFk}`);
this.currentPDA.description.push(`${this.$t('Serial Number')}: ${this.currentPDA.deviceProduction.serialNumber}`);
this.currentPDA.description = this.currentPDA.description.join(' ');
}
}
Controller.$inject = ['$element', '$scope'];
ngModule.vnComponent('vnWorkerPda', {
template: require('./index.html'),
controller: Controller,
});

View File

@ -0,0 +1,6 @@
@import "./variables";
.text-grey {
color: $color-font-light;
}