import {VCheckbox, VDatePicker, VFileInput, VSelect, VTextarea, VTextField} from "vuetify/components"; import CheckBoxConditional from "@partials/fields/misc/CheckBoxConditional.vue"; import type {Show} from "@models/show/show.ts"; import {getShowDays} from "@models/show/showDays.ts"; import type {ShowDays} from "@models/show/showDays"; import CustomTimePicker from "@partials/fields/misc/CustomTimePicker.vue"; import {showRepetitionData} from "@models/show/ShowRepetition.ts"; import DaysCheckbox from "@partials/fields/show/DaysCheckbox.vue"; import ShowStartEndTime from "@partials/fields/show/ShowStartEndTime.vue"; const fieldDefinitions = { firstShow: { label: 'Data inizio', required: true, }, lastShow: { label: 'Data fine', title: 'Data fine', required: true, }, startTime: { label: 'Ora inizio show', required: true, }, duration: { label: 'Durata', required: false, }, repeatOption: { label: 'Regole di repitizione', repeatType: { label: 'Ripetizione', required: false, }, day: { label: 'Giorni', required: false, }, }, }; export const showDaysForm = (item: ShowDays) => { const fields = {}; const dateMin = new Date().toISOString().substring(0, 10); Object.keys(fieldDefinitions).forEach((key) => { fields[key] = { label: fieldDefinitions[key].label, value: item !== null ? item[key as keyof ShowDays] : '', required: fieldDefinitions[key].required, component: null }; switch (key) { case 'firstShow': fields[key].component = VDatePicker; fields[key].min = dateMin, fields[key].title = fieldDefinitions[key].label; break; case 'lastShow': fields[key].component = CheckBoxConditional; fields[key].props = { checkBoxForm: { checkBoxField: { label: 'Impostare una fine per lo show?' }, fields: { lastShow: { label: fields[key].label, title: fields[key].label, min: dateMin, component: VDatePicker, value: item !== null ? item.lastShow : null, disabled: true }, } } }; break; // Includes duration case 'startTime': fields[key].component = ShowStartEndTime; fields[key].props = { startTime: item !== null ? item.startTime : null, startTimeLabel: fieldDefinitions.startTime.label, duration: item !== null ? item.duration : null, durationLabel: fieldDefinitions.duration.label, endTimeLabel: 'Orario di fine della trasmissione', } break; case 'repeatType': fields[key].component = CheckBoxConditional; fields[key].value = null; fields[key].props = { checkBoxForm: { checkBoxField: { label: 'Ripetere lo show?' }, fields: { repeatType: { label: fields[key].label, component: VSelect, value: item !== null ? item.repeatType : null, props: { items: showRepetitionData, "item-title": 'repeatName', "item-value": 'type' }, disabled: true }, day: { label: 'Giorno', component: DaysCheckbox, value: item !== null ? item.day : null, props: { items: showRepetitionData, "item-title": 'repeatName', "item-value": 'type' }, disabled: true } } } }; break; } }); return fields; };