From 1861d67971e2cc0c20ace091f037f6436437a50d Mon Sep 17 00:00:00 2001 From: Yassine Doghri Date: Wed, 29 Nov 2023 16:00:28 +0000 Subject: [PATCH] fix(podcast-form): move fediverse section below author section --- app/Entities/Episode.php | 12 ++++++++ app/Models/ClipModel.php | 10 +++++++ themes/cp_admin/episode/_sidebar.php | 8 ++++-- themes/cp_admin/podcast/create.php | 40 +++++++++++++-------------- themes/cp_admin/podcast/edit.php | 41 ++++++++++++++-------------- 5 files changed, 66 insertions(+), 45 deletions(-) diff --git a/app/Entities/Episode.php b/app/Entities/Episode.php index bc43df17..3fc08e5f 100644 --- a/app/Entities/Episode.php +++ b/app/Entities/Episode.php @@ -688,4 +688,16 @@ class Episode extends Entity return url_to('episode-preview', (string) $this->preview_id); } + + /** + * Returns the episode's clip count + */ + public function getClipCount(): int|string + { + if ($this->id === null) { + throw new RuntimeException('Episode must be created before getting number of video clips.'); + } + + return (new ClipModel())->getClipCount($this->podcast_id, $this->id); + } } diff --git a/app/Models/ClipModel.php b/app/Models/ClipModel.php index 819d8e42..0e372614 100644 --- a/app/Models/ClipModel.php +++ b/app/Models/ClipModel.php @@ -173,6 +173,16 @@ class ClipModel extends Model ]); } + public function getClipCount(int $podcastId, int $episodeId): int + { + return $this + ->where([ + 'podcast_id' => $podcastId, + 'episode_id' => $episodeId, + ]) + ->countAllResults(); + } + public function clearVideoClipCache(int $clipId): void { cache() diff --git a/themes/cp_admin/episode/_sidebar.php b/themes/cp_admin/episode/_sidebar.php index 52b07631..d5c7f83e 100644 --- a/themes/cp_admin/episode/_sidebar.php +++ b/themes/cp_admin/episode/_sidebar.php @@ -6,9 +6,11 @@ $episodeNavigation = [ 'items' => ['episode-view', 'episode-edit', 'episode-persons-manage', 'embed-add'], ], 'clips' => [ - 'icon' => 'clapperboard', - 'items' => ['video-clips-list', 'video-clips-create', 'soundbites-list', 'soundbites-create'], - 'add-cta' => 'video-clips-create', + 'icon' => 'clapperboard', + 'items' => ['video-clips-list', 'video-clips-create', 'soundbites-list', 'soundbites-create'], + 'count' => $episode->getClipCount(), + 'count-route' => 'video-clips-list', + 'add-cta' => 'video-clips-create', ], ]; ?> diff --git a/themes/cp_admin/podcast/create.php b/themes/cp_admin/podcast/create.php index a14f0950..62c3b642 100644 --- a/themes/cp_admin/podcast/create.php +++ b/themes/cp_admin/podcast/create.php @@ -56,27 +56,6 @@ isChecked="false" > - - - - - -
- -
- - -
-
- -
+ + +
+ +
+ + +
+
+ + +
+ diff --git a/themes/cp_admin/podcast/edit.php b/themes/cp_admin/podcast/edit.php index 930b4a4d..4de46ec0 100644 --- a/themes/cp_admin/podcast/edit.php +++ b/themes/cp_admin/podcast/edit.php @@ -78,27 +78,6 @@ isChecked="type === 'serial' ? 'true' : 'false' ?>" > - - - - - -
- -
- - -
-
- - -
+ + +
+ +
+ + +
+
+ + + +
+