diff --git a/apps/admin-panel/src/components/common/CityTreeSelect.vue b/apps/admin-panel/src/components/common/CityTreeSelect.vue index 0792021..0a5775e 100644 --- a/apps/admin-panel/src/components/common/CityTreeSelect.vue +++ b/apps/admin-panel/src/components/common/CityTreeSelect.vue @@ -2,19 +2,21 @@ - (); -const treeData = computed(() => { +const tree = computed(() => { const ids = new Set(props.cities.map((c) => c.id)); const kids = new Map(); for (const c of props.cities) { @@ -60,18 +73,37 @@ const treeData = computed(() => { kids.get(p)!.push(c); } const seen = new Set(); - const build = (parent: string | null, depth: number): Node[] => + const build = (parent: string | null): Node[] => (kids.get(parent) ?? []) .filter((c) => !seen.has(c.id) && !(props.parentPicker && c.id === props.excludeId)) .map((c) => { seen.add(c.id); - const children = build(c.id, depth + 1); - const node: Node = { value: c.id, key: c.id, title: c.title }; - if (children.length) node.children = children; - if (!props.parentPicker && depth === 0 && children.length) node.disabled = true; - return node; + return { id: c.id, title: c.title, children: build(c.id) }; }); - return build(null, 0); + return build(null); +}); + +const SEP = ' › '; + +/** Every row under `nodes`, depth-first, labelled with its path from there. */ +function flatten(nodes: Node[], prefix: string[], groupTitle = ''): Option[] { + return nodes.flatMap((n) => { + const path = [...prefix, n.title]; + const label = path.join(SEP); + return [ + { value: n.id, label, search: groupTitle ? `${groupTitle}${SEP}${label}` : label }, + ...flatten(n.children, path, groupTitle), + ]; + }); +} + +const options = computed<(Option | Group)[]>(() => { + if (props.parentPicker) return flatten(tree.value, []); + return tree.value.map((top) => + top.children.length + ? { key: top.id, label: top.title, options: flatten(top.children, [], top.title) } + : { value: top.id, label: top.title, search: top.title }, + ); }); function onChange(v: string | undefined) { diff --git a/apps/admin-panel/src/views/Dashboard.vue b/apps/admin-panel/src/views/Dashboard.vue index e776225..8217c7b 100644 --- a/apps/admin-panel/src/views/Dashboard.vue +++ b/apps/admin-panel/src/views/Dashboard.vue @@ -75,7 +75,7 @@ -
+
@@ -708,6 +708,9 @@ b { .row--half { grid-template-columns: repeat(2, minmax(0, 1fr)); } +.row--single { + grid-template-columns: minmax(0, 1fr); +} /* ── KPI cards ── */ .kpi-grid { diff --git a/apps/admin-panel/src/views/apps/product/AddProduct.vue b/apps/admin-panel/src/views/apps/product/AddProduct.vue index b5242b3..268e7a6 100644 --- a/apps/admin-panel/src/views/apps/product/AddProduct.vue +++ b/apps/admin-panel/src/views/apps/product/AddProduct.vue @@ -77,12 +77,17 @@ -
- + +
+ - + سایت گوشی @@ -91,7 +96,7 @@
- +

گالری تصاویر

-

تصاویر جداگانه برای نمایش در سایت و اپلیکیشن موبایل

+

{{ users.isSuperAdmin ? 'تصاویر جداگانه برای نمایش در سایت و اپلیکیشن موبایل' : 'تصاویر نمایش در اپلیکیشن موبایل' }}

- - - +
- + @@ -383,7 +390,7 @@
-

تصویر بارگذاری‌شده به گالری سایت محصول هم اضافه می‌شود.

+

تصویر بارگذاری‌شده به گالری سایت محصول هم اضافه می‌شود.