mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-14 20:33:40 +00:00
feat: add update functionality for device models in UI
This commit is contained in:
parent
06e6fb0e84
commit
e71d79190a
2 changed files with 57 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Jobs\FetchDeviceModelsJob;
|
||||
use App\Models\DeviceModel;
|
||||
use App\Models\DevicePalette;
|
||||
use Livewire\Component;
|
||||
|
|
@ -66,6 +67,14 @@ new class extends Component
|
|||
|
||||
public $viewingDeviceModelId;
|
||||
|
||||
public function updateFromApi(): void
|
||||
{
|
||||
FetchDeviceModelsJob::dispatchSync();
|
||||
$this->deviceModels = DeviceModel::all();
|
||||
$this->devicePalettes = DevicePalette::all();
|
||||
session()->flash('message', 'Device models updated from API.');
|
||||
}
|
||||
|
||||
public function openDeviceModelModal(?string $deviceModelId = null, bool $viewOnly = false): void
|
||||
{
|
||||
if ($deviceModelId) {
|
||||
|
|
@ -229,9 +238,17 @@ new class extends Component
|
|||
</flux:menu>
|
||||
</flux:dropdown>
|
||||
</div>
|
||||
<flux:modal.trigger name="device-model-modal">
|
||||
<flux:button wire:click="openDeviceModelModal()" icon="plus" variant="primary">Add Device Model</flux:button>
|
||||
</flux:modal.trigger>
|
||||
<flux:button.group>
|
||||
<flux:modal.trigger name="device-model-modal">
|
||||
<flux:button wire:click="openDeviceModelModal()" icon="plus" variant="primary">Add Device Model</flux:button>
|
||||
</flux:modal.trigger>
|
||||
<flux:dropdown>
|
||||
<flux:button icon="chevron-down" variant="primary"></flux:button>
|
||||
<flux:menu>
|
||||
<flux:menu.item icon="arrow-path" wire:click="updateFromApi">Update from Models API</flux:menu.item>
|
||||
</flux:menu>
|
||||
</flux:dropdown>
|
||||
</flux:button.group>
|
||||
</div>
|
||||
@if (session()->has('message'))
|
||||
<div class="mb-4">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue