Add ability to edit the playlist name and visibility #5

This commit is contained in:
2026-07-19 13:22:28 +02:00
parent a04d58c60f
commit f35d1a119e
9 changed files with 290 additions and 85 deletions
+51
View File
@@ -26,6 +26,10 @@ class PlaylistOverview extends Component
public Collection $playlistEpisodes;
public bool $editingName = false;
public string $editingPlaylistName = '';
public function boot(PlaylistService $playlistService)
{
$this->playlistService = $playlistService;
@@ -112,6 +116,53 @@ class PlaylistOverview extends Component
$this->refreshEpisodes();
}
public function editName()
{
if (! Auth::check() || Auth::user()->id !== $this->playlist->user->id) {
return;
}
$this->editingPlaylistName = $this->playlist->name;
$this->editingName = true;
}
public function cancelEditName()
{
$this->editingName = false;
$this->editingPlaylistName = '';
}
public function updateName()
{
if (! Auth::check() || Auth::user()->id !== $this->playlist->user->id) {
return;
}
$this->validate([
'editingPlaylistName' => 'required|max:30',
]);
$this->playlist->update([
'name' => $this->editingPlaylistName,
]);
$this->editingName = false;
$this->editingPlaylistName = '';
}
public function toggleVisibility()
{
if (! Auth::check() || Auth::user()->id !== $this->playlist->user->id) {
return;
}
$this->playlist->update([
'is_private' => ! $this->playlist->is_private,
]);
$this->playlist->refresh();
}
public function render()
{
return view('livewire.playlist-overview', [