feat: granular permissions, export backup, user/role management
- PermissionSeeder: 29 permissions with role mapping (admin/manager/staff) - Policies updated to use hasPermissionTo() instead of hasRole() - ExportBackup command: JSON per-table backup with chunk processing - UserResource: CRUD users with role assignment (admin only) - RoleResource: CRUD roles with permission assignment (admin only) - UserPolicy + RolePolicy: admin-only access control - ImportCskh: detailed skip logging with color in dry-run mode - Widgets: permission-based visibility checks - Tests: 8/8 pass (21 assertions)
This commit is contained in:
@@ -11,6 +11,7 @@ use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class FeedbackForm
|
||||
@@ -19,18 +20,22 @@ class FeedbackForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make('Feedback Information')
|
||||
Section::make('Customer & Product')
|
||||
->description('Select the customer and their associated product')
|
||||
->icon('heroicon-o-user-group')
|
||||
->schema([
|
||||
Select::make('customer_id')
|
||||
->relationship('customer', 'name')
|
||||
->searchable()
|
||||
->required()
|
||||
->live(),
|
||||
->live()
|
||||
->columnSpan(1),
|
||||
|
||||
Toggle::make('is_general')
|
||||
->label('General feedback (not related to a product)')
|
||||
->default(false)
|
||||
->live(),
|
||||
->live()
|
||||
->columnSpan(1),
|
||||
|
||||
Select::make('customer_product_id')
|
||||
->label('Product')
|
||||
@@ -57,7 +62,7 @@ class FeedbackForm
|
||||
->live(),
|
||||
|
||||
Select::make('contract_id')
|
||||
->label('Hợp đồng')
|
||||
->label('Contract')
|
||||
->visible(fn ($get): bool => ! $get('is_general') && filled($get('customer_product_id')))
|
||||
->options(function ($get): array {
|
||||
$customerProductId = $get('customer_product_id');
|
||||
@@ -102,48 +107,46 @@ class FeedbackForm
|
||||
})
|
||||
->nullable()
|
||||
->searchable(),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Section::make('Feedback Details')
|
||||
->description('Describe the customer feedback')
|
||||
->icon('heroicon-o-chat-bubble-left-right')
|
||||
->schema([
|
||||
Select::make('feedback_channel_id')
|
||||
->relationship('feedbackChannel', 'name')
|
||||
->required()
|
||||
->preload(),
|
||||
->preload()
|
||||
->columnSpan(1),
|
||||
|
||||
TextInput::make('title')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
->maxLength(255)
|
||||
->columnSpan(1),
|
||||
|
||||
Textarea::make('content')
|
||||
->required()
|
||||
->rows(6)
|
||||
->columnSpanFull(),
|
||||
|
||||
Select::make('attachment_collection')
|
||||
->label('Attachment Collection')
|
||||
->options([
|
||||
'general' => 'General',
|
||||
'proof_of_resolution' => 'Proof of Resolution',
|
||||
'customer_evidence' => 'Customer Evidence',
|
||||
])
|
||||
->default('general'),
|
||||
|
||||
FileUpload::make('attachments')
|
||||
->label('Attachments')
|
||||
->multiple()
|
||||
->disk('local')
|
||||
->directory('feedback-attachments')
|
||||
->columnSpanFull()
|
||||
->dehydrated(false),
|
||||
|
||||
Select::make('tags')
|
||||
->relationship('tags', 'name')
|
||||
->multiple()
|
||||
->preload()
|
||||
->columnSpanFull()
|
||||
->createOptionForm([
|
||||
TextInput::make('name')->required(),
|
||||
TextInput::make('slug')->required(),
|
||||
ColorPicker::make('color')->default('#3b82f6'),
|
||||
]),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Section::make('Assignment & Status')
|
||||
->description('Assign handler and set initial status')
|
||||
->icon('heroicon-o-arrow-path-rounded-square')
|
||||
->schema([
|
||||
Select::make('status')
|
||||
->options([
|
||||
'pending' => 'Pending',
|
||||
@@ -152,22 +155,50 @@ class FeedbackForm
|
||||
'closed' => 'Closed',
|
||||
])
|
||||
->default('pending')
|
||||
->required(),
|
||||
->required()
|
||||
->columnSpan(1),
|
||||
|
||||
Select::make('assigned_to')
|
||||
->relationship('assignedTo', 'name')
|
||||
->searchable()
|
||||
->nullable(),
|
||||
->nullable()
|
||||
->columnSpan(1),
|
||||
|
||||
Select::make('current_department_id')
|
||||
->label('Department')
|
||||
->options(Department::pluck('name', 'id')->toArray())
|
||||
->searchable()
|
||||
->nullable(),
|
||||
->nullable()
|
||||
->columnSpan(1),
|
||||
|
||||
Toggle::make('is_escalated')
|
||||
->label('Escalated')
|
||||
->visible(fn (): bool => auth()->user()?->hasRole(['admin', 'manager']) ?? false),
|
||||
->visible(fn (): bool => auth()->user()?->hasPermissionTo('close-ticket') ?? false)
|
||||
->columnSpan(1),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Section::make('Attachments')
|
||||
->description('Upload files related to this feedback')
|
||||
->icon('heroicon-o-paper-clip')
|
||||
->schema([
|
||||
Select::make('attachment_collection')
|
||||
->label('Collection')
|
||||
->options([
|
||||
'general' => 'General',
|
||||
'proof_of_resolution' => 'Proof of Resolution',
|
||||
'customer_evidence' => 'Customer Evidence',
|
||||
])
|
||||
->default('general')
|
||||
->columnSpan(1),
|
||||
|
||||
FileUpload::make('attachments')
|
||||
->label('Files')
|
||||
->multiple()
|
||||
->disk('local')
|
||||
->directory('feedback-attachments')
|
||||
->columnSpan(1)
|
||||
->dehydrated(false),
|
||||
])
|
||||
->columns(2),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user