mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-03-14 12:23:33 +00:00
feat: add update functionality for device palettes in UI
This commit is contained in:
parent
e71d79190a
commit
8beeff754f
2 changed files with 46 additions and 3 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Jobs\FetchDeviceModelsJob;
|
||||
use App\Models\DevicePalette;
|
||||
use Livewire\Component;
|
||||
|
||||
|
|
@ -58,6 +59,13 @@ new class extends Component
|
|||
|
||||
public $viewingDevicePaletteId;
|
||||
|
||||
public function updateFromApi(): void
|
||||
{
|
||||
FetchDeviceModelsJob::dispatchSync();
|
||||
$this->devicePalettes = DevicePalette::all();
|
||||
session()->flash('message', 'Device palettes updated from API.');
|
||||
}
|
||||
|
||||
public function openDevicePaletteModal(?string $devicePaletteId = null, bool $viewOnly = false): void
|
||||
{
|
||||
if ($devicePaletteId) {
|
||||
|
|
@ -202,9 +210,17 @@ new class extends Component
|
|||
</flux:menu>
|
||||
</flux:dropdown>
|
||||
</div>
|
||||
<flux:modal.trigger name="device-palette-modal">
|
||||
<flux:button wire:click="openDevicePaletteModal()" icon="plus" variant="primary">Add Device Palette</flux:button>
|
||||
</flux:modal.trigger>
|
||||
<flux:button.group>
|
||||
<flux:modal.trigger name="device-palette-modal">
|
||||
<flux:button wire:click="openDevicePaletteModal()" icon="plus" variant="primary">Add Device Palette</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 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