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
01b32d2b89
commit
91e739547b
|
@ -4,17 +4,20 @@
|
||||||
auto-load="true">
|
auto-load="true">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<div class="vn-w-lg">
|
<div class="vn-w-lg">
|
||||||
<vn-card class="vn-pa-sm calendars">
|
<vn-card class="vn-pa-sm calendars" style="position:relative" >
|
||||||
<vn-calendar
|
<vn-icon icon="info" color-marginal style="position: absolute; top: 16px;right: 16px"
|
||||||
ng-repeat="month in $ctrl.months"
|
vn-tooltip="To start adding absences, click an absence type from the right menu and then on the day you want to add an absence">
|
||||||
data="$ctrl.events"
|
</vn-icon>
|
||||||
default-date="month"
|
<vn-calendar
|
||||||
format-day="$ctrl.formatDay($day, $element)"
|
ng-repeat="month in $ctrl.months"
|
||||||
display-controls="false"
|
data="$ctrl.events"
|
||||||
hide-contiguous="true"
|
default-date="month"
|
||||||
hide-year="true"
|
format-day="$ctrl.formatDay($day, $element)"
|
||||||
on-selection="$ctrl.onSelection($days)">
|
display-controls="false"
|
||||||
</vn-calendar>
|
hide-contiguous="true"
|
||||||
|
hide-year="true"
|
||||||
|
on-selection="$ctrl.onSelection($event, $days)">
|
||||||
|
</vn-calendar>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</div>
|
</div>
|
||||||
<vn-side-menu side="right">
|
<vn-side-menu side="right">
|
||||||
|
|
|
@ -44,7 +44,8 @@ class Controller extends Section {
|
||||||
set worker(value) {
|
set worker(value) {
|
||||||
this._worker = value;
|
this._worker = value;
|
||||||
|
|
||||||
if (value) this.refresh();
|
if (value)
|
||||||
|
this.refresh().then(() => this.repaint());
|
||||||
}
|
}
|
||||||
|
|
||||||
onData(data) {
|
onData(data) {
|
||||||
|
@ -78,8 +79,6 @@ class Controller extends Section {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.repaint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
repaint() {
|
repaint() {
|
||||||
|
@ -105,24 +104,25 @@ class Controller extends Section {
|
||||||
this.absenceType = absenceType;
|
this.absenceType = absenceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelection($days) {
|
onSelection($event, $days) {
|
||||||
if (!this.absenceType)
|
if (!this.absenceType)
|
||||||
return this.vnApp.showMessage(this.$t('Choose an absence type'));
|
return this.vnApp.showMessage(this.$t('Choose an absence type from the right menu'));
|
||||||
|
|
||||||
const day = $days[0];
|
const day = $days[0];
|
||||||
const stamp = day.getTime();
|
const stamp = day.getTime();
|
||||||
const event = this.events[stamp];
|
const event = this.events[stamp];
|
||||||
|
const calendar = $event.target.closest('vn-calendar').$ctrl;
|
||||||
|
|
||||||
if (event) {
|
if (event) {
|
||||||
if (event.type == this.absenceType.code)
|
if (event.type == this.absenceType.code)
|
||||||
this.delete(day, event);
|
this.delete(calendar, day, event);
|
||||||
else
|
else
|
||||||
this.edit(event);
|
this.edit(calendar, event);
|
||||||
} else
|
} else
|
||||||
this.create(day);
|
this.create(calendar, day);
|
||||||
}
|
}
|
||||||
|
|
||||||
create(dated) {
|
create(calendar, dated) {
|
||||||
const absenceType = this.absenceType;
|
const absenceType = this.absenceType;
|
||||||
const params = {
|
const params = {
|
||||||
dated: dated,
|
dated: dated,
|
||||||
|
@ -131,55 +131,58 @@ class Controller extends Section {
|
||||||
|
|
||||||
const path = `Workers/${this.$params.id}/createAbsence`;
|
const path = `Workers/${this.$params.id}/createAbsence`;
|
||||||
this.$http.post(path, params).then(res => {
|
this.$http.post(path, params).then(res => {
|
||||||
this.responseHandler(() => {
|
const newEvent = res.data;
|
||||||
const newEvent = res.data;
|
this.events[dated.getTime()] = {
|
||||||
this.events[dated.getTime()] = {
|
name: absenceType.name,
|
||||||
name: absenceType.name,
|
color: absenceType.rgb,
|
||||||
color: absenceType.rgb,
|
type: absenceType.code,
|
||||||
type: absenceType.code,
|
absenceId: newEvent.id
|
||||||
absenceId: newEvent.id
|
};
|
||||||
};
|
|
||||||
this.refresh();
|
this.repaintCanceller(() =>
|
||||||
});
|
this.refresh().then(calendar.repaint())
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
edit(event) {
|
edit(calendar, event) {
|
||||||
const absenceType = this.absenceType;
|
const absenceType = this.absenceType;
|
||||||
const params = {
|
const params = {
|
||||||
absenceId: event.absenceId,
|
absenceId: event.absenceId,
|
||||||
absenceTypeId: absenceType.id
|
absenceTypeId: absenceType.id
|
||||||
};
|
};
|
||||||
const path = `Workers/${this.$params.id}/updateAbsence`;
|
const path = `Workers/${this.$params.id}/updateAbsence`;
|
||||||
this.$http.patch(path, params).then(
|
this.$http.patch(path, params).then(() => {
|
||||||
this.responseHandler(() => {
|
event.color = absenceType.rgb;
|
||||||
event.color = absenceType.rgb;
|
event.name = absenceType.name;
|
||||||
event.name = absenceType.name;
|
event.code = absenceType.code;
|
||||||
event.code = absenceType.code;
|
|
||||||
this.refresh();
|
this.repaintCanceller(() =>
|
||||||
})
|
this.refresh().then(calendar.repaint())
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(day, event) {
|
delete(calendar, day, event) {
|
||||||
const params = {absenceId: event.absenceId};
|
const params = {absenceId: event.absenceId};
|
||||||
const path = `Workers/${this.$params.id}/deleteAbsence`;
|
const path = `Workers/${this.$params.id}/deleteAbsence`;
|
||||||
this.$http.delete(path, {params}).then(
|
this.$http.delete(path, {params}).then(() => {
|
||||||
this.responseHandler(() => {
|
delete this.events[day.getTime()];
|
||||||
delete this.events[day.getTime()];
|
|
||||||
this.refresh();
|
this.repaintCanceller(() =>
|
||||||
})
|
this.refresh().then(calendar.repaint())
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
responseHandler(cb) {
|
repaintCanceller(cb) {
|
||||||
if (this.repaintCanceller) {
|
if (this.canceller) {
|
||||||
clearTimeout(this.repaintCanceller);
|
clearTimeout(this.canceller);
|
||||||
this.repaintCanceller = null;
|
this.canceller = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.repaintCanceller = setTimeout(
|
this.canceller = setTimeout(
|
||||||
() => cb(), 650);
|
() => cb(), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
|
@ -188,7 +191,7 @@ class Controller extends Section {
|
||||||
started: this.started,
|
started: this.started,
|
||||||
ended: this.ended
|
ended: this.ended
|
||||||
};
|
};
|
||||||
this.$http.get(`WorkerCalendars/absences`, {params})
|
return this.$http.get(`WorkerCalendars/absences`, {params})
|
||||||
.then(res => this.onData(res.data));
|
.then(res => this.onData(res.data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,4 +2,5 @@ Calendar: Calendario
|
||||||
Holidays: Vacaciones
|
Holidays: Vacaciones
|
||||||
Used: Utilizados
|
Used: Utilizados
|
||||||
of: de
|
of: de
|
||||||
days: días
|
days: días
|
||||||
|
Choose an absence type from the right menu: Elige un tipo de ausencia desde el menú de la derecha
|
Loading…
Reference in New Issue