fix(settings): merge full system catalog on program settings page
Fill missing can_edit=0 keys client-side so Montzar and other groups show the same fields as khaneghi admin advanced settings before import. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -38,7 +38,7 @@ import {
|
||||
normalizeSettingRow,
|
||||
resolveSettingFieldType,
|
||||
} from '@/config/khanegiSettingCatalog'
|
||||
import { isSuperAdminSystemSettingKey } from '@/config/superAdminSettingKeys'
|
||||
import { isSuperAdminSystemSettingKey, SUPERADMIN_SYSTEM_SETTING_KEYS } from '@/config/superAdminSettingKeys'
|
||||
import type { KhanegiSettingRow } from '@/config/khanegiSettingRow'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
@@ -306,8 +306,28 @@ function errText(e: any) {
|
||||
return Array.isArray(msg) ? msg.join('، ') : msg || 'خطا'
|
||||
}
|
||||
|
||||
function mergeSystemCatalogRows(rows: KhanegiSettingRow[]): KhanegiSettingRow[] {
|
||||
const byKey = new Map(rows.map((row) => [rowKey(row), row]))
|
||||
return [...SUPERADMIN_SYSTEM_SETTING_KEYS]
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
.map((key) => {
|
||||
const found = byKey.get(key)
|
||||
if (found) return normalizeSettingRow(found)
|
||||
return normalizeSettingRow({
|
||||
key,
|
||||
value: '',
|
||||
title_fa: '',
|
||||
description: '',
|
||||
type: '',
|
||||
is_active: 1,
|
||||
can_edit: 0,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function applyItems(raw: unknown[]) {
|
||||
items.value = raw.map((row) => asRow((row || {}) as Record<string, unknown>))
|
||||
const rows = raw.map((row) => asRow((row || {}) as Record<string, unknown>))
|
||||
items.value = mergeSystemCatalogRows(rows)
|
||||
}
|
||||
|
||||
async function load() {
|
||||
|
||||
Reference in New Issue
Block a user