Skip to content

feat(grid): add select/combo editor types for category products inline edit#157

Open
Ibochkarev wants to merge 2 commits intobetafrom
feat/155-inline-edit-select-combo
Open

feat(grid): add select/combo editor types for category products inline edit#157
Ibochkarev wants to merge 2 commits intobetafrom
feat/155-inline-edit-select-combo

Conversation

@Ibochkarev
Copy link
Copy Markdown
Member

@Ibochkarev Ibochkarev commented Mar 16, 2026

Описание

Добавлена поддержка select и combo для inline-редактирования в таблице товаров категории (closes #155). Базовая реализация расширяет PR #134; поверх первоначального коммита выполнен архитектурный рефакторинг (единый контракт опций, реестр справочников, composable).

Select (статические опции)

  • editor_type: 'select' в конфиге колонки
  • editor_options: [{ label, value }, ...]
  • Один PrimeVue Select с option-value="value" / option-label="label"

Combo (опции из API)

  • editor_type: 'combo'
  • editor_reference — ключ из серверного реестра (например vendors → путь к API)
  • editor_combo_endpoint (опционально) — переопределение URL только если путь в белом списке (префикс /api/mgr/references/)
  • Приоритет: валидный override → иначе URL из реестра по editor_reference. Должен быть задан reference или allowlisted endpoint (валидация при сохранении в GridFieldsConfig и на бэкенде)

API и контракт данных

  • GET .../references/vendors дополняет ответ массивом options: [{ value, label }]; поле vendors сохранено для обратной совместимости
  • Фронт после загрузки везде использует { value, label }[] (toSelectOptionsFromReferencesResponse)

Бэкенд

  • GridEditorReferenceRegistry — whitelist ключ → путь, проверка allowlist для override
  • GridColumnEditorType — константы типов редактора (text, number, select, combo)
  • GridConfigService — сохранение editor_reference, editor_combo_endpoint, очистка combo-полей при смене типа
  • GridConfigController — в ответе конфига для category-products передаётся editor_references для UI

Фронтенд (vueManager)

  • useCategoryProductsInlineEdit — состояние inline-edit, загрузка combo, сохранение
  • utils/gridEditorOptions.js — чистые функции: allowlist URL, резолв URL, маппинг ответа API → опции
  • constants/gridColumnEditorTypes.js — замороженный объект + normalizeGridColumnEditorType / хелперы
  • CategoryProductsGrid — подключение composable, один Select для select+combo
  • GridFieldsConfig — выбор reference, поле override URL, лексиконы ru/en

Тип изменений

  • Новая функциональность (non-breaking: старые конфиги с только editor_combo_endpoint продолжают работать как override)
  • Breaking change
  • Рефакторинг

Связанные Issues

Closes #155

Как протестировано

  • Ручное тестирование
  • ESLint (vueManager)
  • PHPStan (при наличии в CI)

Сценарии:

  • Колонка с editor_type: select и JSON editor_options
  • Combo с editor_reference: vendors без override
  • Combo с allowlisted editor_combo_endpoint
  • Ошибка при пустом combo без reference и без endpoint; toast при ошибке загрузки combo
  • showClear для nullable combo-полей

Чеклист

  • Лексиконы ru и en
  • CHANGELOG.md обновлён
  • Стиль проекта соблюдён

Дополнительно

  • ProductDataService::$allowedUpdateFields по-прежнему должен включать редактируемые поля (например vendor_id, made_in).

@Ibochkarev Ibochkarev marked this pull request as ready for review March 16, 2026 10:41
@Ibochkarev Ibochkarev requested a review from biz87 March 16, 2026 10:41
…e edit

- Add editor_type: select with editor_options for static options (e.g. made_in)
- Add editor_type: combo with editor_combo_endpoint for API-loaded options (e.g. vendor_id)
- Validate editor_combo_endpoint when combo type is selected
- Add showClear for combo Select to allow clearing nullable fields
- Toast notification on combo options load failure
- Lexicons: editor_type_select, editor_type_combo, editor_options, editor_combo_endpoint, editor_combo_endpoint_required, combo_options_load_failed

Refs #155
@Ibochkarev Ibochkarev force-pushed the feat/155-inline-edit-select-combo branch from e54131b to c534194 Compare April 19, 2026 05:05
…ons API

- API: getVendors adds options [{value,label}], keeps vendors for BC
- GridEditorReferenceRegistry + GridColumnEditorType; GridConfigService validation
- GET grid-config: editor_references for category-products
- Vue: useCategoryProductsInlineEdit, gridEditorOptions, gridColumnEditorTypes
- GridFieldsConfig: editor_reference + allowlisted override URL; lexicons ru/en
- CHANGELOG

Refs #155
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: inline edit — select/combo editor type for category products grid

1 participant