From 8c77080ae6aa6c8709317165c77727204fe544af Mon Sep 17 00:00:00 2001 From: Will Miao Date: Wed, 19 Nov 2025 22:26:16 +0800 Subject: [PATCH] feat: conditionally hide license filters on recipes page Add shouldShowLicenseFilters method to check if current page is 'recipes' and skip license filter initialization and updates when on recipes page. Also conditionally render license filter section in header template based on current page. This prevents license filters from appearing on the recipes page where they are not applicable. --- static/js/managers/FilterManager.js | 18 +++++++++++++----- templates/components/header.html | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/static/js/managers/FilterManager.js b/static/js/managers/FilterManager.js index 23e4ac89..8d28fb31 100644 --- a/static/js/managers/FilterManager.js +++ b/static/js/managers/FilterManager.js @@ -39,8 +39,10 @@ export class FilterManager { this.createModelTypeTags(); } - // Add click handlers for license filter tags - this.initializeLicenseFilters(); + // Add click handlers for license filter tags if supported on this page + if (this.shouldShowLicenseFilters()) { + this.initializeLicenseFilters(); + } // Add click handler for filter button if (this.filterButton) { @@ -386,8 +388,10 @@ export class FilterManager { this.applyTagElementState(tag, state); }); - // Update license tags - this.updateLicenseSelections(); + // Update license tags if visible on this page + if (this.shouldShowLicenseFilters()) { + this.updateLicenseSelections(); + } this.updateModelTypeSelections(); } @@ -546,11 +550,15 @@ export class FilterManager { ...source, baseModel: Array.isArray(source.baseModel) ? [...source.baseModel] : [], tags: this.normalizeTagFilters(source.tags), - license: this.normalizeLicenseFilters(source.license), + license: this.shouldShowLicenseFilters() ? this.normalizeLicenseFilters(source.license) : {}, modelTypes: this.normalizeModelTypeFilters(source.modelTypes) }; } + shouldShowLicenseFilters() { + return this.currentPage !== 'recipes'; + } + normalizeTagFilters(tagFilters) { if (!tagFilters) { return {}; diff --git a/templates/components/header.html b/templates/components/header.html index 2c358914..e2942c39 100644 --- a/templates/components/header.html +++ b/templates/components/header.html @@ -147,6 +147,7 @@ {% endif %} + {% if current_page != 'recipes' %}

{{ t('header.filter.license') }}

@@ -158,6 +159,7 @@
+ {% endif %}