From baa13260c6fe05f846a8cd52a285e1a7604cd4e7 Mon Sep 17 00:00:00 2001 From: Denozordec Date: Sun, 28 Jun 2026 22:22:21 +0700 Subject: [PATCH] =?UTF-8?q?feat(web,=20db):=20autocomplete=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B5=D0=BA=D1=82=D0=B0=20VPS,=20=D0=B7=D0=B0=D1=89?= =?UTF-8?q?=D0=B8=D1=82=D0=B0=20=D0=BF=D0=BE=D0=BB=D0=B5=D0=B9=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D1=81=D0=B8=D0=BD=D0=BA=D0=B5=20=D0=B8=20=D1=81?= =?UTF-8?q?=D1=82=D0=B8=D0=BB=D1=8C=20Command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Проект выбирается из справочника; ручные правки автоматически попадают в userOverrides без сброса при сохранении. CommandDialog приведён к эталону shadcn/ReUI. Co-authored-by: Cursor --- .../src/components/domain/vps-edit-sheet.tsx | 56 ++++++------------- apps/web/src/components/global-search.tsx | 33 ++++++----- apps/web/src/lib/vps-sync-fields.ts | 1 + apps/web/src/routes/_auth/vps.tsx | 23 +++++++- packages/db/src/repositories/vps.ts | 42 +++++++++++--- packages/ui/src/components/command.tsx | 4 +- 6 files changed, 95 insertions(+), 64 deletions(-) diff --git a/apps/web/src/components/domain/vps-edit-sheet.tsx b/apps/web/src/components/domain/vps-edit-sheet.tsx index f43ed59..a390642 100644 --- a/apps/web/src/components/domain/vps-edit-sheet.tsx +++ b/apps/web/src/components/domain/vps-edit-sheet.tsx @@ -3,10 +3,8 @@ import { FormSheetRhf } from '@/components/form-sheet-rhf' import { FormField } from '@/components/form-field' import { Input } from '@cfdm/ui/components/input' import { SelectField } from '@/components/select-field' -import { AutoCompleteInput } from '@/components/auto-complete-input' +import { AutoCompleteInput, type AutoCompleteOption } from '@/components/auto-complete-input' import { Textarea } from '@cfdm/ui/components/textarea' -import { Checkbox } from '@cfdm/ui/components/checkbox' -import { Label } from '@cfdm/ui/components/label' import { NumberField, NumberFieldGroup, @@ -18,7 +16,7 @@ import { FormDatePicker } from '@/components/form-date-picker' import { vpsSchema, type VpsFormValues } from '@/lib/schemas' import { vpsStatusLabel, tariffTypeLabel } from '@/lib/format' import { buildCityOptions, cityMatchesCountry, resolveCountryForCityFromRows } from '@cfdm/shared/geo' -import { VPS_SYNC_OVERRIDE_FIELDS, parseUserOverrides } from '@/lib/vps-sync-fields' +import { parseUserOverrides } from '@/lib/vps-sync-fields' import { CustomFieldValues } from '@/components/domain/custom-field-values' import { parseCustomData, type CustomFieldDef } from '@/lib/custom-fields' import type { Provider, ProviderAccount, Vps } from '@/types/entities' @@ -82,6 +80,7 @@ interface VpsEditSheetProps { providerAccounts: ProviderAccount[] vpsRows: Vps[] formCountryOptions: Array<{ value: string; label: string }> + projectFormOptions: AutoCompleteOption[] customFieldDefs?: CustomFieldDef[] onSubmit: (values: VpsFormValues) => void submitting?: boolean @@ -96,6 +95,7 @@ export function VpsEditSheet({ providerAccounts, vpsRows, formCountryOptions, + projectFormOptions, customFieldDefs = [], onSubmit, submitting, @@ -116,6 +116,7 @@ export function VpsEditSheet({ const providerId = watch('providerId') const formCountry = watch('country') ?? '' const formCity = watch('city') ?? '' + const formProject = watch('project') ?? '' const formCityOptions = buildCityOptions(vpsRows, formCountry.trim() || undefined) return ( @@ -147,7 +148,16 @@ export function VpsEditSheet({ /> - + setValue('project', v, { shouldDirty: true })} + options={projectFormOptions} + searchPlaceholder="Поиск проекта…" + emptyText="Нет вариантов" + showLeadingInInput={false} + /> { - setValue('country', v) + setValue('country', v, { shouldDirty: true }) if (v.trim() && formCity.trim() && !cityMatchesCountry(formCity, v, vpsRows)) { setValue('city', '') } @@ -171,9 +181,9 @@ export function VpsEditSheet({ placeholder="Любой" value={formCity} onChange={(v) => { - setValue('city', v) + setValue('city', v, { shouldDirty: true }) const country = resolveCountryForCityFromRows(v, vpsRows) - if (country) setValue('country', country) + if (country) setValue('country', country, { shouldDirty: true }) }} options={formCityOptions} searchPlaceholder="Поиск города…" @@ -338,36 +348,6 @@ export function VpsEditSheet({