|
@@ -92,7 +92,9 @@
|
|
|
<q-item
|
|
<q-item
|
|
|
v-for="holiday in monthHolidays"
|
|
v-for="holiday in monthHolidays"
|
|
|
:key="holiday.id"
|
|
:key="holiday.id"
|
|
|
- class="q-pa-sm"
|
|
|
|
|
|
|
+ class="q-pa-sm cursor-pointer"
|
|
|
|
|
+ clickable
|
|
|
|
|
+ @click="openEdit(holiday)"
|
|
|
>
|
|
>
|
|
|
<q-item-section avatar>
|
|
<q-item-section avatar>
|
|
|
<q-avatar
|
|
<q-avatar
|
|
@@ -113,16 +115,7 @@
|
|
|
}}</q-item-label>
|
|
}}</q-item-label>
|
|
|
</q-item-section>
|
|
</q-item-section>
|
|
|
<q-item-section side>
|
|
<q-item-section side>
|
|
|
- <q-btn
|
|
|
|
|
- flat
|
|
|
|
|
- round
|
|
|
|
|
- dense
|
|
|
|
|
- icon="mdi-trash-can-outline"
|
|
|
|
|
- color="grey-5"
|
|
|
|
|
- size="sm"
|
|
|
|
|
- :loading="deletingId === holiday.id"
|
|
|
|
|
- @click="removeHoliday(holiday)"
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <q-icon name="mdi-pencil-outline" color="grey-5" size="xs" />
|
|
|
</q-item-section>
|
|
</q-item-section>
|
|
|
</q-item>
|
|
</q-item>
|
|
|
</q-list>
|
|
</q-list>
|
|
@@ -206,7 +199,8 @@ import { useDialogPluginComponent, useQuasar } from "quasar";
|
|
|
import DefaultDialogHeader from "src/components/defaults/DefaultDialogHeader.vue";
|
|
import DefaultDialogHeader from "src/components/defaults/DefaultDialogHeader.vue";
|
|
|
import DefaultInput from "src/components/defaults/DefaultInput.vue";
|
|
import DefaultInput from "src/components/defaults/DefaultInput.vue";
|
|
|
import DefaultSelect from "src/components/defaults/DefaultSelect.vue";
|
|
import DefaultSelect from "src/components/defaults/DefaultSelect.vue";
|
|
|
-import { getHolidays, createHoliday, deleteHoliday } from "src/api/holiday";
|
|
|
|
|
|
|
+import { getHolidays, createHoliday } from "src/api/holiday";
|
|
|
|
|
+import FeriadosEditDialog from "src/pages/dashboard/components/FeriadosEditDialog.vue";
|
|
|
|
|
|
|
|
defineEmits([...useDialogPluginComponent.emits]);
|
|
defineEmits([...useDialogPluginComponent.emits]);
|
|
|
|
|
|
|
@@ -225,7 +219,6 @@ const newType = ref("feriado");
|
|
|
const existingHolidays = ref([]);
|
|
const existingHolidays = ref([]);
|
|
|
const loadingHolidays = ref(false);
|
|
const loadingHolidays = ref(false);
|
|
|
const saving = ref(false);
|
|
const saving = ref(false);
|
|
|
-const deletingId = ref(null);
|
|
|
|
|
|
|
|
|
|
const weekDays = ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"];
|
|
const weekDays = ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"];
|
|
|
|
|
|
|
@@ -357,21 +350,18 @@ async function saveNewRecord() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-async function removeHoliday(holiday) {
|
|
|
|
|
- deletingId.value = holiday.id;
|
|
|
|
|
- try {
|
|
|
|
|
- await deleteHoliday(holiday.id);
|
|
|
|
|
- existingHolidays.value = existingHolidays.value.filter(
|
|
|
|
|
- (h) => h.id !== holiday.id,
|
|
|
|
|
- );
|
|
|
|
|
- } catch {
|
|
|
|
|
- $q.notify({
|
|
|
|
|
- type: "negative",
|
|
|
|
|
- message: "Erro ao remover feriado. Tente novamente.",
|
|
|
|
|
- });
|
|
|
|
|
- } finally {
|
|
|
|
|
- deletingId.value = null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+function openEdit(holiday) {
|
|
|
|
|
+ $q.dialog({
|
|
|
|
|
+ component: FeriadosEditDialog,
|
|
|
|
|
+ componentProps: { holiday },
|
|
|
|
|
+ }).onOk(({ action, holiday: updated, id }) => {
|
|
|
|
|
+ if (action === "update") {
|
|
|
|
|
+ const idx = existingHolidays.value.findIndex((h) => h.id === updated.id);
|
|
|
|
|
+ if (idx !== -1) existingHolidays.value[idx] = { ...existingHolidays.value[idx], ...updated };
|
|
|
|
|
+ } else if (action === "delete") {
|
|
|
|
|
+ existingHolidays.value = existingHolidays.value.filter((h) => h.id !== id);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function loadHolidays() {
|
|
async function loadHolidays() {
|