diff --git a/src/components/admin/ProjectScenes.tsx b/src/components/admin/ProjectScenes.tsx index 143e953..346bc0b 100644 --- a/src/components/admin/ProjectScenes.tsx +++ b/src/components/admin/ProjectScenes.tsx @@ -547,9 +547,26 @@ function PresetsTab({ projectId }: { projectId: string }) { const colorKeys = useMemo(() => colors.map((c) => ({ key: c.element_key, title: c.title })), [colors]); - const startNew = () => setEdit({ name: "", sort: rows.length, items: [] }); + // A preset is a colour setup for ALL shared colours, so a new preset starts + // pre-filled with one placeholder per shared colour (seeded from its default), + // instead of forcing the admin to add each one by hand. + const seedItems = (): PresetItem[] => + colors.map((c, i) => ({ element_key: c.element_key, value: c.default_color || "#000000", sort: i })); + + const startNew = () => setEdit({ name: "", sort: rows.length, items: seedItems() }); const setItems = (items: PresetItem[]) => setEdit((e) => (e ? { ...e, items } : e)); + // Fill placeholders for any shared colours not yet present (for existing presets, + // or after new shared colours were added). + const fillAllColors = () => { + const present = new Set((edit?.items ?? []).map((it) => it.element_key)); + const base = edit?.items ?? []; + const additions = colors + .filter((c) => !present.has(c.element_key)) + .map((c, i) => ({ element_key: c.element_key, value: c.default_color || "#000000", sort: base.length + i })); + if (additions.length) setItems([...base, ...additions]); + }; + const save = async () => { if (!edit) return; setSaving(true); setErr(null); @@ -584,7 +601,12 @@ function PresetsTab({ projectId }: { projectId: string }) {
رنگ‌های پریست - +
+ {colors.length > 0 && (edit.items ?? []).length < colors.length && ( + + )} + +
{(edit.items ?? []).length === 0 ? (

رنگی اضافه نشده.