93 lines
5.2 KiB
PHP
93 lines
5.2 KiB
PHP
<div class="space-y-6">
|
|
@include('livewire.polls.partials.locked-warning')
|
|
|
|
<!-- Language of the texts being edited -->
|
|
<div class="flex flex-wrap items-center gap-2">
|
|
<span class="text-sm text-gray-700">{{ __('Language') }}:</span>
|
|
@foreach ($locales as $code)
|
|
<button type="button" wire:click="$set('editLocale', '{{ $code }}')"
|
|
class="rounded-md border px-2 py-1 text-xs uppercase {{ $editLocale === $code ? 'border-theme-brand bg-theme-brand text-white' : 'border-theme-border text-theme-primary' }}">
|
|
{{ $code }}
|
|
</button>
|
|
@endforeach
|
|
</div>
|
|
|
|
@forelse ($questions as $index => $question)
|
|
@php($type = $registry->has($question['type']) ? $registry->get($question['type']) : null)
|
|
<div class="p-4 bg-theme-surface rounded-md border border-theme-border" wire:key="poll-question-{{ $question['key'] }}">
|
|
<div class="flex flex-wrap items-center gap-2 mb-4">
|
|
<span class="text-sm font-semibold text-theme-primary mr-auto">{{ __('Question') }} {{ $index + 1 }}</span>
|
|
@unless ($contentLocked)
|
|
<x-jetstream.light-button wire:click="moveQuestion({{ $index }}, -1)" :disabled="$index === 0" title="{{ __('Move up') }}">
|
|
<x-icon class="h-4 w-4" name="chevron-up" />
|
|
</x-jetstream.light-button>
|
|
<x-jetstream.light-button wire:click="moveQuestion({{ $index }}, 1)" :disabled="$loop->last" title="{{ __('Move down') }}">
|
|
<x-icon class="h-4 w-4" name="chevron-down" />
|
|
</x-jetstream.light-button>
|
|
<x-jetstream.light-button wire:click="removeQuestion({{ $index }})" title="{{ __('Remove question') }}">
|
|
<x-icon class="h-4 w-4" name="trash" />
|
|
</x-jetstream.light-button>
|
|
@endunless
|
|
</div>
|
|
|
|
<fieldset @disabled($contentLocked) @class(["space-y-4", "opacity-60" => $contentLocked])>
|
|
<div class="grid grid-cols-1 gap-4 sm:grid-cols-3">
|
|
<div class="sm:col-span-2">
|
|
<label class="block text-sm text-gray-700 mb-2">{{ __('Question') }} ({{ strtoupper($editLocale) }})</label>
|
|
<x-input wire:model="questions.{{ $index }}.label.{{ $editLocale }}" type="text" class="w-full" />
|
|
@include('polls.types._error', ['field' => "questions.$index.label"])
|
|
@php($filled = array_keys(array_filter($question['label'] ?? [], fn ($label) => trim((string) $label) !== '')))
|
|
@if ($filled)
|
|
<p class="mt-1 text-xs text-theme-secondary">{{ __('Filled in') }}: {{ strtoupper(implode(', ', $filled)) }}</p>
|
|
@endif
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm text-gray-700 mb-2">{{ __('Type') }}</label>
|
|
<select wire:model.live="questions.{{ $index }}.type" class="w-full border border-primary-300 bg-theme-background rounded-md shadow-sm text-sm">
|
|
@foreach ($typeOptions as $key => $label)
|
|
<option value="{{ $key }}">{{ $label }}</option>
|
|
@endforeach
|
|
@unless ($type)
|
|
<option value="{{ $question['type'] }}">{{ $question['type'] }} ({{ __('disabled') }})</option>
|
|
@endunless
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
@include('polls.types._checkbox', ['model' => "questions.$index.required", 'label' => __('Answer required')])
|
|
|
|
@if ($type)
|
|
@include($type->editorView(), [
|
|
'type' => $type,
|
|
'settings' => $question['settings'] ?? [],
|
|
'prefix' => "questions.$index.settings",
|
|
'index' => $index,
|
|
'locale' => $editLocale,
|
|
])
|
|
@else
|
|
<p class="text-sm text-red-600">{{ __('This question type is disabled in the platform configuration.') }}</p>
|
|
@endif
|
|
</fieldset>
|
|
</div>
|
|
@empty
|
|
<p class="text-sm text-theme-secondary">{{ __('No questions yet.') }}</p>
|
|
@endforelse
|
|
|
|
@unless ($contentLocked)
|
|
<div class="flex flex-wrap items-end gap-3">
|
|
<div>
|
|
<label class="block text-sm text-gray-700 mb-2">{{ __('New question') }}</label>
|
|
<select wire:model="newQuestionType" class="border border-primary-300 bg-theme-background rounded-md shadow-sm text-sm">
|
|
@foreach ($typeOptions as $key => $label)
|
|
<option value="{{ $key }}">{{ $label }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<x-jetstream.secondary-button wire:click="addQuestion">
|
|
<x-icon class="mr-2 h-4 w-4" name="plus" />
|
|
{{ __('Add question') }}
|
|
</x-jetstream.secondary-button>
|
|
</div>
|
|
@endunless
|
|
</div>
|