forked from verdnatura/salix-front
fix: WorkerCalendarItem
This commit is contained in:
parent
adde8d1ab8
commit
2094506baf
|
@ -82,6 +82,7 @@ const onFetchAbsences = (data) => {
|
||||||
type: type.code,
|
type: type.code,
|
||||||
absenceId: absence.id,
|
absenceId: absence.id,
|
||||||
isFestive: false,
|
isFestive: false,
|
||||||
|
isHoliday: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ const handleEventSelected = (event, { year, month, day }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const date = new Date(year, month - 1, day);
|
const date = new Date(year, month - 1, day);
|
||||||
if (!event.absenceId) createEvent(date);
|
if (!event?.absenceId) createEvent(date);
|
||||||
else if (event.type == props.absenceType.code) deleteEvent(event, date);
|
else if (event.type == props.absenceType.code) deleteEvent(event, date);
|
||||||
else editEvent(event);
|
else editEvent(event);
|
||||||
};
|
};
|
||||||
|
@ -136,24 +136,37 @@ const getEventByTimestamp = ({ year, month, day }) => {
|
||||||
return props.events[stamp] || null;
|
return props.events[stamp] || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isFestive = (timestamp) => {
|
||||||
|
const event = getEventByTimestamp(timestamp);
|
||||||
|
if (!event) return false;
|
||||||
|
|
||||||
|
const { isFestive } = event;
|
||||||
|
return isFestive;
|
||||||
|
};
|
||||||
const getEventAttrs = (timestamp) => {
|
const getEventAttrs = (timestamp) => {
|
||||||
const event = getEventByTimestamp(timestamp);
|
const event = getEventByTimestamp(timestamp);
|
||||||
if (!event) return {};
|
if (!event) return {};
|
||||||
|
|
||||||
const { name, color, isFestive } = event;
|
const { name, color, isFestive, type } = event;
|
||||||
|
|
||||||
// Atributos a asignar a cada slot que representa un evento en el calendario
|
// Atributos a asignar a cada slot que representa un evento en el calendario
|
||||||
|
|
||||||
const attrs = {
|
const attrs = {
|
||||||
title: name,
|
title: name,
|
||||||
style: color ? `background-color: ${color};` : '',
|
style:
|
||||||
|
color && type !== 'holiday'
|
||||||
|
? `background-color: ${color};`
|
||||||
|
: 'background-color:#3d3d3d;',
|
||||||
label: timestamp.day,
|
label: timestamp.day,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isFestive) {
|
if (isFestive) {
|
||||||
attrs.class = '--festive';
|
attrs.class = '--festive';
|
||||||
attrs.label = event.absenceId ? timestamp.day : '';
|
attrs.label = event.absenceId ? timestamp.day : '';
|
||||||
|
// attrs.style = 'color: red';
|
||||||
}
|
}
|
||||||
|
// if(type === 'holiday')
|
||||||
|
else attrs.class = `--${type}`;
|
||||||
|
|
||||||
return attrs;
|
return attrs;
|
||||||
};
|
};
|
||||||
|
@ -203,7 +216,6 @@ watch(_year, (newValue) => {
|
||||||
<template #day="{ scope: { timestamp } }">
|
<template #day="{ scope: { timestamp } }">
|
||||||
<!-- Este slot representa cada día del calendario y muestra un botón representando el correspondiente evento -->
|
<!-- Este slot representa cada día del calendario y muestra un botón representando el correspondiente evento -->
|
||||||
<QBtn
|
<QBtn
|
||||||
v-if="getEventByTimestamp(timestamp)"
|
|
||||||
v-bind="{ ...getEventAttrs(timestamp) }"
|
v-bind="{ ...getEventAttrs(timestamp) }"
|
||||||
@click="
|
@click="
|
||||||
handleEventSelected(getEventByTimestamp(timestamp), timestamp)
|
handleEventSelected(getEventByTimestamp(timestamp), timestamp)
|
||||||
|
@ -239,6 +251,11 @@ watch(_year, (newValue) => {
|
||||||
&.--festive {
|
&.--festive {
|
||||||
border: 2px solid $negative;
|
border: 2px solid $negative;
|
||||||
}
|
}
|
||||||
|
&.--holiday {
|
||||||
|
& > span:nth-child(2) .block {
|
||||||
|
color: $negative;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
|
|
Loading…
Reference in New Issue