Files
ntspi-app/resources/js/Pages/Dashboard/Components/ContentBuilder/blocks/SliderBlock.vue
T
2026-04-13 14:37:57 +05:00

52 lines
1.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="space-y-3">
<div>
<label class="block text-sm font-medium text-foreground mb-1">
Слайдер <span class="text-danger">*</span>
</label>
<select
:value="modelValue.slider"
@change="update('slider', $event.target.value)"
required
class="w-full px-3 py-2 border border-layer-line rounded-lg bg-white text-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent"
>
<option value="">Выберите слайдер...</option>
<option v-for="slider in sliders" :key="slider.slug" :value="slider.slug">
{{ slider.title }}
</option>
</select>
<p class="mt-1 text-xs text-muted-foreground-1">
Только активные слайдеры с изображениями
</p>
</div>
</div>
</template>
<script>
export default {
name: 'SliderBlock',
props: {
modelValue: { type: Object, required: true }
},
emits: ['update:modelValue', 'update'],
data() {
return { sliders: [] };
},
async mounted() {
// Загрузка слайдеров с бэкенда
try {
const response = await fetch('/api/dashboard/sliders/active');
this.sliders = await response.json();
} catch (e) {
console.error('Failed to load sliders:', e);
}
},
methods: {
update(field, value) {
this.$emit('update:modelValue', { ...this.modelValue, [field]: value });
this.$emit('update');
}
}
}
</script>