feat: workerDisableExcluded update DB field
gitea/salix/pipeline/head Something is wrong with the build of this commit
Details
gitea/salix/pipeline/head Something is wrong with the build of this commit
Details
This commit is contained in:
parent
600dd7a434
commit
1165e050eb
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,45 @@
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
|
@ -1,26 +0,0 @@
|
||||||
|
|
||||||
module.exports = Self => {
|
|
||||||
Self.remoteMethod('workerDisableExcluded', {
|
|
||||||
description: 'Check an email inbox and process it',
|
|
||||||
accessType: 'READ',
|
|
||||||
accepts: {
|
|
||||||
arg: 'workerFk',
|
|
||||||
type: 'Number',
|
|
||||||
required: true,
|
|
||||||
description: `The worker id`
|
|
||||||
},
|
|
||||||
returns: {
|
|
||||||
type: ['Object'],
|
|
||||||
root: true
|
|
||||||
},
|
|
||||||
http: {
|
|
||||||
path: `/workerDisableExcluded`,
|
|
||||||
verb: 'GET'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Self.workerDisableExcluded = workerFk => {
|
|
||||||
console.log(workerFk);
|
|
||||||
return 'tests123';
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -13,4 +13,6 @@ module.exports = Self => {
|
||||||
require('../methods/worker/contracts')(Self);
|
require('../methods/worker/contracts')(Self);
|
||||||
require('../methods/worker/holidays')(Self);
|
require('../methods/worker/holidays')(Self);
|
||||||
require('../methods/worker/activeContract')(Self);
|
require('../methods/worker/activeContract')(Self);
|
||||||
|
require('../methods/worker/workerDisableExcluded')(Self);
|
||||||
|
require('../methods/worker/workerExcludeFromDisable')(Self);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,9 +7,12 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"id": {
|
"workerFk": {
|
||||||
"id": true,
|
"id": true,
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
},
|
||||||
|
"dated": {
|
||||||
|
"type": "date"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"acls": [
|
"acls": [
|
||||||
|
|
|
@ -15,14 +15,19 @@
|
||||||
</div>
|
</div>
|
||||||
</slot-before>
|
</slot-before>
|
||||||
<slot-menu>
|
<slot-menu>
|
||||||
<label class="vn-item">
|
<!--ng-if="!$ctrl.canBeExcluded"-->
|
||||||
<!--
|
<vn-item
|
||||||
<input ng-if="$ctrl.isExcluded()" type="checkbox" id="canBeDisabled" disabled checked>
|
ng-click="$ctrl.setExcluded()"
|
||||||
<input ng-if="!$ctrl.isExcluded()" type="checkbox" id="canBeDisabled" disabled>
|
translate
|
||||||
-->
|
ng-if="!$ctrl.excluded">
|
||||||
|
Marcar para no deshabilitar
|
||||||
<p>{{$ctrl.isExcluded()}}</p>
|
</vn-item>
|
||||||
</label>
|
<vn-item
|
||||||
|
ng-click="$ctrl.setExcluded()"
|
||||||
|
translate
|
||||||
|
ng-if="$ctrl.excluded">
|
||||||
|
Marcar como deshabilitable
|
||||||
|
</vn-item>
|
||||||
</slot-menu>
|
</slot-menu>
|
||||||
<slot-body>
|
<slot-body>
|
||||||
<div class="attributes">
|
<div class="attributes">
|
||||||
|
|
|
@ -5,6 +5,7 @@ class Controller extends Descriptor {
|
||||||
constructor($element, $, $rootScope) {
|
constructor($element, $, $rootScope) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
this.$rootScope = $rootScope;
|
this.$rootScope = $rootScope;
|
||||||
|
this.canBeExcluded();
|
||||||
}
|
}
|
||||||
|
|
||||||
get worker() {
|
get worker() {
|
||||||
|
@ -15,12 +16,23 @@ class Controller extends Descriptor {
|
||||||
this.entity = value;
|
this.entity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
async isExcluded() {
|
get excluded() {
|
||||||
// eslint-disable-next-line no-console
|
return this.entity.excluded;
|
||||||
console.log(this.entity);
|
}
|
||||||
let excluded = await this.$http.get(`workerDisableExcluded`);
|
|
||||||
// eslint-disable-next-line no-console
|
set excluded(value) {
|
||||||
console.log(excluded);
|
this.entity.excluded = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
async canBeExcluded() {
|
||||||
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
|
let data = await this.$http.get(`Workers/workerDisableExcluded/${this.entity.id}`);
|
||||||
|
this.excluded = data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
async setExcluded() {
|
||||||
|
await this.$http.get(`Workers/workerExcludeFromDisable/${this.entity.id}/${this.entity.excluded}`);
|
||||||
|
this.canBeExcluded();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadData() {
|
loadData() {
|
||||||
|
|
Loading…
Reference in New Issue