From 0d32ff693905eeac51888bcb210b801cc8e5c899 Mon Sep 17 00:00:00 2001 From: edalzell Date: Tue, 12 May 2026 15:46:35 -0700 Subject: [PATCH 1/3] check for the template --- resources/js/pages/taxonomies/Show.vue | 2 +- src/Http/Resources/CP/Taxonomies/ListedTerm.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/js/pages/taxonomies/Show.vue b/resources/js/pages/taxonomies/Show.vue index fe06b007886..d4265a3981a 100644 --- a/resources/js/pages/taxonomies/Show.vue +++ b/resources/js/pages/taxonomies/Show.vue @@ -139,7 +139,7 @@ export default { {{ term.slug }} diff --git a/src/Http/Resources/CP/Taxonomies/ListedTerm.php b/src/Http/Resources/CP/Taxonomies/ListedTerm.php index 1aa5e99c459..1dd0573358e 100644 --- a/src/Http/Resources/CP/Taxonomies/ListedTerm.php +++ b/src/Http/Resources/CP/Taxonomies/ListedTerm.php @@ -40,6 +40,7 @@ public function toArray($request) 'permalink' => $term->absoluteUrl(), 'edit_url' => $term->editUrl(), + 'hasTemplate' => view()->exists($term->template()), 'taxonomy' => $term->taxonomy()->toArray(), 'viewable' => User::current()->can('view', $term), 'editable' => User::current()->can('edit', $term), From 422698e01e604a8af4d0834212311f64380885ef Mon Sep 17 00:00:00 2001 From: edalzell Date: Tue, 12 May 2026 15:57:52 -0700 Subject: [PATCH 2/3] snake case --- resources/js/pages/taxonomies/Show.vue | 2 +- src/Http/Resources/CP/Taxonomies/ListedTerm.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/js/pages/taxonomies/Show.vue b/resources/js/pages/taxonomies/Show.vue index d4265a3981a..a6046715267 100644 --- a/resources/js/pages/taxonomies/Show.vue +++ b/resources/js/pages/taxonomies/Show.vue @@ -139,7 +139,7 @@ export default { {{ term.slug }} diff --git a/src/Http/Resources/CP/Taxonomies/ListedTerm.php b/src/Http/Resources/CP/Taxonomies/ListedTerm.php index 1dd0573358e..9065299626a 100644 --- a/src/Http/Resources/CP/Taxonomies/ListedTerm.php +++ b/src/Http/Resources/CP/Taxonomies/ListedTerm.php @@ -40,7 +40,7 @@ public function toArray($request) 'permalink' => $term->absoluteUrl(), 'edit_url' => $term->editUrl(), - 'hasTemplate' => view()->exists($term->template()), + 'has_template' => view()->exists($term->template()), 'taxonomy' => $term->taxonomy()->toArray(), 'viewable' => User::current()->can('view', $term), 'editable' => User::current()->can('edit', $term), From db87b44a4b064c9cdc1fb6db1818c762012a5426 Mon Sep 17 00:00:00 2001 From: edalzell Date: Tue, 12 May 2026 15:57:57 -0700 Subject: [PATCH 3/3] test --- .../Taxonomies/ViewTermsListingTest.php | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/Feature/Taxonomies/ViewTermsListingTest.php b/tests/Feature/Taxonomies/ViewTermsListingTest.php index 48ab1e4873f..b2eb150923d 100644 --- a/tests/Feature/Taxonomies/ViewTermsListingTest.php +++ b/tests/Feature/Taxonomies/ViewTermsListingTest.php @@ -6,12 +6,13 @@ use Statamic\Facades\Taxonomy; use Statamic\Facades\Term; use Statamic\Facades\User; +use Tests\FakesViews; use Tests\PreventSavingStacheItemsToDisk; use Tests\TestCase; class ViewTermsListingTest extends TestCase { - use PreventSavingStacheItemsToDisk; + use FakesViews, PreventSavingStacheItemsToDisk; #[Test] public function it_does_not_eager_load_actions_in_listing() @@ -28,4 +29,37 @@ public function it_does_not_eager_load_actions_in_listing() ->assertJsonCount(1, 'data') ->assertJsonMissingPath('data.0.actions'); } + + #[Test] + public function it_returns_has_template_true_when_template_exists() + { + $this->withFakeViews(); + $this->viewShouldReturnRaw('tags.show', ''); + + $user = tap(User::make()->makeSuper())->save(); + $taxonomy = tap(Taxonomy::make('tags'))->save(); + tap(Term::make()->taxonomy('tags')->inDefaultLocale()->slug('alfa')->data(['title' => 'alfa']))->save(); + + $this + ->actingAs($user) + ->getJson(cp_route('taxonomies.terms.index', $taxonomy->handle())) + ->assertSuccessful() + ->assertJsonPath('data.0.has_template', true); + } + + #[Test] + public function it_returns_has_template_false_when_template_does_not_exist() + { + $this->withFakeViews(); + + $user = tap(User::make()->makeSuper())->save(); + $taxonomy = tap(Taxonomy::make('tags'))->save(); + tap(Term::make()->taxonomy('tags')->inDefaultLocale()->slug('alfa')->data(['title' => 'alfa']))->save(); + + $this + ->actingAs($user) + ->getJson(cp_route('taxonomies.terms.index', $taxonomy->handle())) + ->assertSuccessful() + ->assertJsonPath('data.0.has_template', false); + } }