Repository navigation
feat(core): disabledWhen and readOnlyWhen, the rules as data - #134
Merged
Merged
Conversation
Like appearWhen: a field list that locks fields can be stored as JSON.
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.
A field takes
disabledWhenandreadOnlyWhen:disabledConditionandreadOnlyConditionwritten as data, in the same shape as
appearWhen/requiredWhen(
{ field: 'status', equals: 'closed' },in,truthy,empty,root: true,all/any/not). A field list that locks fields can then be stored as JSON or sentfrom a server.
disabled: truestill disables; a function wins over the rule when both are set(as with
appearConditionoverappearWhen).the data rule).
resolveDisabled/resolveReadOnlyread the rules, so every renderer getsdisabled/readOnly.disabledWhenitself withevaluateCondition(in core since 1.12.0), keeping the rule that an adapter only calls APIs of the oldest
core in its peer range (
^1.12.0).fieldsToJsonSchemawarns about both and leaves them out (JSON Schema cannot makereadOnlydepend on a value).Tests: core resolve tests (data rule,
root: true, flag still wins, function wins) andthe export warnings; a
disabledWhensection test in React, Vue, Svelte and Angular. Theyfailed before the change. All packages pass (core 395, react 210, vue 210, svelte 122,
angular 190), core type tests clean, eslint and prettier clean.