feat: add setting to control category products button visibility

- Add show_category_products_button field to StoreDTO
- Update SettingsSerializerService to support new field
- Add setting in admin panel on 'Store' tab with toggle
- Pass setting to SPA through SettingsHandler
- Button displays only for categories with child categories
- Add default value true to configuration
This commit is contained in:
2025-12-24 01:45:50 +03:00
parent 7b0e5f80e9
commit c3994b2291
9 changed files with 50 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ export const useSettingsStore = defineStore('settings', {
enable_store: true,
feature_coupons: true,
feature_vouchers: true,
show_category_products_button: true,
},
orders: {

View File

@@ -21,6 +21,10 @@
<a :href="`/admin/index.php?route=sale/voucher&user_token=${userToken}`"
target="_blank">подарочные сертификаты OpenCart</a> при оформлении заказа.</p>
</ItemBool>
<ItemBool label="Показывать кнопку «Показать товары из текущей категории»" v-model="settings.items.store.show_category_products_button">
<p>Включите, чтобы пользователи видели кнопку «Показать товары из "название текущей категории"» на странице категории, если у неё есть дочерние категории. Настройка работает только для страниц категорий с дочерними категориями, при отключении кнопка скрыта.</p>
</ItemBool>
</template>
<script setup>

View File

@@ -12,6 +12,7 @@ export const useSettingsStore = defineStore('settings', {
ya_metrika_enabled: false,
feature_coupons: false,
feature_vouchers: false,
show_category_products_button: true,
currency_code: null,
theme: {
light: 'light', dark: 'dark', variables: {
@@ -43,6 +44,7 @@ export const useSettingsStore = defineStore('settings', {
this.store_enabled = settings.store_enabled;
this.feature_coupons = settings.feature_coupons;
this.feature_vouchers = settings.feature_vouchers;
this.show_category_products_button = settings.show_category_products_button ?? true;
this.currency_code = settings.currency_code;
this.texts = settings.texts;
this.mainpage_blocks = settings.mainpage_blocks;

View File

@@ -18,7 +18,7 @@
</button>
<button
v-if="parentCategory"
v-if="parentCategory && parentCategory.children?.length && settings.show_category_products_button"
class="py-2 px-4 flex items-center mb-3 cursor-pointer border-b w-full pb-2 border-base-200"
@click.prevent="showProductsInParentCategory"
>
@@ -59,11 +59,13 @@ import {useCategoriesStore} from "@/stores/CategoriesStore.js";
import {useRoute} from "vue-router";
import CategoryItem from "@/components/CategoriesList/CategoryItem.vue";
import {useYaMetrikaStore} from "@/stores/yaMetrikaStore.js";
import {useSettingsStore} from "@/stores/SettingsStore.js";
import BaseViewWrapper from "@/views/BaseViewWrapper.vue";
const route = useRoute();
const categoriesStore = useCategoriesStore();
const yaMetrika = useYaMetrikaStore();
const settings = useSettingsStore();
const parentId = computed(() => route.params.id ? Number(route.params.id) : null);