feat(extra-fields): add ms3-key-value field type#323
Open
Ibochkarev wants to merge 4 commits into
Open
Conversation
Introduce configurable key-value extra fields with fixed and free modes, backend validation via KeyValueFieldService, and Vue editor components for manager forms and extra field definitions. Closes modx-pro#300
Align Vue defaults and product/order hydration with the repeater pattern, stabilize free-mode editing, add KeyValueFieldService smoke tests, and document the type in the package changelog.
Changelog notes for ms3-key-value belong at release time, not in this PR.
Surface prepareObject validation errors with lexicon messages, warn on duplicate free-mode keys, document strip-first unknown-key handling, and harden numeric casting / config encoding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
Тип extra field
ms3-key-value: плоский JSON-объект (ключ → значение) с конфигом в колонкеkey_value_config.Режимы:
Backend:
KeyValueFieldService(decode → normalize → validate, strip-first для unknown keys), Phinx-миграция,ServiceRegistry,ExtraFieldsService,ProductDataService(whitelist, обходprepareOptionValues, lexicon-ошибки вprepareObject), нормализация extra fields вOrdersController.Frontend:
KeyValueField,KeyValueSchemaEditor,structuredExtraField.js,DynamicField,ExtraFieldsManager,ProductDataFields,OrderView,OrderExtraFieldsSection.Тип изменений
Связанные Issues
Closes #300
Как это было протестировано?
Конфигурация тестирования:
feat/300-key-value-extra-fieldотbetaПроверки (exit 0):
php -l—KeyValueFieldService.php, миграция,ExtraFieldsService.php,ProductDataService.php,OrdersController.php,ServiceRegistry.php,msExtraField.php,KeyValueFieldServiceTest.phpphp core/components/minishop3/tests/KeyValueFieldServiceTest.php→OKnpx eslint—KeyValueField.vue,KeyValueSchemaEditor.vue,keyValueField.js,structuredExtraField.js,DynamicField.vue,ExtraFieldsManager.vue,ProductDataFields.vue,OrderView.vue,OrderExtraFieldsSection.vuePHPStan и полный прогон на MODX не выполнялись.
Скриншоты (если применимо)
Не приложены. Визуальная проверка форм менеджера локально.
Чеклист
Дополнительные заметки
Паттерн как у
ms3-repeater(#301). CHANGELOG /docs/changelog.txtне трогали — записи при релизе.Доработки после review:
mode: fixedсогласован PHP/JScol-12в product data / заказахInputNumberдля schemanumberprepareObjectпробрасывает lexicon-ошибку валидацииKeyValueFieldServiceTest.phpencodeConfig/ numeric cast (1e3→1000)Вне MVP #300: PHP dispatcher для structured xtypes; валидация на Web checkout; CSV-импорт; клиентская валидация до save; docs.modx.pro; подключение smoke-теста к CI (в репо пока нет такого workflow).