Rework admin panel and other
This commit is contained in:
@@ -16,9 +16,11 @@ use Filament\Forms;
|
||||
use Filament\Forms\Components\Builder;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
@@ -29,23 +31,44 @@ use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
|
||||
|
||||
class FormBuilderItem
|
||||
{
|
||||
public static function getItem()
|
||||
public static function getItem(): Builder
|
||||
{
|
||||
return Builder::make('columns')
|
||||
->label('Конструктор полей формы')
|
||||
->addActionLabel('Добавить новое поле')
|
||||
->blockPickerColumns(3)
|
||||
->blockPickerWidth('2xl')
|
||||
->collapsed()
|
||||
->collapsible()
|
||||
->cloneable()
|
||||
->schema([
|
||||
// Email поле
|
||||
Builder\Block::make('email')
|
||||
->label('Почта')
|
||||
->icon('heroicon-o-envelope')
|
||||
->label('Поле Email')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->label('Название поля')
|
||||
->placeholder('Например: Ваш Email')
|
||||
->helperText('Это название будет отображаться пользователям')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
|
||||
Section::make('Настройка')
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Подсказка для поля')
|
||||
->placeholder('Например: Введите действующий email')
|
||||
->helperText('Необязательное пояснение для пользователей')
|
||||
->maxLength(500)
|
||||
->columnSpanFull(),
|
||||
|
||||
Section::make('Дополнительные настройки')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
@@ -54,18 +77,34 @@ class FormBuilderItem
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
|
||||
// Phone поле
|
||||
Builder\Block::make('phone')
|
||||
->label('Телефон')
|
||||
->icon('heroicon-o-phone')
|
||||
->label('Поле Телефона')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->label('Название поля')
|
||||
->placeholder('Например: Ваш телефон')
|
||||
->helperText('Укажите контактный номер для связи')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
Section::make('Настройка')
|
||||
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Подсказка для поля')
|
||||
->placeholder('Например: +7 (XXX) XXX-XX-XX')
|
||||
->maxLength(500)
|
||||
->columnSpanFull(),
|
||||
|
||||
Section::make('Дополнительные настройки')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
@@ -73,73 +112,135 @@ class FormBuilderItem
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
|
||||
// Короткий текст
|
||||
Builder\Block::make('text')
|
||||
->icon('heroicon-o-pencil')
|
||||
->label('Короткий текст')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->label('Название поля')
|
||||
->placeholder('Например: Ваше имя')
|
||||
->helperText('Краткий текст (до 255 символов)')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
|
||||
Section::make('Настройка')
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('textarea')
|
||||
->label('Длинный текст текст')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
Section::make('Настройка')
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Подсказка для поля')
|
||||
->placeholder('Например: Введите ваше полное имя')
|
||||
->maxLength(500)
|
||||
->columnSpanFull(),
|
||||
|
||||
Section::make('Дополнительные настройки')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
|
||||
// Длинный текст
|
||||
Builder\Block::make('textarea')
|
||||
->icon('heroicon-o-document-text')
|
||||
->label('Длинный текст')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Название поля')
|
||||
->placeholder('Например: Ваш комментарий')
|
||||
->helperText('Расширенный текст (до 5000 символов)')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Подсказка для поля')
|
||||
->placeholder('Например: Опишите вашу проблему подробно')
|
||||
->maxLength(500)
|
||||
->columnSpanFull(),
|
||||
|
||||
Section::make('Дополнительные настройки')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
|
||||
// Дата
|
||||
Builder\Block::make('date')
|
||||
->icon('heroicon-o-calendar')
|
||||
->label('Дата')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->label('Название поля')
|
||||
->placeholder('Например: Дата рождения')
|
||||
->helperText('Выбор даты из календаря')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
Section::make('Настройка')
|
||||
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Подсказка для поля')
|
||||
->placeholder('Например: Укажите вашу дату рождения')
|
||||
->maxLength(500)
|
||||
->columnSpanFull(),
|
||||
|
||||
Section::make('Дополнительные настройки')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
]),
|
||||
|
||||
]),
|
||||
|
||||
// Ссылка
|
||||
Builder\Block::make('url')
|
||||
->icon('heroicon-o-link')
|
||||
->label('Ссылка')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->label('Название поля')
|
||||
->placeholder('Например: Ваш сайт')
|
||||
->helperText('Введите корректный URL адрес')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
Section::make('Настройка')
|
||||
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Подсказка для поля')
|
||||
->placeholder('Например: https://example.com')
|
||||
->maxLength(500)
|
||||
->columnSpanFull(),
|
||||
|
||||
Section::make('Дополнительные настройки')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
@@ -147,140 +248,178 @@ class FormBuilderItem
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
|
||||
// Множественный выбор
|
||||
Builder\Block::make('multiple_choice')
|
||||
->label('Несколько вариантов')
|
||||
->icon('heroicon-o-check-circle')
|
||||
->label('Множественный выбор')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->label('Название группы')
|
||||
->placeholder('Например: Ваши интересы')
|
||||
->helperText('Несколько вариантов с возможностью выбора')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(), Forms\Components\Repeater::make('columns')->schema([
|
||||
TextInput::make('title_field')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
])->collapsed(),
|
||||
|
||||
Section::make('Настройка')
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Repeater::make('columns')
|
||||
->label('Варианты выбора')
|
||||
->addActionLabel('Добавить вариант')
|
||||
->collapsible()
|
||||
->cloneable()
|
||||
->itemLabel(fn (array $state): ?string => $state['title_field'] ?? 'Новый вариант')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Текст варианта')
|
||||
->placeholder('Например: Спорт')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Описание варианта')
|
||||
->placeholder('Необязательное описание')
|
||||
->maxLength(500),
|
||||
]),
|
||||
|
||||
Section::make('Дополнительные настройки')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
|
||||
|
||||
// Одиночный выбор
|
||||
Builder\Block::make('single_choice')
|
||||
->label('Один вариант')
|
||||
->icon('heroicon-o-radio')
|
||||
->label('Одиночный выбор')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->label('Название группы')
|
||||
->placeholder('Например: Ваш пол')
|
||||
->helperText('Один вариант из предложенных')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(), Forms\Components\Repeater::make('columns')->schema([
|
||||
TextInput::make('title_field')
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
])->collapsed(),
|
||||
|
||||
Section::make('Настройка')
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Repeater::make('columns')
|
||||
->label('Варианты выбора')
|
||||
->addActionLabel('Добавить вариант')
|
||||
->collapsible()
|
||||
->cloneable()
|
||||
->itemLabel(fn (array $state): ?string => $state['title_field'] ?? 'Новый вариант')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Текст варианта')
|
||||
->placeholder('Например: Мужской')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Описание варианта')
|
||||
->placeholder('Необязательное описание')
|
||||
->maxLength(500),
|
||||
]),
|
||||
|
||||
Section::make('Дополнительные настройки')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
|
||||
// Дополнительное образование
|
||||
Builder\Block::make('additional_education_choice')
|
||||
->label('Выбрать дополнительное образование')
|
||||
->icon('heroicon-o-academic-cap')
|
||||
->label('Доп. образование')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->label('Название поля')
|
||||
->placeholder('Например: Дополнительное образование')
|
||||
->helperText('Выбор из списка доп. образования')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
|
||||
Section::make('Настройка')
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Подсказка для поля')
|
||||
->placeholder('Например: Выберите интересующую программу')
|
||||
->maxLength(500)
|
||||
->columnSpanFull(),
|
||||
|
||||
Section::make('Дополнительные настройки')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
// RuleRequiredComponent::getComponent(),
|
||||
// RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
->schema([]),
|
||||
])
|
||||
->maxItems(1),
|
||||
|
||||
// Образовательная программа
|
||||
Builder\Block::make('educational_program_choice')
|
||||
->label('Выбрать Образовательную программу')
|
||||
->icon('heroicon-o-book-open')
|
||||
->label('Образовательная программа')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->label('Название поля')
|
||||
->placeholder('Например: Основная программа')
|
||||
->helperText('Выбор из списка образовательных программ')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->live(onBlur: true)
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp);
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required(),
|
||||
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
|
||||
|
||||
Section::make('Настройка')
|
||||
Hidden::make('name_field')->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Подсказка для поля')
|
||||
->placeholder('Например: Выберите основную программу обучения')
|
||||
->maxLength(500)
|
||||
->columnSpanFull(),
|
||||
|
||||
Section::make('Дополнительные настройки')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent(),
|
||||
RuleLengthLimitComponent::getComponent(),
|
||||
]),
|
||||
])
|
||||
->maxItems(1),
|
||||
Builder\Block::make('captcha')
|
||||
->label('reCaptcha')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->default('Капча')
|
||||
->disabled(true)
|
||||
->dehydrated(true),
|
||||
Forms\Components\Hidden::make('name_field')->required()->default(Str::slug('reCaptcha') . Carbon::now()->timestamp),
|
||||
Section::make('Настройка')
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent()->default(true),
|
||||
]),
|
||||
]),
|
||||
Builder\Block::make('personal_data')
|
||||
->label('Соглашение на обработку персональных данных')
|
||||
->schema([
|
||||
TextInput::make('title_field')
|
||||
->label('Заголовок поля')
|
||||
->live(onBlur: true)
|
||||
->default('Соглашение на обработку персональных данных')
|
||||
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
|
||||
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
|
||||
}),
|
||||
Forms\Components\Hidden::make('name_field')->required()->default(Str::slug('Соглашение на обработку персональных данных') . Carbon::now()->timestamp),
|
||||
|
||||
Section::make('Настройка')
|
||||
->collapsed()
|
||||
->statePath('rules')
|
||||
->schema([
|
||||
RuleRequiredComponent::getComponent()->default(true),
|
||||
]),
|
||||
]),
|
||||
])
|
||||
->label('')
|
||||
->addActionLabel('Добавить поле')
|
||||
->blockPickerColumns(3)
|
||||
->blockPickerWidth('2xl')
|
||||
->collapsed();
|
||||
|
||||
->maxItems(1)
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user