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:
@@ -20,6 +20,30 @@
|
||||
4. **Тестируй изменения перед коммитом**
|
||||
5. **Документируй публичные API**
|
||||
|
||||
### Правила коммитов
|
||||
|
||||
1. **Следование Conventional Commits**
|
||||
- Используй префиксы: `feat:`, `fix:`, `chore:`, `refactor:`, `style:`, `test:`, `docs:`
|
||||
- Формат: `<type>: <subject>` (первая строка до 72 символов)
|
||||
- После пустой строки - подробное описание изменений
|
||||
|
||||
2. **Язык коммитов**
|
||||
- Все коммиты на **английском языке**
|
||||
- Подробное описание изменений в теле коммита
|
||||
- Перечисляй все измененные файлы и ключевые изменения
|
||||
|
||||
3. **Примеры правильных коммитов**
|
||||
```
|
||||
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
|
||||
```
|
||||
|
||||
### Запрещено
|
||||
|
||||
- Хардкод значений (используй конфиги/настройки)
|
||||
|
||||
@@ -39,6 +39,7 @@ export const useSettingsStore = defineStore('settings', {
|
||||
enable_store: true,
|
||||
feature_coupons: true,
|
||||
feature_vouchers: true,
|
||||
show_category_products_button: true,
|
||||
},
|
||||
|
||||
orders: {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ HTML,
|
||||
'enable_store' => true,
|
||||
'feature_coupons' => true,
|
||||
'feature_vouchers' => true,
|
||||
'show_category_products_button' => true,
|
||||
],
|
||||
|
||||
'texts' => [
|
||||
|
||||
@@ -7,6 +7,7 @@ final class StoreDTO
|
||||
private bool $enableStore;
|
||||
private bool $featureCoupons;
|
||||
private bool $featureVouchers;
|
||||
private bool $showCategoryProductsButton;
|
||||
private string $ocDefaultCurrency;
|
||||
private bool $ocConfigTax;
|
||||
private int $ocStoreId;
|
||||
@@ -15,6 +16,7 @@ final class StoreDTO
|
||||
bool $enableStore,
|
||||
bool $featureCoupons,
|
||||
bool $featureVouchers,
|
||||
bool $showCategoryProductsButton,
|
||||
string $ocDefaultCurrency,
|
||||
bool $ocConfigTax,
|
||||
int $ocStoreId
|
||||
@@ -22,6 +24,7 @@ final class StoreDTO
|
||||
$this->enableStore = $enableStore;
|
||||
$this->featureCoupons = $featureCoupons;
|
||||
$this->featureVouchers = $featureVouchers;
|
||||
$this->showCategoryProductsButton = $showCategoryProductsButton;
|
||||
$this->ocDefaultCurrency = $ocDefaultCurrency;
|
||||
$this->ocConfigTax = $ocConfigTax;
|
||||
$this->ocStoreId = $ocStoreId;
|
||||
@@ -42,6 +45,11 @@ final class StoreDTO
|
||||
return $this->featureVouchers;
|
||||
}
|
||||
|
||||
public function isShowCategoryProductsButton(): bool
|
||||
{
|
||||
return $this->showCategoryProductsButton;
|
||||
}
|
||||
|
||||
public function getOcDefaultCurrency(): string
|
||||
{
|
||||
return $this->ocDefaultCurrency;
|
||||
@@ -63,6 +71,7 @@ final class StoreDTO
|
||||
'enable_store' => $this->enableStore,
|
||||
'feature_coupons' => $this->featureCoupons,
|
||||
'feature_vouchers' => $this->featureVouchers,
|
||||
'show_category_products_button' => $this->showCategoryProductsButton,
|
||||
'oc_default_currency' => $this->ocDefaultCurrency,
|
||||
'oc_config_tax' => $this->ocConfigTax,
|
||||
'oc_store_id' => $this->ocStoreId,
|
||||
|
||||
@@ -48,6 +48,7 @@ class SettingsHandler
|
||||
'store_enabled' => $this->settings->config()->getStore()->isEnableStore(),
|
||||
'feature_coupons' => $this->settings->config()->getStore()->isFeatureCoupons(),
|
||||
'feature_vouchers' => $this->settings->config()->getStore()->isFeatureVouchers(),
|
||||
'show_category_products_button' => $this->settings->config()->getStore()->isShowCategoryProductsButton(),
|
||||
'currency_code' => $this->settings->config()->getStore()->getOcDefaultCurrency(),
|
||||
'texts' => $this->settings->config()->getTexts()->toArray(),
|
||||
'mainpage_blocks' => $this->settings->get('mainpage_blocks', []),
|
||||
|
||||
@@ -141,6 +141,7 @@ class SettingsSerializerService
|
||||
$data['enable_store'] ?? true,
|
||||
$data['feature_coupons'] ?? true,
|
||||
$data['feature_vouchers'] ?? true,
|
||||
$data['show_category_products_button'] ?? true,
|
||||
$data['oc_default_currency'],
|
||||
$data['oc_config_tax'],
|
||||
$data['oc_store_id']
|
||||
@@ -281,6 +282,10 @@ class SettingsSerializerService
|
||||
throw new InvalidArgumentException('store.feature_vouchers must be a boolean');
|
||||
}
|
||||
|
||||
if (isset($data['show_category_products_button']) && ! is_bool($data['show_category_products_button'])) {
|
||||
throw new InvalidArgumentException('store.show_category_products_button must be a boolean');
|
||||
}
|
||||
|
||||
if (! isset($data['oc_default_currency'])) {
|
||||
throw new InvalidArgumentException('store.oc_default_currency is required');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user