-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Schema paths containing 'then' or 'else' were not transformed correctly to their data paths. This is now fixed. The JSON Forms resolver already allowed to omit 'oneOf', 'allOf' and 'anyOf' within UI Schema scopes. The resolver will now do the same for 'then' and 'else' segments. For this the resolving algorithm was rewritten to a depth first search. First trying to resolve the paths as they were handed over and, if not successful, checking for omitted segments. Co-authored-by: Stefan Dirix <[email protected]>
- Loading branch information
Showing
6 changed files
with
251 additions
and
45 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
118 changes: 118 additions & 0 deletions
118
packages/examples/src/examples/conditional-schema-compositions.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
The MIT License | ||
Copyright (c) 2017-2019 EclipseSource Munich | ||
https://github.com/eclipsesource/jsonforms | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
*/ | ||
import { registerExamples } from '../register'; | ||
|
||
export const schema = { | ||
type: 'object', | ||
properties: { | ||
name: { | ||
type: 'string', | ||
minLength: 1, | ||
description: 'The task\'s name', | ||
}, | ||
recurrence: { | ||
type: 'string', | ||
enum: ['Never', 'Daily', 'Weekly', 'Monthly'], | ||
}, | ||
}, | ||
anyOf: [ | ||
{ | ||
if: { | ||
properties: { | ||
recurrence: { | ||
const: 'Never' | ||
} | ||
} | ||
}, | ||
then: { | ||
properties: { | ||
lastname: { | ||
type: 'string' | ||
}, | ||
age: { | ||
type: 'number' | ||
} | ||
} | ||
} | ||
}, | ||
] | ||
}; | ||
|
||
export const uischema = { | ||
type: 'HorizontalLayout', | ||
elements: [ | ||
{ | ||
type: 'VerticalLayout', | ||
elements: [ | ||
{ | ||
type: 'Control', | ||
scope: '#/properties/name', | ||
}, | ||
{ | ||
type: 'Control', | ||
scope: '#/properties/recurrence', | ||
}, | ||
{ | ||
type: 'Control', | ||
scope: '#/anyOf/0/then/properties/lastname', | ||
rule: { | ||
effect: 'SHOW', | ||
condition: { | ||
scope: '#/properties/recurrence', | ||
schema: { | ||
const: 'Never' | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
type: 'Control', | ||
scope: '#/properties/age', | ||
rule: { | ||
effect: 'SHOW', | ||
condition: { | ||
scope: '#/properties/recurrence', | ||
schema: { | ||
const: 'Never' | ||
} | ||
} | ||
} | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
const data = {}; | ||
|
||
registerExamples([ | ||
{ | ||
name: 'conditional-schema-compositions', | ||
label: 'Conditional Schema Compositions', | ||
data, | ||
schema, | ||
uischema | ||
} | ||
]); |
This file contains 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