feat(fe smartblock): started working on smart blocks editor

This commit is contained in:
Marco Cavalli 2025-03-25 10:57:19 +01:00
parent 8ba2731c31
commit 08c50d6a97
7 changed files with 516 additions and 3 deletions

View file

@ -0,0 +1,113 @@
import {VCheckbox, VSelect, VTextarea, VTextField} from "vuetify/components";
import RadioGroup from "@partials/fields/smartblock/RadioGroup.vue";
import SmartBlockCriteria from "@partials/fields/smartblock/SmartBlockCriteria.vue";
import SmartBlockLimit from "@partials/fields/smartblock/SmartBlockLimit.vue";
export function smartblock(item) {
const visibleFields = {
name: {
title: 'Nome',
required: true,
},
description: {
title: 'Descrizione',
required: false
},
type: {
title: 'Tipologia blocco',
required: true,
radioButtons: [
{
label: 'Dinamico',
value: 'dynamic'
},
{
label: 'Statico',
value: 'static'
}
]
},
criteria: {
title: 'Seleziona i criteri',
required: true
},
limit: {
title: 'Limite a',
required: true
},
repeated_tracks: {
title: 'Permetti al ripetizione delle tracce',
required: false
},
overflow_tracks: {
title: 'Permetti all\'ultima traccia di andare oltre il limite',
required: false
},
sort: {
title: 'Ordina per',
required: true
}
}
return () => {
const fields = {}
Object.keys(visibleFields).forEach((key) => {
fields[key] = {
label: visibleFields[key].title,
value: item !== null ? item[key] : '',
required: visibleFields[key].required,
component: VTextField
}
// console.log(fields)
switch (key) {
case 'name':
fields[key].component = VTextField
break
case 'description':
fields[key].component = VTextarea
break
case 'type':
fields[key].component = RadioGroup
fields[key].radioButtons = visibleFields[key].radioButtons
break
case 'criteria':
fields[key].component = SmartBlockCriteria
break
case 'limit':
fields[key].component = SmartBlockLimit
break
case 'repeated_tracks':
case 'overflow_tracks':
fields[key].component = VCheckbox
break
case 'sort':
fields[key].component = VSelect
fields[key].items = [
{
title: 'Random',
value: 'random'
},
{
title: 'Dal più recente',
value: 'newest'
},
{
title: 'Dal meno recente',
value: 'oldest'
},
{
title: 'Più recentemente andate in onda',
value: 'mostrecentplay'
},
{
title: 'Meno recentemente andate in onda',
value: 'leastrecentplay'
}
]
break
}
})
// console.log(fields)
return fields
}
}

View file

@ -0,0 +1,84 @@
export function smartblockCriteria() {
const criteria = [ {
type: 'string',
title: 'Nome dell\'Album',
value: 'album_title'
},
{
type: 'string',
title: 'Nome dell\'Artista',
value: 'artist_name'
},
{
type: 'number',
title: 'Bit Rate (kbps)',
value: 'bit_rate'
},
{
type: 'number',
title: 'BPM',
value: 'bpm'
},
{
type: 'string',
title: 'Genere',
value: 'genre'
},
{
type: 'TrackType',
title: 'Tipo di traccia',
value: 'track_type_id'
}
]
const modifiers = [
{
value: 'contains',
title: 'contiene',
type: 'string'
},
{
value: 'does not contains',
title: 'non contiene',
type: 'string'
},
{
value: 'starts with',
title: 'comincia con',
type: 'string'
},
{
value: 'ends with',
title: 'finisce con',
type: 'string'
},
{
value: 'is greater than',
title: 'è maggiore di',
type: 'number'
},
{
value: 'is less than',
title: 'è minore di',
type: 'number'
},
{
value: 'is in the range',
title: 'è tra',
type: 'number'
},
{
value: 'is',
title: 'è uguale a',
type: 'all'
},
{
value: 'is not',
title: 'è diverso da',
type: 'all'
},
]
return { criteria, modifiers }
}