fix(FE Show model): moved field definitions
This commit is contained in:
parent
0597fa5f5c
commit
e38e84c20a
1 changed files with 3 additions and 135 deletions
|
@ -2,10 +2,6 @@ import type {ShowInstance} from "@models/show/showInstance.ts";
|
|||
import type {ShowDays} from "@models/show/showDays";
|
||||
import type {ShowDjs} from "@models/show/showDjs";
|
||||
import axios, {type AxiosResponse} from "axios";
|
||||
import {VCheckbox, VFileInput, VTextarea, VTextField} from "vuetify/components";
|
||||
import ColorPickerButton from "@partials/fields/misc/ColorPickerButton.vue";
|
||||
import CheckBoxConditional from "@partials/fields/misc/CheckBoxConditional.vue";
|
||||
import PlaylistSelect from "@partials/fields/playlist/PlaylistSelect.vue";
|
||||
|
||||
export interface Show {
|
||||
id?: number;
|
||||
|
@ -26,7 +22,7 @@ export interface Show {
|
|||
|
||||
// Relationships
|
||||
block?: any;
|
||||
showDays?: ShowDays[];
|
||||
showDays?: ShowDays;
|
||||
showDjs?: ShowDjs[];
|
||||
showInstances?: ShowInstance[];
|
||||
playlist?: any;
|
||||
|
@ -47,138 +43,11 @@ export const baseShow = (): Show => {
|
|||
hasAutoplaylist: false,
|
||||
autoplaylistId: 0,
|
||||
autoplaylistRepeat: false,
|
||||
showDjs: null
|
||||
showDjs: null,
|
||||
showDays: null,
|
||||
}
|
||||
}
|
||||
|
||||
const fieldDefinitions = {
|
||||
name: {
|
||||
label: 'Nome',
|
||||
required: true,
|
||||
},
|
||||
url: {
|
||||
label: 'URL',
|
||||
required: true,
|
||||
},
|
||||
genre: {
|
||||
label: 'Genere',
|
||||
required: true,
|
||||
},
|
||||
description: {
|
||||
label: 'Descrizione',
|
||||
required: false,
|
||||
},
|
||||
backgroundColor: {
|
||||
label: 'Colore di sfondo',
|
||||
required: false,
|
||||
},
|
||||
liveStreamUsingAirtimeAuth: {
|
||||
label: 'Autenticazione Airtime',
|
||||
required: false,
|
||||
},
|
||||
imagePath: {
|
||||
label: 'Percorso immagine',
|
||||
required: false,
|
||||
},
|
||||
hasAutoplaylist: {
|
||||
label: 'Ha playlist automatica',
|
||||
required: false,
|
||||
},
|
||||
autoplaylistRepeat: {
|
||||
label: 'Ripeti playlist automatica',
|
||||
required: false,
|
||||
},
|
||||
showDjs: {
|
||||
label: 'DJs',
|
||||
required: false
|
||||
}
|
||||
};
|
||||
|
||||
export const showForm = (item: Show) => {
|
||||
const fields = {};
|
||||
Object.keys(fieldDefinitions).forEach((key) => {
|
||||
fields[key] = {
|
||||
label: fieldDefinitions[key].label,
|
||||
value: item !== null ? item[key as keyof Show] : '',
|
||||
required: fieldDefinitions[key].required,
|
||||
component: null // Placeholder, will be set in the switch case
|
||||
};
|
||||
|
||||
switch (key) {
|
||||
case 'name':
|
||||
case 'url':
|
||||
case 'genre':
|
||||
fields[key].component = VTextField;
|
||||
break;
|
||||
case 'description':
|
||||
fields[key].component = VTextarea;
|
||||
break;
|
||||
case 'backgroundColor':
|
||||
fields[key].component = ColorPickerButton;
|
||||
break;
|
||||
case 'liveStreamUsingAirtimeAuth':
|
||||
fields[key].component = CheckBoxConditional;
|
||||
fields[key].value = {
|
||||
value: item !== null ? item.liveStreamUsingAirtimeAuth : false,
|
||||
};
|
||||
fields[key].props = {
|
||||
checkBoxForm: {
|
||||
checkBoxField: { label: fields[key].label },
|
||||
fields: {
|
||||
liveStreamUser: {
|
||||
label: 'Utente streaming',
|
||||
component: VTextField,
|
||||
value: item !== null ? item.liveStreamUser : '',
|
||||
disabled: true
|
||||
},
|
||||
liveStreamPass: {
|
||||
label: 'Password di streaming',
|
||||
component: VTextField,
|
||||
value: item !== null ? item.liveStreamPass : '',
|
||||
disabled: true
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case 'imagePath':
|
||||
fields[key].component = VFileInput;
|
||||
fields[key].props = { type: 'file' };
|
||||
break;
|
||||
case 'hasAutoplaylist':
|
||||
fields[key].component = CheckBoxConditional;
|
||||
fields[key].value = {
|
||||
value: item !== null ? item.hasAutoplaylist : false,
|
||||
};
|
||||
fields[key].props = {
|
||||
checkBoxForm: {
|
||||
checkBoxField: { label: fields[key].label },
|
||||
fields: {
|
||||
liveStreamUser: {
|
||||
label: 'Ripetere playlist?',
|
||||
component: VCheckbox,
|
||||
value: item.autoplaylistRepeat,
|
||||
disabled: true
|
||||
},
|
||||
playlistId: {
|
||||
label: 'Playlist',
|
||||
component: PlaylistSelect,
|
||||
value: item.autoplaylistId,
|
||||
disabled: true
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
break;
|
||||
case 'DJs':
|
||||
fields[key].component = CheckBoxConditional;
|
||||
fields[key].value = {
|
||||
value: item.showDjs
|
||||
};
|
||||
}
|
||||
});
|
||||
return fields;
|
||||
};
|
||||
|
||||
export const showTableHeader = [
|
||||
{title: 'Nome', value: 'name'},
|
||||
|
@ -202,7 +71,6 @@ export const getShow = async (options: {
|
|||
);
|
||||
return await axios.get(`/show`, {params: filteredParams})
|
||||
.then((response: AxiosResponse) => {
|
||||
|
||||
return response.data
|
||||
}).catch((error: Error) => {
|
||||
console.log("Error: " + error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue