Skip to content

Commit

Permalink
editor: add ordered property for definitions
Browse files Browse the repository at this point in the history
* Adds ordered properties for JSONSchema definitions.
* Fixes ordered properties for JSONSchema oneOf, anyOf.
* Sets horizontal labels only for the long mode editor.

Co-Authored-by: Johnny Mariéthoz <Johnny.Mariethoz@rero.ch>
  • Loading branch information
jma committed Jul 23, 2020
1 parent 7cec461 commit 40a3385
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export class EditorComponent implements OnInit, OnChanges, OnDestroy {
}

// Add an horizontal wrapper
if (this._horizontalWrapperTypes.some(elem => elem === field.type)) {
if (this.longMode && this._horizontalWrapperTypes.some(elem => elem === field.type)) {
field.wrappers = [
...(field.wrappers ? field.wrappers : []),
'form-field-horizontal'
Expand Down
18 changes: 12 additions & 6 deletions projects/rero/ng-core/src/lib/record/editor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,22 @@ export function orderedJsonSchema(schema: any) {
orderedJsonSchema(item);
}
}
// recursion for anyOf
// recursion for anyOf
if (schema.anyOf) {
for (const item of schema.oneOf) {
orderedJsonSchema(schema.anyOf);
for (const item of schema.anyOf) {
orderedJsonSchema(item);
}
}
// recursion for allOf
if (schema.allOf) {
for (const item of schema.oneOf) {
orderedJsonSchema(schema.allOf);
for (const item of schema.allOf) {
orderedJsonSchema(item);
}
}
// recursion for definitions
if (schema.definitions) {
for (const property of Object.keys(schema.definitions)) {
orderedJsonSchema(schema.definitions[property]);
}
}
return schema;
Expand Down Expand Up @@ -87,7 +93,7 @@ export function resolveRefs(data: any) {
for (const key of Object.keys(data)) {
const value = resolveRefs(data[key]);
if (key === '$ref') {
newObject.pid = extractIdOnRef(value);
newObject.pid = extractIdOnRef(value);
} else {
newObject[key] = value;
}
Expand Down

0 comments on commit 40a3385

Please sign in to comment.