feat: Add force delete and restore actions to Partner and Announcement resources, and apply minor formatting adjustments across several Filament resources and relation managers.

This commit is contained in:
Yoga Pangestu 2025-12-16 14:05:04 +07:00
parent ff54d97d98
commit b88660b8c8
7 changed files with 45 additions and 37 deletions

View File

@ -42,7 +42,7 @@ public function table(Table $table): Table
TextColumn::make('e_catalog') TextColumn::make('e_catalog')
->label('E-Catalog') ->label('E-Catalog')
->url(fn ($record) => $record->e_catalog) ->url(fn($record) => $record->e_catalog)
->openUrlInNewTab() ->openUrlInNewTab()
->color('primary'), ->color('primary'),
@ -88,7 +88,7 @@ public function table(Table $table): Table
->success() ->success()
->send(); ->send();
}) })
->visible(fn (CooperationProposal $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING), ->visible(fn(CooperationProposal $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING),
Action::make('reject') Action::make('reject')
->label('Tolak') ->label('Tolak')
@ -114,7 +114,7 @@ public function table(Table $table): Table
->warning() ->warning()
->send(); ->send();
}) })
->visible(fn (CooperationProposal $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING) ->visible(fn(CooperationProposal $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING)
->modalWidth(Width::Large), ->modalWidth(Width::Large),
]) ])
->toolbarActions([ ->toolbarActions([

View File

@ -40,7 +40,7 @@ public function form(Schema $schema): Schema
DatePicker::make('publication_date') DatePicker::make('publication_date')
->label('Tanggal Publikasi') ->label('Tanggal Publikasi')
->placeholder(fn () => now()->format('l, d F Y')) ->placeholder(fn() => now()->format('l, d F Y'))
->native(false) ->native(false)
->displayFormat('l, d F Y') ->displayFormat('l, d F Y')
->required(), ->required(),
@ -85,7 +85,7 @@ public function table(Table $table): Table
TextColumn::make('link') TextColumn::make('link')
->label('Link') ->label('Link')
->limit(30) ->limit(30)
->url(fn ($record) => $record->link) ->url(fn($record) => $record->link)
->openUrlInNewTab(), ->openUrlInNewTab(),
TextColumn::make('status') TextColumn::make('status')
@ -113,7 +113,7 @@ public function table(Table $table): Table
->success() ->success()
->send(); ->send();
}) })
->visible(fn (Report $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING), ->visible(fn(Report $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING),
Action::make('reject') Action::make('reject')
->label('Tolak') ->label('Tolak')
@ -138,7 +138,7 @@ public function table(Table $table): Table
->warning() ->warning()
->send(); ->send();
}) })
->visible(fn (Report $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING) ->visible(fn(Report $record) => ! auth()->user()->hasRole('Perusahaan') && $record->status === ApprovalStatus::PENDING)
->modalWidth(Width::Large), ->modalWidth(Width::Large),
]) ])
->headerActions([ ->headerActions([

View File

@ -93,7 +93,7 @@ public function table(Table $table): Table
TextColumn::make('report_count') TextColumn::make('report_count')
->label('Laporan Diterima') ->label('Laporan Diterima')
->getStateUsing(function (TaskAssignment $record) { ->getStateUsing(function (TaskAssignment $record) {
return $record->reports()->count().' / '.($record->report_amount * $record->partnerMedia()->count()); return $record->reports()->count() . ' / ' . ($record->report_amount * $record->partnerMedia()->count());
}), }),
]) ])
->filters([ ->filters([
@ -102,10 +102,11 @@ public function table(Table $table): Table
->headerActions([ ->headerActions([
CreateAction::make() CreateAction::make()
->label('Buat Penugasan') ->label('Buat Penugasan')
->visible(fn () => $this->canCreateTaskAssignment()), ->visible(fn() => $this->canCreateTaskAssignment()),
]) ])
->recordActions([ ->recordActions([
EditAction::make(), EditAction::make(),
DeleteAction::make(), DeleteAction::make(),
]) ])
->toolbarActions([ ->toolbarActions([

View File

@ -56,9 +56,9 @@ public static function configure(Table $table): Table
->sortable() ->sortable()
->date('l, d F Y') ->date('l, d F Y')
->description( ->description(
fn (Cooperation $record): string => now()->greaterThan($record->final_submission_date) fn(Cooperation $record): string => now()->greaterThan($record->final_submission_date)
? 'Waktu Pengajuan Habis' ? 'Waktu Pengajuan Habis'
: 'Sisa waktu pengajuan: '.now()->diffForHumans( : 'Sisa waktu pengajuan: ' . now()->diffForHumans(
$record->final_submission_date, $record->final_submission_date,
['syntax' => CarbonInterface::DIFF_ABSOLUTE] ['syntax' => CarbonInterface::DIFF_ABSOLUTE]
) )
@ -90,9 +90,9 @@ public static function configure(Table $table): Table
->html() ->html()
->getStateUsing(function (Cooperation $record) { ->getStateUsing(function (Cooperation $record) {
$record->loadCount([ $record->loadCount([
'partnerMedia as approved_count' => fn ($query) => $query->where('status', ApprovalStatus::ACCEPTED), 'partnerMedia as approved_count' => fn($query) => $query->where('status', ApprovalStatus::ACCEPTED),
'partnerMedia as rejected_count' => fn ($query) => $query->where('status', ApprovalStatus::REJECTED), 'partnerMedia as rejected_count' => fn($query) => $query->where('status', ApprovalStatus::REJECTED),
'partnerMedia as pending_count' => fn ($query) => $query->where('status', ApprovalStatus::PENDING), 'partnerMedia as pending_count' => fn($query) => $query->where('status', ApprovalStatus::PENDING),
]); ]);
$totalCount = $record->partnerMedia()->count(); $totalCount = $record->partnerMedia()->count();
@ -152,6 +152,7 @@ public static function configure(Table $table): Table
]) ])
->recordActions([ ->recordActions([
ViewAction::make(), ViewAction::make(),
Action::make('accept') Action::make('accept')
->label('Terima') ->label('Terima')
->icon(Heroicon::OutlinedCheck) ->icon(Heroicon::OutlinedCheck)
@ -188,6 +189,7 @@ public static function configure(Table $table): Table
return $cooperationMedia && $cooperationMedia->status === ApprovalStatus::PENDING; return $cooperationMedia && $cooperationMedia->status === ApprovalStatus::PENDING;
}), }),
Action::make('reject') Action::make('reject')
->label('Tolak') ->label('Tolak')
->icon(Heroicon::XMark) ->icon(Heroicon::XMark)
@ -224,6 +226,7 @@ public static function configure(Table $table): Table
return $cooperationMedia && $cooperationMedia->status === ApprovalStatus::PENDING; return $cooperationMedia && $cooperationMedia->status === ApprovalStatus::PENDING;
}), }),
Action::make('send_proposal') Action::make('send_proposal')
->label('Ajukan Proposal') ->label('Ajukan Proposal')
->icon(Heroicon::DocumentText) ->icon(Heroicon::DocumentText)
@ -249,7 +252,7 @@ public static function configure(Table $table): Table
->disk(config('filesystems.default')) ->disk(config('filesystems.default'))
->acceptedFileTypes(['application/pdf']) ->acceptedFileTypes(['application/pdf'])
->maxSize(1024 * 10) ->maxSize(1024 * 10)
->directory('cooperation/proposal/'.now()->toDateString()) ->directory('cooperation/proposal/' . now()->toDateString())
->required(), ->required(),
]) ])
->action(function ($record, array $data) { ->action(function ($record, array $data) {
@ -301,6 +304,7 @@ public static function configure(Table $table): Table
->exists(); ->exists();
}) })
->modalWidth(Width::Large), ->modalWidth(Width::Large),
Action::make('create_task_assignment') Action::make('create_task_assignment')
->label('Buat Penugasan') ->label('Buat Penugasan')
->icon(Heroicon::Plus) ->icon(Heroicon::Plus)
@ -308,7 +312,7 @@ public static function configure(Table $table): Table
->schema([ ->schema([
DatePicker::make('start_date') DatePicker::make('start_date')
->label('Tanggal Mulai') ->label('Tanggal Mulai')
->placeholder(fn () => now()->translatedFormat('l, d F Y')) ->placeholder(fn() => now()->translatedFormat('l, d F Y'))
->native(false) ->native(false)
->displayFormat('l, d F Y') ->displayFormat('l, d F Y')
->locale('id') ->locale('id')
@ -316,7 +320,7 @@ public static function configure(Table $table): Table
DatePicker::make('end_date') DatePicker::make('end_date')
->label('Tanggal Seleisa') ->label('Tanggal Seleisa')
->placeholder(fn () => now()->addDays(30)->translatedFormat('l, d F Y')) ->placeholder(fn() => now()->addDays(30)->translatedFormat('l, d F Y'))
->native(false) ->native(false)
->displayFormat('l, d F Y') ->displayFormat('l, d F Y')
->required() ->required()
@ -361,15 +365,17 @@ public static function configure(Table $table): Table
->modalHeading('Buat Penugasan') ->modalHeading('Buat Penugasan')
->modalSubmitActionLabel('Simpan') ->modalSubmitActionLabel('Simpan')
->visible( ->visible(
fn (Cooperation $record): bool => ! auth()->user()->hasRole('Perusahaan') fn(Cooperation $record): bool => ! auth()->user()->hasRole('Perusahaan')
&& ! $record->taskAssignments()->exists() && ! $record->taskAssignments()->exists()
&& $record->status === CooperationStatus::ASSIGNMENT && $record->status === CooperationStatus::ASSIGNMENT
) )
->modalWidth(Width::Large), ->modalWidth(Width::Large),
EditAction::make() EditAction::make()
->visible(fn () => ! auth()->user()->hasRole('Perusahaan')), ->visible(fn() => ! auth()->user()->hasRole('Perusahaan')),
DeleteAction::make() DeleteAction::make()
->visible(fn () => ! auth()->user()->hasRole('Perusahaan')), ->visible(fn() => ! auth()->user()->hasRole('Perusahaan')),
]) ])
->toolbarActions([ ->toolbarActions([
BulkActionGroup::make([ BulkActionGroup::make([

View File

@ -104,7 +104,7 @@ public static function form(Schema $schema): Schema
->schema( ->schema(
collect($documents) collect($documents)
->map( ->map(
fn ($doc) => Section::make($doc['title']) fn($doc) => Section::make($doc['title'])
->schema([ ->schema([
TextInput::make($doc['text_name']) TextInput::make($doc['text_name'])
->hiddenLabel() ->hiddenLabel()
@ -249,7 +249,9 @@ public static function table(Table $table): Table
->toolbarActions([ ->toolbarActions([
BulkActionGroup::make([ BulkActionGroup::make([
DeleteBulkAction::make(), DeleteBulkAction::make(),
ForceDeleteBulkAction::make(), ForceDeleteBulkAction::make(),
RestoreBulkAction::make(), RestoreBulkAction::make(),
]), ]),
]) ])

View File

@ -59,7 +59,7 @@ public static function table(Table $table): Table
->label('Perusahaan') ->label('Perusahaan')
->searchable() ->searchable()
->sortable() ->sortable()
->description(fn (User $record) => $record->company?->director_name), ->description(fn(User $record) => $record->company?->director_name),
TextColumn::make('company.partnerMedia.name') TextColumn::make('company.partnerMedia.name')
->label('Media') ->label('Media')
@ -81,30 +81,25 @@ public static function table(Table $table): Table
->wrap(), ->wrap(),
]) ])
->filters([ ->filters([
// TrashedFilter::make()
->native(false),
]) ])
->recordActions([ ->recordActions([
EditAction::make(), EditAction::make()
DeleteAction::make(), ->modalWidth(Width::Large),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
])
->filters([
TrashedFilter::make()->native(false),
])
->recordActions([
EditAction::make()->modalWidth(Width::Large),
DeleteAction::make(), DeleteAction::make(),
ForceDeleteAction::make(), ForceDeleteAction::make(),
RestoreAction::make(), RestoreAction::make(),
]) ])
->toolbarActions([ ->toolbarActions([
BulkActionGroup::make([ BulkActionGroup::make([
DeleteBulkAction::make(), DeleteBulkAction::make(),
ForceDeleteBulkAction::make(), ForceDeleteBulkAction::make(),
RestoreBulkAction::make(), RestoreBulkAction::make(),
]), ]),
]) ])

View File

@ -95,9 +95,13 @@ public static function table(Table $table): Table
TrashedFilter::make()->native(false), TrashedFilter::make()->native(false),
]) ])
->recordActions([ ->recordActions([
EditAction::make()->modalWidth(Width::Large), EditAction::make()
->modalWidth(Width::Large),
DeleteAction::make(), DeleteAction::make(),
ForceDeleteAction::make(), ForceDeleteAction::make(),
RestoreAction::make(), RestoreAction::make(),
]) ])
->toolbarActions([ ->toolbarActions([