feat: website settings menu gated by has_landing
Add تنظیمات وبسایت before پیکربندی with landing_* subsections, and show unit addon on numeric setting fields. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="h-full min-h-0">
|
||||
<BasicShowContent :title="pageTitle" :help="configurationPageIntro" class="h-full">
|
||||
<BasicShowContent :title="pageTitle" :help="pageHelp" class="h-full">
|
||||
<div class="settings-toolbar">
|
||||
<a-input
|
||||
v-model:value="search"
|
||||
@@ -207,10 +207,10 @@ import { loading } from '@/utils'
|
||||
import { getEditableConfiguration, getSystemConfiguration, setConfiguration, setSystemConfiguration, refreshSuperAdminSettings } from '@/api/configuration'
|
||||
import SettingValueField from './SettingValueField.vue'
|
||||
import SettingCard from './SettingCard.vue'
|
||||
import { configurationPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { configurationPageIntro, websiteSettingsPageIntro } from '@/utils/adminHelpCopy'
|
||||
import { refreshAppModeMenu } from '@/router'
|
||||
import { useUserStore } from '@/store/userStore'
|
||||
import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyAutomationEnabledFromRows, applyProductFundsEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applyPriceChannelAccessFromRows, applySupportChatMenuEnabledFromRows, applyGroupSmsFromRows, applyCustomerSpecialPricingFromRows, applyGoldCreditEnabledFromRows, applyCustomerDirectSmsFromRows, applyCustomerLevelProfitEnabledFromRows, applySuperAdminAccessFlagsFromItems, invalidateSettingsBootstrap, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setAutomationEnabledFromSettings, setProductFundsEnabledFromSettings, setPriceTriggerEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setPriceChannelAccessFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings, setGroupSmsEnabledFromSettings, setCustomerSpecialPricingEnabledFromSettings, setGoldCreditEnabledFromSettings } from '@/utils/config'
|
||||
import { applyBannerEnabledFromRows, applyTrackingSystemsEnabledFromRows, applyConditionalOrderEnabledFromRows, applyAutomationEnabledFromRows, applyProductFundsEnabledFromRows, applyPriceTriggerEnabledFromRows, applyAppNotificationEnabledFromRows, applyPriceProviderFromRows, applyPriceChannelAccessFromRows, applySupportChatMenuEnabledFromRows, applyGroupSmsFromRows, applyCustomerSpecialPricingFromRows, applyGoldCreditEnabledFromRows, applyCustomerDirectSmsFromRows, applyCustomerLevelProfitEnabledFromRows, applySuperAdminAccessFlagsFromItems, invalidateSettingsBootstrap, setBannerEnabledFromSettings, setConditionalOrderEnabledFromSettings, setAutomationEnabledFromSettings, setProductFundsEnabledFromSettings, setPriceTriggerEnabledFromSettings, setAppNotificationEnabledFromSettings, setPriceProviderFromSettings, setPriceChannelAccessFromSettings, setStoreModeFromSettings, setTrackingSystemsEnabledFromSettings, setGroupSmsEnabledFromSettings, setCustomerSpecialPricingEnabledFromSettings, setGoldCreditEnabledFromSettings, applyHasLandingFromRows, setHasLandingFromSettings } from '@/utils/config'
|
||||
import {
|
||||
EDITABLE_SETTING_GROUPS,
|
||||
SYSTEM_SETTING_GROUPS,
|
||||
@@ -218,6 +218,12 @@ import {
|
||||
OTHER_PAGE_SETTING_MENUS,
|
||||
type SettingGroupDef
|
||||
} from './settingGroups'
|
||||
import {
|
||||
LANDING_SETTING_GROUPS,
|
||||
isLandingContentKey,
|
||||
landingSectionByPrefix,
|
||||
matchesLandingPrefix
|
||||
} from './landingSettings'
|
||||
import {
|
||||
SETTING_TYPE_OPTIONS,
|
||||
formatValueForSave,
|
||||
@@ -233,8 +239,9 @@ import {
|
||||
} from './settingTypes'
|
||||
import { TRADING_HOURS_SETTING_KEY_SET } from './tradingHoursKeys'
|
||||
|
||||
const props = withDefaults(defineProps<{ mode?: 'editable' | 'system' }>(), {
|
||||
mode: 'editable'
|
||||
const props = withDefaults(defineProps<{ mode?: 'editable' | 'system' | 'landing'; landingPrefix?: string }>(), {
|
||||
mode: 'editable',
|
||||
landingPrefix: ''
|
||||
})
|
||||
|
||||
const userStore = useUserStore()
|
||||
@@ -243,11 +250,24 @@ function refreshMenuAfterStoreChange() {
|
||||
}
|
||||
|
||||
const isSystemMode = computed(() => props.mode === 'system')
|
||||
const pageTitle = computed(() => (isSystemMode.value ? 'تنظیمات پیشرفته' : 'تنظیمات'))
|
||||
const isLandingMode = computed(() => props.mode === 'landing')
|
||||
const pageTitle = computed(() => {
|
||||
if (isLandingMode.value) {
|
||||
return landingSectionByPrefix(props.landingPrefix)?.title ?? 'تنظیمات وبسایت'
|
||||
}
|
||||
return isSystemMode.value ? 'تنظیمات پیشرفته' : 'تنظیمات'
|
||||
})
|
||||
const pageHelp = computed(() => (isLandingMode.value ? websiteSettingsPageIntro : configurationPageIntro))
|
||||
const refreshingSuperAdmin = ref(false)
|
||||
const settingGroups = computed(() =>
|
||||
isSystemMode.value ? SYSTEM_SETTING_GROUPS : EDITABLE_SETTING_GROUPS
|
||||
)
|
||||
const settingGroups = computed(() => {
|
||||
if (isLandingMode.value) {
|
||||
const prefix = props.landingPrefix || ''
|
||||
return prefix
|
||||
? LANDING_SETTING_GROUPS.filter((g) => g.id === prefix)
|
||||
: LANDING_SETTING_GROUPS
|
||||
}
|
||||
return isSystemMode.value ? SYSTEM_SETTING_GROUPS : EDITABLE_SETTING_GROUPS
|
||||
})
|
||||
|
||||
const settingTypeOptions = SETTING_TYPE_OPTIONS
|
||||
|
||||
@@ -327,6 +347,13 @@ const filteredRows = computed(() =>
|
||||
(baseData.value || []).filter((row) => {
|
||||
if (row.id == null || !matchesFilter(row)) return false
|
||||
if (!isSettingVisible(row.key)) return false
|
||||
if (isLandingMode.value) {
|
||||
if (!isEditable(row)) return false
|
||||
const prefix = props.landingPrefix || ''
|
||||
if (prefix) return matchesLandingPrefix(row.key || '', prefix)
|
||||
return isLandingContentKey(row.key)
|
||||
}
|
||||
if (isLandingContentKey(row.key)) return false
|
||||
const menu = String(row.menu ?? '').trim()
|
||||
if (OTHER_PAGE_SETTING_MENUS.has(menu)) return false
|
||||
if (!menu && !isSystemMode.value && TRADING_HOURS_SETTING_KEY_SET.has(row.key || '')) {
|
||||
@@ -486,7 +513,7 @@ onMounted(() => {
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.mode,
|
||||
() => [props.mode, props.landingPrefix],
|
||||
() => {
|
||||
search.value = ''
|
||||
filterType.value = undefined
|
||||
@@ -608,6 +635,7 @@ async function initConfig() {
|
||||
applyPriceProviderFromRows(baseData.value)
|
||||
applyPriceChannelAccessFromRows(baseData.value)
|
||||
applySupportChatMenuEnabledFromRows(baseData.value)
|
||||
applyHasLandingFromRows(baseData.value)
|
||||
applyGroupSmsFromRows(baseData.value)
|
||||
applyCustomerSpecialPricingFromRows(baseData.value)
|
||||
applyGoldCreditEnabledFromRows(baseData.value)
|
||||
@@ -616,6 +644,7 @@ async function initConfig() {
|
||||
!isSystemMode.value ||
|
||||
!baseData.value.some((row) => row.key === 'price_provider') ||
|
||||
!baseData.value.some((row) => row.key === 'show_to_users_chat') ||
|
||||
!baseData.value.some((row) => row.key === 'has_landing') ||
|
||||
!baseData.value.some((row) => row.key === 'price_channel_access') ||
|
||||
!baseData.value.some((row) => row.key === 'group_sms') ||
|
||||
!baseData.value.some((row) => row.key === 'customer_special_pricing') ||
|
||||
@@ -627,6 +656,7 @@ async function initConfig() {
|
||||
const rows = Array.isArray(all) ? all : []
|
||||
applyPriceProviderFromRows(rows)
|
||||
applySupportChatMenuEnabledFromRows(rows)
|
||||
applyHasLandingFromRows(rows)
|
||||
applyPriceChannelAccessFromRows(rows)
|
||||
applyGroupSmsFromRows(rows)
|
||||
applyCustomerSpecialPricingFromRows(rows)
|
||||
@@ -701,6 +731,14 @@ function syncMenuFlagsFromSetting(key: string | undefined, value: string) {
|
||||
if (row) row.value = value
|
||||
}
|
||||
}
|
||||
if (key === 'has_landing') {
|
||||
setHasLandingFromSettings(isSwitchOn(value))
|
||||
const list = userStore.userInfo?.settings
|
||||
if (Array.isArray(list)) {
|
||||
const row = list.find((s: any) => s?.key === key)
|
||||
if (row) row.value = value
|
||||
}
|
||||
}
|
||||
if (key === 'price_channel_access') {
|
||||
setPriceChannelAccessFromSettings(isSwitchOn(value))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user