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.
This commit is contained in:
Will Miao
2025-11-19 22:26:16 +08:00
parent bcf72c6bcc
commit 8c77080ae6
2 changed files with 15 additions and 5 deletions

View File

@@ -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 {};

View File

@@ -147,6 +147,7 @@
</div>
</div>
{% endif %}
{% if current_page != 'recipes' %}
<div class="filter-section">
<h4>{{ t('header.filter.license') }}</h4>
<div class="filter-tags">
@@ -158,6 +159,7 @@
</div>
</div>
</div>
{% endif %}
<div class="filter-actions">
<button class="clear-filters-btn" onclick="filterManager.clearFilters()">
{{ t('header.filter.clearAll') }}