From 2b134940f0ec468cbe1195784c0dc5706c5a2a72 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Thu, 9 Apr 2026 17:27:25 +0700 Subject: [PATCH] Simplify catalog option controls --- app/pages/catalog-settings.vue | 62 +++++++++++++--------------------- 1 file changed, 24 insertions(+), 38 deletions(-) diff --git a/app/pages/catalog-settings.vue b/app/pages/catalog-settings.vue index be9f253..556b31d 100644 --- a/app/pages/catalog-settings.vue +++ b/app/pages/catalog-settings.vue @@ -34,7 +34,6 @@ type CatalogSettingForm = { sleeveOptions: string[]; colorOptions: string[]; labelOptions: string[]; - drafts: Record; }; type OptionGroupDefinition = { key: OptionKey; @@ -72,17 +71,6 @@ function toInputValue(value: number | null | undefined) { return value == null ? '' : String(value); } -function createDrafts(): Record { - return { - widthOptionsMm: '', - lengthOptionsM: '', - thicknessOptionsMicron: '', - sleeveOptions: '', - colorOptions: '', - labelOptions: '', - }; -} - function parseOptionalInteger(value: string) { const normalized = value.trim(); if (!normalized) { @@ -135,7 +123,6 @@ function createForm(item: CatalogSettingItem): CatalogSettingForm { sleeveOptions: normalizeOptionList(item.sleeveOptions, 'text'), colorOptions: normalizeOptionList(item.colorOptions, 'text'), labelOptions: normalizeOptionList(item.labelOptions, 'text'), - drafts: createDrafts(), }; } @@ -144,20 +131,28 @@ function formFor(item: CatalogSettingItem) { return forms[item.productType]; } -function addOption(form: CatalogSettingForm, group: OptionGroupDefinition) { - const value = normalizeOptionEntry(form.drafts[group.key], group.kind); +function addOption(form: CatalogSettingForm, group: OptionGroupDefinition, rawValue: string) { + const value = normalizeOptionEntry(rawValue, group.kind); if (!value) { return; } form[group.key] = normalizeOptionList([...form[group.key], value], group.kind); - form.drafts[group.key] = ''; } function removeOption(form: CatalogSettingForm, groupKey: OptionKey, value: string) { form[groupKey] = form[groupKey].filter((item) => item !== value); } +function openAddOptionPrompt(form: CatalogSettingForm, group: OptionGroupDefinition) { + const value = window.prompt(group.placeholder, ''); + if (value == null) { + return; + } + + addOption(form, group, value); +} + function optionChipLabel(value: string, group: OptionGroupDefinition) { return group.suffix ? `${value} ${group.suffix}` : value; } @@ -311,21 +306,30 @@ async function saveAllSettings() {
-
{{ group.label }}
+
+
{{ group.label }}
+ +
-
- - -