refactor code
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2023-02-23 08:21:59 +01:00
parent 05d91ed50e
commit 35b47c6da2
2 changed files with 26 additions and 25 deletions

View File

@ -97,7 +97,8 @@
<vn-button
label="Resend"
ng-click="$ctrl.resendEmail()"
class="right">
class="right"
ng-show="::$ctrl.isHr">
</vn-button>
</vn-button-bar>

View File

@ -26,10 +26,22 @@ class Controller extends Section {
this.date = initialDate;
}
get isHr() {
return this.aclService.hasAny(['hr']);
}
get worker() {
return this._worker;
}
get weekNumber() {
return this.getWeekNumber(this.date);
}
set weekNumber(value) {
this._weekNumber = value;
}
set worker(value) {
this._worker = value;
}
@ -306,11 +318,10 @@ class Controller extends Section {
}
isSatisfied() {
const weekNumber = this.getWeekNumber(this.date);
const params = {
workerId: this.worker.id,
year: this.date.getFullYear(),
week: weekNumber,
week: this.weekNumber,
state: 'CONFIRMED'
};
const query = `WorkerTimeControls/updateWorkerTimeControlMail`;
@ -321,11 +332,10 @@ class Controller extends Section {
}
isUnsatisfied() {
const weekNumber = this.getWeekNumber(this.date);
const params = {
workerId: this.worker.id,
year: this.date.getFullYear(),
week: weekNumber,
week: this.weekNumber,
state: 'REVISE',
reason: this.reason
};
@ -374,11 +384,9 @@ class Controller extends Section {
this.$http.get('WorkerTimeControlMails/findOne', {filter})
.then(res => {
const state = res.data.state;
const currentWeekNumber = this.getWeekNumber(this.date);
if (currentWeekNumber == weekNumberValue) {
if (this.weekNumber == weekNumberValue) {
this.state = state;
this.reason = res.data.reason;
console.log(currentWeekNumber, weekNumberValue, this.state, this.reason);
}
if (state == 'CONFIRMED') {
weekNumber.classList.add('confirmed');
@ -390,18 +398,11 @@ class Controller extends Section {
}
resendEmail() {
const filter = {
where: {userFk: this.$params.id},
};
this.$http.get('EmailUsers/findOne', {filter})
.then(res => {
const timestamp = this.date.getTime() / 1000;
const url = `${window.location.origin}/#!/worker/${this.$params.id}/time-control?timestamp=${timestamp}`;
const weekNumber = this.getWeekNumber(this.date);
const url = `${window.location.origin}/#!/worker/${this.worker.id}/time-control?timestamp=${timestamp}`;
const params = {
recipient: res.data.email,
week: weekNumber + 1,
recipient: this.worker.user.emailUser.email,
week: this.weekNumber + 1,
year: this.date.getFullYear(),
url: url,
};
@ -409,7 +410,6 @@ class Controller extends Section {
.then(res => {
this.vnApp.showSuccess(this.$t('Email sended'));
});
});
}
getTime(timeString) {