Skip to content

Commit

Permalink
TrackingEventEdit fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
xGrz committed Jun 7, 2024
1 parent 0c8a8c9 commit 7233392
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<div class="grid gap-2 p-2">
<p>
<small class="block text-slate-500">DHL system description:</small>
<span class="italic">{{$description}}</span>
<span class="italic">{{$system_description}}</span>
</p>
<x-p-input label="Your description" wire:model.live.debounce.300ms="custom_description"/>
<x-p-input label="Your description" wire:model.live.debounce.300ms="description"/>
<x-p-select wire:model.live="type" label="Stan dostawy">
@foreach($types as $ident => $typeName)
<option value="{{$ident}}">{{$typeName}}</option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<x-p-tbody>
@foreach($events as $event)
<x-p-tr>
<x-p-td>{{$event->symbol}}</x-p-td>
<x-p-td>{{$event->custom_description ?? $event->description}}</x-p-td>
<x-p-td class="font-bold text-sm {{$event->type?->getStateColor()}}">{{$event->code}}</x-p-td>
<x-p-td class="text-sm">{{$event->label}}</x-p-td>
<x-p-td>{{$event->type->getLabel()}}</x-p-td>
<x-p-td right>
<x-p-button
wire:click="$dispatch('openModal', { component: 'tracking-event-edit', arguments: { event: '{{$event->symbol}}' }}) " size="small"
wire:click="$dispatch('openModal', { component: 'tracking-event-edit', arguments: { event: '{{$event->code}}' }}) " size="small"
>
Edit
</x-p-button>
Expand Down
7 changes: 5 additions & 2 deletions resources/views/shipments/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@
class="absolute w-3 h-3 rounded-full mt-1.5 -start-1.5 border border-white {{ str($event->type->getStateColor())->replace('text', 'bg') }}"></div>
<time
class="mb-1 text-sm font-normal leading-none text-gray-500">{{$event->pivot->event_timestamp}}</time>
<div class="text-lg font-semibold {{$event->type->getStateColor()}}">{{$event->getDescription()}}</div>
<div
class="text-lg font-semibold {{$event->type->getStateColor()}}">{{$event->label}}</div>
<p>
@if($event->pivot->terminal){{'@'}}{{$event->pivot->terminal}}@endif
@if($event->pivot->terminal)
{{'@'}}{{$event->pivot->terminal}}
@endif
</p>
</li>
@endforeach
Expand Down
16 changes: 8 additions & 8 deletions src/Livewire/Settings/TrackingEvents/TrackingEventEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
use Livewire\Attributes\Validate;
use LivewireUI\Modal\ModalComponent;
use xGrz\Dhl24\Enums\DHLStatusType;
use xGrz\Dhl24\Models\DHLStatus;
use xGrz\Dhl24\Models\DHLTrackingState;

class TrackingEventEdit extends ModalComponent
{
public DHLStatus $event;
public DHLTrackingState $event;
public $types = [];

public $description = '';
#[Validate]
public $custom_description = '';
public $description = '';
public $system_description = '';
public $type;

public function mount(DHLStatus $event): void
public function mount(DHLTrackingState $event): void
{
$this->types = DHLStatusType::getOptions();
$this->type = $event->type;
$this->event = $event;
$this->system_description = $event->system_description;
$this->description = $event->description;
$this->custom_description = $event->custom_description;
}
public function render(): View
{
Expand All @@ -36,7 +36,7 @@ public function render(): View
public function rules(): array
{
return [
'custom_description' => 'string',
'description' => 'string',
'type' => 'required'
];
}
Expand All @@ -45,7 +45,7 @@ public function update(): void
{
$this->validate();
$this->event->update([
'custom_description' => $this->custom_description,
'description' => $this->description,
'type' => $this->type
]);
$this->closeModal();
Expand Down
11 changes: 5 additions & 6 deletions src/Livewire/Settings/TrackingEvents/TrackingEventListing.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@
use Illuminate\Database\Eloquent\Collection;
use Illuminate\View\View;
use Livewire\Component;
use xGrz\Dhl24\Models\DHLStatus;
use xGrz\Dhl24\Facades\DHL24;

class TrackingEventListing extends Component
{
public Collection $events;

public function mount(): void
{
self::loadEvents();
$this->events = DHL24::states()
->query()
->orderByTypes()
->get();
}

public function render(): View
{
return view('dhl-ui::settings.livewire.tracking-events.tracking-event-listing');
}

private function loadEvents(): void
{
$this->events = DHLStatus::orderByTypes()->get();
}

}

0 comments on commit 7233392

Please sign in to comment.