complete story 4.3 adfter validation and fixing
This commit is contained in:
@@ -33,6 +33,12 @@ new class extends Component {
|
||||
|
||||
public function addUpdate(): void
|
||||
{
|
||||
if ($this->timeline->isArchived()) {
|
||||
session()->flash('error', __('messages.cannot_update_archived_timeline'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->validate();
|
||||
|
||||
$update = $this->timeline->updates()->create([
|
||||
@@ -99,6 +105,46 @@ new class extends Component {
|
||||
$this->editingUpdateId = null;
|
||||
$this->updateText = '';
|
||||
}
|
||||
|
||||
public function archive(): void
|
||||
{
|
||||
if ($this->timeline->isArchived()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->timeline->archive();
|
||||
|
||||
AdminLog::create([
|
||||
'admin_id' => auth()->id(),
|
||||
'action' => 'archive',
|
||||
'target_type' => 'timeline',
|
||||
'target_id' => $this->timeline->id,
|
||||
'ip_address' => request()->ip(),
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
session()->flash('success', __('messages.timeline_archived'));
|
||||
}
|
||||
|
||||
public function unarchive(): void
|
||||
{
|
||||
if ($this->timeline->isActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->timeline->unarchive();
|
||||
|
||||
AdminLog::create([
|
||||
'admin_id' => auth()->id(),
|
||||
'action' => 'unarchive',
|
||||
'target_type' => 'timeline',
|
||||
'target_id' => $this->timeline->id,
|
||||
'ip_address' => request()->ip(),
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
session()->flash('success', __('messages.timeline_unarchived'));
|
||||
}
|
||||
}; ?>
|
||||
|
||||
<div>
|
||||
@@ -109,7 +155,7 @@ new class extends Component {
|
||||
</div>
|
||||
|
||||
{{-- Timeline Header --}}
|
||||
<div class="mb-6 rounded-lg border border-zinc-200 bg-white p-6 dark:border-zinc-700 dark:bg-zinc-800">
|
||||
<div class="mb-6 rounded-lg border border-zinc-200 bg-white p-6 dark:border-zinc-700 dark:bg-zinc-800 {{ $timeline->isArchived() ? 'opacity-75' : '' }}">
|
||||
<div class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
|
||||
<div>
|
||||
<flux:heading size="xl">{{ $timeline->case_name }}</flux:heading>
|
||||
@@ -119,9 +165,22 @@ new class extends Component {
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<flux:badge :color="$timeline->status->value === 'active' ? 'green' : 'zinc'">
|
||||
{{ $timeline->status->label() }}
|
||||
</flux:badge>
|
||||
<div class="flex items-center gap-3">
|
||||
<flux:badge :color="$timeline->isArchived() ? 'amber' : 'green'">
|
||||
{{ $timeline->status->label() }}
|
||||
</flux:badge>
|
||||
@if($timeline->isActive())
|
||||
<flux:modal.trigger name="archive-confirm">
|
||||
<flux:button variant="danger" size="sm" icon="archive-box">
|
||||
{{ __('timelines.archive') }}
|
||||
</flux:button>
|
||||
</flux:modal.trigger>
|
||||
@else
|
||||
<flux:button variant="primary" size="sm" icon="archive-box-arrow-down" wire:click="unarchive">
|
||||
{{ __('timelines.unarchive') }}
|
||||
</flux:button>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 flex flex-wrap gap-4 text-sm text-zinc-600 dark:text-zinc-300">
|
||||
@@ -149,37 +208,51 @@ new class extends Component {
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if(session('error'))
|
||||
<div class="mb-6">
|
||||
<flux:callout variant="danger" icon="exclamation-circle">
|
||||
{{ session('error') }}
|
||||
</flux:callout>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
{{-- Add Update Form --}}
|
||||
<div class="mb-6 rounded-lg border border-zinc-200 bg-white p-6 dark:border-zinc-700 dark:bg-zinc-800">
|
||||
<div class="mb-6 rounded-lg border border-zinc-200 bg-white p-6 dark:border-zinc-700 dark:bg-zinc-800 {{ $timeline->isArchived() ? 'opacity-60' : '' }}">
|
||||
<flux:heading size="lg" class="mb-4">{{ __('timelines.add_update') }}</flux:heading>
|
||||
|
||||
<form wire:submit="{{ $editingUpdateId ? 'saveEdit' : 'addUpdate' }}">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('timelines.update_text') }} *</flux:label>
|
||||
<flux:textarea
|
||||
wire:model="updateText"
|
||||
rows="4"
|
||||
placeholder="{{ __('timelines.update_placeholder') }}"
|
||||
/>
|
||||
<flux:description>{{ __('timelines.update_min_chars') }}</flux:description>
|
||||
<flux:error name="updateText" />
|
||||
</flux:field>
|
||||
@if($timeline->isArchived())
|
||||
<flux:callout variant="warning" icon="archive-box">
|
||||
{{ __('timelines.archived_notice') }}
|
||||
</flux:callout>
|
||||
@else
|
||||
<form wire:submit="{{ $editingUpdateId ? 'saveEdit' : 'addUpdate' }}">
|
||||
<flux:field>
|
||||
<flux:label>{{ __('timelines.update_text') }} *</flux:label>
|
||||
<flux:textarea
|
||||
wire:model="updateText"
|
||||
rows="4"
|
||||
placeholder="{{ __('timelines.update_placeholder') }}"
|
||||
/>
|
||||
<flux:description>{{ __('timelines.update_min_chars') }}</flux:description>
|
||||
<flux:error name="updateText" />
|
||||
</flux:field>
|
||||
|
||||
<div class="mt-4 flex items-center gap-3">
|
||||
@if($editingUpdateId)
|
||||
<flux:button variant="primary" type="submit">
|
||||
{{ __('timelines.save_edit') }}
|
||||
</flux:button>
|
||||
<flux:button variant="ghost" type="button" wire:click="cancelEdit">
|
||||
{{ __('timelines.cancel') }}
|
||||
</flux:button>
|
||||
@else
|
||||
<flux:button variant="primary" type="submit">
|
||||
{{ __('timelines.add_update_button') }}
|
||||
</flux:button>
|
||||
@endif
|
||||
</div>
|
||||
</form>
|
||||
<div class="mt-4 flex items-center gap-3">
|
||||
@if($editingUpdateId)
|
||||
<flux:button variant="primary" type="submit">
|
||||
{{ __('timelines.save_edit') }}
|
||||
</flux:button>
|
||||
<flux:button variant="ghost" type="button" wire:click="cancelEdit">
|
||||
{{ __('timelines.cancel') }}
|
||||
</flux:button>
|
||||
@else
|
||||
<flux:button variant="primary" type="submit">
|
||||
{{ __('timelines.add_update_button') }}
|
||||
</flux:button>
|
||||
@endif
|
||||
</div>
|
||||
</form>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- Timeline Updates --}}
|
||||
@@ -220,7 +293,7 @@ new class extends Component {
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if(!$editingUpdateId)
|
||||
@if(!$editingUpdateId && $timeline->isActive())
|
||||
<flux:button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
@@ -242,4 +315,23 @@ new class extends Component {
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- Archive Confirmation Modal --}}
|
||||
<flux:modal name="archive-confirm" class="max-w-md">
|
||||
<div class="space-y-6">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('timelines.archive_confirm_title') }}</flux:heading>
|
||||
<flux:text class="mt-2">{{ __('timelines.archive_confirm_message') }}</flux:text>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-3">
|
||||
<flux:modal.close>
|
||||
<flux:button variant="ghost">{{ __('timelines.cancel') }}</flux:button>
|
||||
</flux:modal.close>
|
||||
<flux:button variant="danger" wire:click="archive" x-on:click="$flux.modal('archive-confirm').close()">
|
||||
{{ __('timelines.archive') }}
|
||||
</flux:button>
|
||||
</div>
|
||||
</div>
|
||||
</flux:modal>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user