Files
citrus/app/Filament/Admin/Resources/Proposals/Schemas/ProposalForm.php
T

165 lines
9.3 KiB
PHP
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.
<?php
namespace App\Filament\Admin\Resources\Proposals\Schemas;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\CodeEditor;
use Filament\Forms\Components\CodeEditor\Enums\Language as CodeEditorLanguage;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\View;
use Filament\Schemas\Schema;
class ProposalForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->schema([
Tabs::make('Tabs')
->tabs([
Tab::make('Teklif Detayları ve İçerik')
->icon('heroicon-m-document-text')
->schema([
// Section 2: side-by-side Markdown editor (CodeMirror) + live preview
Section::make(__('proposal.content_section'))
->description('Sol tarafta Markdown formatında içeriği düzenleyin, sağ tarafta canlı olarak nasıl görüneceğini izleyin.')
->columns(2)
->schema([
CodeEditor::make('content')
->label(__('proposal.content_field'))
->hiddenLabel()
->required()
->language(CodeEditorLanguage::Markdown)
->live(onBlur: false)
->columnSpan(1)
->extraAttributes([
'style' => 'min-height: 700px; max-height: 700px; overflow-y: auto;',
'data-field-name' => 'content',
]),
View::make('filament.components.markdown-preview')
->columnSpan(1),
]),
]),
Tab::make('Durum ve Ayarlar')
->icon('heroicon-m-cog-6-tooth')
->schema([
// Section 1: compact top metadata and configuration
Section::make(__('proposal.settings_section'))
->columns(12)
->schema([
TextInput::make('title')
->label(__('proposal.title_field'))
->required()
->maxLength(255)
->live(onBlur: true)
->afterStateUpdated(function (string $operation, $state, callable $set) {
if ($operation !== 'create') {
return;
}
$set('slug', \Str::slug($state));
})
->columnSpan(4),
TextInput::make('slug')
->label(__('proposal.slug_field'))
->required()
->maxLength(255)
->unique(ignoreRecord: true)
->rules(['alpha_dash'])
->helperText(__('proposal.slug_helper'))
->columnSpan(4),
Select::make('status')
->label(__('proposal.status_field'))
->options([
'draft' => __('proposal.status_draft'),
'sent' => __('proposal.status_sent'),
'accepted' => __('proposal.status_accepted'),
'rejected' => __('proposal.status_rejected'),
'revised' => __('proposal.status_revised'),
])
->default('draft')
->required()
->columnSpan(4),
TextInput::make('client_name')
->label(__('proposal.client_name_field'))
->required()
->maxLength(255)
->columnSpan(4),
TextInput::make('client_email')
->label(__('proposal.client_email_field'))
->email()
->maxLength(255)
->columnSpan(4),
DatePicker::make('valid_until')
->label(__('proposal.valid_until_field'))
->native(false)
->displayFormat('d.m.Y')
->columnSpan(4),
TextInput::make('total_price')
->label(__('proposal.total_price_field'))
->numeric()
->prefix(fn ($get) => match ($get('currency')) {
'USD' => '$',
'EUR' => '€',
default => '₺',
})
->columnSpan(3),
Select::make('currency')
->label(__('proposal.currency_field'))
->options([
'TRY' => 'TL (₺)',
'USD' => 'USD ($)',
'EUR' => 'EUR (€)',
])
->default('TRY')
->required()
->live()
->columnSpan(1),
Select::make('meta.accent_color')
->label(__('proposal.accent_color_field'))
->options([
'indigo' => 'Premium Indigo (Mor/Mavi)',
'emerald' => 'Emerald Medical (Zümrüt Yeşil)',
'cyberpunk' => 'Cyberpunk Neon (Pembe/Mavi)',
'coral' => 'Coral Corporate (Mercan Kırmızı)',
'amber' => 'Amber Executive (Kehribar/Altın)',
])
->default('indigo')
->live()
->columnSpan(4),
Checkbox::make('meta.show_calculator')
->label(__('proposal.show_calculator_field'))
->default(true)
->columnSpan(4),
// Client feedback inside this section — only visible when present
Textarea::make('client_feedback')
->label('Müşteri Geri Bildirimi / Revizyon Notu')
->rows(3)
->disabled()
->dehydrated(false)
->placeholder('Henüz geri bildirim bırakılmadı.')
->visible(fn ($record) => $record !== null && !empty($record->client_feedback))
->columnSpanFull(),
]),
]),
])->columnSpanFull()
]);
}
}