diff --git a/src/components/WorkerTimeForm.vue b/src/components/WorkerTimeForm.vue new file mode 100644 index 000000000..54462873b --- /dev/null +++ b/src/components/WorkerTimeForm.vue @@ -0,0 +1,106 @@ + + + + + + + + {{ workerHourEntry }} + + + + + +es: + Add time: AƱadir hora + Edit entry: Editar entrada + Hour: Hora + Type: Tipo + Entrada: Entrada + Intermedio: Intermedio + Salida: Salida + diff --git a/src/components/WorkerTimeHourChip.vue b/src/components/WorkerTimeHourChip.vue index 2dedf1be8..1a6c60eaa 100644 --- a/src/components/WorkerTimeHourChip.vue +++ b/src/components/WorkerTimeHourChip.vue @@ -22,7 +22,7 @@ const $props = defineProps({ }, }); -const emit = defineEmits(['onHourEntryDeleted']); +const emit = defineEmits(['onHourEntryDeleted', 'showWorkerTimeForm']); const { t } = useI18n(); const { notify } = useNotify(); @@ -57,6 +57,16 @@ const deleteHourEntry = async () => { console.error('Error deleting hour entry'); } }; + +const getChipFormattedHour = (date) => { + //TODO:: Ver si se puede hacer una funcion reutilizable o complementar a utils de dates + const newDate = new Date(date); + const hour = newDate.getHours(); + const min = newDate.getMinutes(); + return `${hour < 10 ? '0' + hour : hour}:${min < 10 ? '0' + min : min}`; +}; + +const showWorkerTimeForm = () => emit('showWorkerTimeForm'); @@ -64,16 +74,18 @@ const deleteHourEntry = async () => { {{ directionIconTooltip }} - + {{ t('Edit') }} - {{ hour }} + {{ + getChipFormattedHour(hour) + }} import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router'; -import { onMounted, ref, computed, onBeforeMount, nextTick } from 'vue'; +import { onMounted, ref, computed, onBeforeMount, nextTick, reactive } from 'vue'; import FetchData from 'components/FetchData.vue'; import WorkerTimeHourChip from 'components/WorkerTimeHourChip.vue'; +import WorkerTimeForm from 'components/WorkerTimeForm.vue'; + import useNotify from 'src/composables/useNotify.js'; import axios from 'axios'; import { useRole } from 'src/composables/useRole'; @@ -13,12 +15,6 @@ import { useStateStore } from 'stores/useStateStore'; import { useState } from 'src/composables/useState'; import { dashIfEmpty } from 'src/filters'; -// const entryDirections = [ -// { code: 'in', description: t('Entrada') }, -// { code: 'middle', description: t('Intermedio') }, -// { code: 'out', description: t('Salida') }, -// ]; - const route = useRoute(); const { t } = useI18n(); const { notify } = useNotify(); @@ -47,6 +43,7 @@ const columns = computed(() => { }); }); +const workerTimeFormDialogRef = ref(null); const workerHoursRef = ref(null); const calendarRef = ref(null); const selectedDate = ref(null); @@ -60,6 +57,10 @@ const reason = ref(null); const canResend = ref(null); const weekTotalHours = ref(null); const workerTimeControlMails = ref(null); +const workerTimeFormProps = reactive({ + dated: null, + formType: null, +}); onMounted(() => setDate(Date.vnNew())); @@ -71,14 +72,6 @@ const getHeaderFormattedDate = (date) => { return `${day} ${monthName}`; }; -const getChipFormattedHour = (date) => { - //TODO:: Ver si se puede hacer una funcion reutilizable o complementar a utils de dates - const newDate = new Date(date); - const hour = newDate.getHours(); - const min = newDate.getMinutes(); - return `${hour < 10 ? '0' + hour : hour}:${min < 10 ? '0' + min : min}`; -}; - const formatHours = (timestamp = 0) => { //TODO:: Ver si se puede hacer una funcion reutilizable o complementar a utils de dates let hour = Math.floor(timestamp / 3600); @@ -380,7 +373,7 @@ const getFinishTime = () => { } }; -const onHourEntryDeleted = async () => { +const updateData = async () => { await fetchHours(); await getMailStates(selectedDate.value); }; @@ -400,6 +393,16 @@ const getMailStates = async (date) => { // await repaint(); }; +const showWorkerTimeForm = (propValue, formType) => { + console.log('workerTimeFormDialogRef:: ', workerTimeFormDialogRef.value); + if (formType === 'edit') { + workerTimeFormProps.entryId = propValue; + } else { + workerTimeFormProps.dated = propValue; + } + workerTimeFormDialogRef.value.show(); +}; + onBeforeMount(() => { weekdayStore.initStore(); console.log('asdasdasd:: ', weekdayStore); @@ -455,67 +458,69 @@ onMounted(async () => { date range: {{ selectedCalendarDates }} - - - - - - - {{ t(col.label) }} - {{ t(col.formattedDate) }} - - - - - - - - + + + + + {{ t(col.label) }} + {{ t(col.formattedDate) }} + + + + + + + + + + + + + + + + + {{ formatHours(day.dayData?.workedHours) }} h. + + - - - - - - - - - {{ formatHours(day.dayData?.workedHours) }} h. - - - {{ t('Add time') }} - - - - - - - + {{ t('Add time') }} + + + + + + + + + {{ columns }} - @@ -550,9 +555,6 @@ onMounted(async () => { es: - Entrada: Entrada - Intermedio: Intermedio - Salida: Salida Hours: Horas Total semana: Total semana Termina a las: Termina a las
{{ workerHourEntry }}
date range: {{ selectedCalendarDates }}
{{ columns }}