mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-14 15:37:53 +00:00
fix style
fix: playlist form
This commit is contained in:
parent
b8a0aa47bf
commit
71eaeac949
2 changed files with 34 additions and 4 deletions
|
|
@ -20,6 +20,7 @@ new class extends Component {
|
||||||
public $selected_weekdays = null;
|
public $selected_weekdays = null;
|
||||||
public $active_from;
|
public $active_from;
|
||||||
public $active_until;
|
public $active_until;
|
||||||
|
public $refresh_time = null;
|
||||||
|
|
||||||
public function mount(\App\Models\Device $device)
|
public function mount(\App\Models\Device $device)
|
||||||
{
|
{
|
||||||
|
|
@ -77,13 +78,23 @@ new class extends Component {
|
||||||
'selected_weekdays' => 'nullable|array',
|
'selected_weekdays' => 'nullable|array',
|
||||||
'active_from' => 'nullable|date_format:H:i',
|
'active_from' => 'nullable|date_format:H:i',
|
||||||
'active_until' => 'nullable|date_format:H:i',
|
'active_until' => 'nullable|date_format:H:i',
|
||||||
|
'refresh_time' => 'nullable|integer|min:60',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($this->refresh_time < 60) {
|
||||||
|
$this->refresh_time = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($this->selected_weekdays)){
|
||||||
|
$this->selected_weekdays = null;
|
||||||
|
}
|
||||||
|
|
||||||
$this->device->playlists()->create([
|
$this->device->playlists()->create([
|
||||||
'name' => $this->playlist_name,
|
'name' => $this->playlist_name,
|
||||||
'weekdays' => $this->selected_weekdays,
|
'weekdays' => $this->selected_weekdays,
|
||||||
'active_from' => $this->active_from,
|
'active_from' => $this->active_from,
|
||||||
'active_until' => $this->active_until,
|
'active_until' => $this->active_until,
|
||||||
|
'refresh_time' => $this->refresh_time,
|
||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -154,29 +165,40 @@ new class extends Component {
|
||||||
{
|
{
|
||||||
$this->validate([
|
$this->validate([
|
||||||
'playlist_name' => 'required|string|max:255',
|
'playlist_name' => 'required|string|max:255',
|
||||||
'selected_weekdays' => 'array',
|
'selected_weekdays' => 'nullable|array',
|
||||||
'active_from' => 'nullable|date_format:H:i',
|
'active_from' => 'nullable|date_format:H:i',
|
||||||
'active_until' => 'nullable|date_format:H:i',
|
'active_until' => 'nullable|date_format:H:i',
|
||||||
|
'refresh_time' => 'nullable|integer|min:60',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($this->refresh_time < 60) {
|
||||||
|
$this->refresh_time = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($this->selected_weekdays)){
|
||||||
|
$this->selected_weekdays = null;
|
||||||
|
}
|
||||||
|
|
||||||
$playlist->update([
|
$playlist->update([
|
||||||
'name' => $this->playlist_name,
|
'name' => $this->playlist_name,
|
||||||
'weekdays' => $this->selected_weekdays,
|
'weekdays' => $this->selected_weekdays,
|
||||||
'active_from' => $this->active_from,
|
'active_from' => $this->active_from,
|
||||||
'active_until' => $this->active_until,
|
'active_until' => $this->active_until,
|
||||||
|
'refresh_time' => $this->refresh_time,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get();
|
$this->playlists = $this->device->playlists()->with('items.plugin')->orderBy('created_at')->get();
|
||||||
$this->reset(['playlist_name', 'selected_weekdays', 'active_from', 'active_until']);
|
$this->reset(['playlist_name', 'selected_weekdays', 'active_from', 'active_until', 'refresh_time']);
|
||||||
Flux::modal('edit-playlist-' . $playlist->id)->close();
|
Flux::modal('edit-playlist-' . $playlist->id)->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preparePlaylistEdit(Playlist $playlist)
|
public function preparePlaylistEdit(Playlist $playlist)
|
||||||
{
|
{
|
||||||
$this->playlist_name = $playlist->name;
|
$this->playlist_name = $playlist->name;
|
||||||
$this->selected_weekdays = $playlist->weekdays ?? [];
|
$this->selected_weekdays = $playlist->weekdays ?? null;
|
||||||
$this->active_from = optional($playlist->active_from)->format('H:i');
|
$this->active_from = optional($playlist->active_from)->format('H:i');
|
||||||
$this->active_until = optional($playlist->active_until)->format('H:i');
|
$this->active_until = optional($playlist->active_until)->format('H:i');
|
||||||
|
$this->refresh_time = $playlist->refresh_time;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
@ -323,6 +345,10 @@ new class extends Component {
|
||||||
<flux:input type="time" label="Active Until" wire:model="active_until"/>
|
<flux:input type="time" label="Active Until" wire:model="active_until"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<flux:input type="number" label="Refresh Time (seconds)" wire:model="refresh_time" min="1" placeholder="Leave empty to use device default"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<flux:spacer/>
|
<flux:spacer/>
|
||||||
<flux:button type="submit" variant="primary">Create Playlist</flux:button>
|
<flux:button type="submit" variant="primary">Create Playlist</flux:button>
|
||||||
|
|
@ -392,6 +418,10 @@ new class extends Component {
|
||||||
<flux:input type="time" label="Active Until" wire:model="active_until"/>
|
<flux:input type="time" label="Active Until" wire:model="active_until"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<flux:input type="number" label="Refresh Time (seconds)" wire:model="refresh_time" min="1" placeholder="Leave empty to use device default"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<flux:spacer/>
|
<flux:spacer/>
|
||||||
<flux:button type="submit" variant="primary">Save Changes</flux:button>
|
<flux:button type="submit" variant="primary">Save Changes</flux:button>
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ HTML;
|
||||||
<flux:button icon="chevron-down" variant="primary"></flux:button>
|
<flux:button icon="chevron-down" variant="primary"></flux:button>
|
||||||
<flux:menu>
|
<flux:menu>
|
||||||
<flux:modal.trigger name="delete-plugin">
|
<flux:modal.trigger name="delete-plugin">
|
||||||
<flux:menu.item icon="trash">Delete Plugin</flux:menu.item>
|
<flux:menu.item icon="trash" variant="danger">Delete Plugin</flux:menu.item>
|
||||||
</flux:modal.trigger>
|
</flux:modal.trigger>
|
||||||
</flux:menu>
|
</flux:menu>
|
||||||
</flux:dropdown>
|
</flux:dropdown>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue