-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular renderer for object arrays #1615
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you check whether by extending JsonFormsArrayControl we can get rid of some methods?
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class ArrayLayoutRenderer extends JsonFormsBaseRenderer<ControlElement> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not extend the JsonFormsArrayControl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I changed the renderer so it extends JsonFormsArrayControl
mat-icon-button | ||
[disabled]="readonly" | ||
(click)="add()" | ||
attr.aria-label="{{ 'Add to ' + this.label + 'button' }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will need to find a localization solution
4c26bfe
to
4ddc136
Compare
|
||
getProps(index: number): OwnPropsOfRenderer { | ||
const uischema = | ||
(this.uischema.options?.detailUISchema as UISchemaElement) ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should unify this with the react renderer and use detail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or even better use the findschema like here:
const foundUISchema = findUISchema( |
|
||
export const ArrayLayoutRendererTester: RankedTester = rankWith( | ||
4, | ||
isObjectArray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we check for isObjectArrayWithNesting
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that tester too restrictive? If we don't have a nested array or don't provide a detail schema in the options, then the new renderer won't be used.
uischema: UISchemaElement; | ||
}[]; | ||
|
||
constructor(private jsonFormAngularService: JsonFormsAngularService) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to make this private as we can access it from the parent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If not, it should be accessible via the parent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you. I added a small possible improvement comment, it can be done as a follow up though.
Do you know why neither the buttons nor the toolbar is using the default styling colors of material? |
I did the small refactoring to the array renderer. Regarding the styling:
|
Ah, and the toolbar color is not set to 'primary'. I'll update my commit to use it. |
- use correct button - add Roboto font to Angular Examples - use 'primary' color for toolbar
c85333d
to
06321ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me!
Add array layout renderer for objects.