Refactored according to the suggested changes
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
3376293d1a
commit
1d8fb25325
|
@ -1,30 +0,0 @@
|
|||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('workerDisableExcluded', {
|
||||
description: 'Check if the worker can be disabled',
|
||||
accessType: 'READ',
|
||||
accepts: {
|
||||
arg: 'id',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: `The worker id`,
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/workerDisableExcluded/:id`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.workerDisableExcluded = async id => {
|
||||
let result;
|
||||
const query = `Select * from vn.workerDisableExcluded where workerFk like ${id}`;
|
||||
let sqlResult = await Self.rawSql(query);
|
||||
sqlResult.length == 0 ? result = false : result = true;
|
||||
return result;
|
||||
};
|
||||
};
|
|
@ -1,45 +0,0 @@
|
|||
module.exports = Self => {
|
||||
Self.remoteMethod('workerExcludeFromDisable', {
|
||||
description: 'Change the status of the worker between can be disabled and cant be disabled',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
arg: 'id',
|
||||
type: 'Number',
|
||||
required: true,
|
||||
description: `The worker id`,
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'currValue',
|
||||
type: 'Boolean',
|
||||
required: true,
|
||||
description: `The current value of workerDisableExcluded`,
|
||||
http: {source: 'path'}
|
||||
}],
|
||||
returns: {
|
||||
type: 'boolean',
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/workerExcludeFromDisable/:id/:currValue`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.workerExcludeFromDisable = async(id, currValue) => {
|
||||
const models = Self.app.models;
|
||||
|
||||
if (!currValue) {
|
||||
await models.WorkerDisableExcluded.create({
|
||||
workerFk: id,
|
||||
dated: new Date()
|
||||
});
|
||||
} else {
|
||||
await models.WorkerDisableExcluded.remove({
|
||||
workerFk: id
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
};
|
|
@ -13,6 +13,4 @@ module.exports = Self => {
|
|||
require('../methods/worker/contracts')(Self);
|
||||
require('../methods/worker/holidays')(Self);
|
||||
require('../methods/worker/activeContract')(Self);
|
||||
require('../methods/worker/workerDisableExcluded')(Self);
|
||||
require('../methods/worker/workerExcludeFromDisable')(Self);
|
||||
};
|
||||
|
|
|
@ -15,18 +15,17 @@
|
|||
</div>
|
||||
</slot-before>
|
||||
<slot-menu>
|
||||
<!--ng-if="!$ctrl.canBeExcluded"-->
|
||||
<vn-item
|
||||
ng-click="$ctrl.setExcluded()"
|
||||
ng-click="$ctrl.handleExcluded()"
|
||||
translate
|
||||
ng-if="!$ctrl.excluded">
|
||||
Marcar para no deshabilitar
|
||||
Click to exclude the user from getting disabled
|
||||
</vn-item>
|
||||
<vn-item
|
||||
ng-click="$ctrl.setExcluded()"
|
||||
ng-click="$ctrl.handleExcluded()"
|
||||
translate
|
||||
ng-if="$ctrl.excluded">
|
||||
Marcar como deshabilitable
|
||||
Click to allow the user to be disabled
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
<slot-body>
|
||||
|
@ -54,7 +53,7 @@
|
|||
</div>
|
||||
<div class="icons">
|
||||
<vn-icon
|
||||
vn-tooltip="Fijado para no deshabilitar"
|
||||
vn-tooltip="This user can't be disabled"
|
||||
icon="person"
|
||||
ng-if="$ctrl.worker.excluded">
|
||||
</vn-icon>
|
||||
|
|
|
@ -5,7 +5,6 @@ class Controller extends Descriptor {
|
|||
constructor($element, $, $rootScope) {
|
||||
super($element, $);
|
||||
this.$rootScope = $rootScope;
|
||||
this.canBeExcluded();
|
||||
}
|
||||
|
||||
get worker() {
|
||||
|
@ -14,6 +13,9 @@ class Controller extends Descriptor {
|
|||
|
||||
set worker(value) {
|
||||
this.entity = value;
|
||||
|
||||
if (value)
|
||||
this.getIsExcluded();
|
||||
}
|
||||
|
||||
get excluded() {
|
||||
|
@ -22,18 +24,22 @@ class Controller extends Descriptor {
|
|||
|
||||
set excluded(value) {
|
||||
this.entity.excluded = value;
|
||||
this.$rootScope.$apply();
|
||||
}
|
||||
|
||||
async canBeExcluded() {
|
||||
await new Promise(r => setTimeout(r, 500));
|
||||
let data = await this.$http.get(`Workers/workerDisableExcluded/${this.entity.id}`);
|
||||
this.excluded = data.data;
|
||||
getIsExcluded() {
|
||||
this.$http.get(`workerDisableExcludeds/${this.entity.id}/exists`).then(data => {
|
||||
this.excluded = data.data.exists;
|
||||
});
|
||||
}
|
||||
|
||||
async setExcluded() {
|
||||
await this.$http.get(`Workers/workerExcludeFromDisable/${this.entity.id}/${this.entity.excluded}`);
|
||||
this.excluded = !this.entity.excluded;
|
||||
handleExcluded() {
|
||||
if (this.excluded) {
|
||||
this.$http.delete(`workerDisableExcludeds/${this.entity.id}`);
|
||||
this.excluded = false;
|
||||
} else {
|
||||
this.$http.post(`workerDisableExcludeds`, {workerFk: this.entity.id, dated: new Date});
|
||||
this.excluded = true;
|
||||
}
|
||||
}
|
||||
|
||||
loadData() {
|
||||
|
|
|
@ -20,4 +20,7 @@ View worker: Ver trabajador
|
|||
Worker id: Id trabajador
|
||||
Workers: Trabajadores
|
||||
worker: trabajador
|
||||
Go to the worker: Ir al trabajador
|
||||
Go to the worker: Ir al trabajador
|
||||
Click to exclude the user from getting disabled: Marcar para no deshabilitar
|
||||
Click to allow the user to be disabled: Marcar para deshabilitar
|
||||
This user can't be disabled: Fijado para no deshabilitar
|
Loading…
Reference in New Issue