Open ribrewguy opened 3 months ago
Hi @ribrewguy
I think the problem is that you're defining the JSON Forms renderer entry correctly, but not passing a specific rank to it. I think this means that when your tester matches, you'll get a return value of 1 (I'm assuming this is the default), and therefore your custom renderer entry won't take precedence over the off-the-shelf renderers, unless you remove them as demonstrated above.
What I normally do is use the rankWith
helper to pass a specific value to a matching entry, for example (from the stock EnumControlRenderer.vue)
export const entry: JsonFormsRendererRegistryEntry = {
renderer: controlRenderer,
tester: rankWith(2, isEnumControl),
};
You can find the rank
value of the off-the-shelf renderer you want to override and make sure your custom renderer returns higher than that, or an arbitrarily high value if you 'always' want it to win.
Or, if you want to make sure that a specific tester always ranks higher than a specific other tester (I use this to override off-the-shelf renderers) you can use the withIncreasedRank
helper
export const StringControlRendererEntry = {
renderer: StringControlRenderer,
tester: withIncreasedRank(1, UpstreamStringControlRendererEntry.tester),
};
NB the off-the-shelf renderer testers aren't currently exported from the released version of @jsonforms/vue-vueitfy, so I've released a version of my fork that does that, and I have a (build failing around the example app - needs work - contributions welcome!) PR to add them https://github.com/eclipsesource/jsonforms-vuetify-renderers/pull/110.
It would be very helpful to understand how to create a custom Vuetify renderer that properly handles custom types. I am trying to create a renderer for a complex object in my application that I typically use with a compound component I wrote for the case. The primary issues I've been facing are below. Any ideas or help would be greatly appreciated as this is currently a blocker for moving forward with this library.
tester: scopeEndsWith('amount')
directly didn't work until I removed the vuetify renderers. Note that the income.amount scope certainly ends in "amount".[Vue warn]: Invalid prop: type check failed for prop "id". Expected String with value "undefined", got Undefined at <ControlWrapper id=undefined description=undefined errors="" ... > at <MonetaryAmountControlRenderer renderers= Array [ {…} ] cells= Array [] schema=
I have a test bed (test.vue) configured as such:
You'll note that the
amount
property is a complex object. I have developed a MonetaryAmountField.vue that accepts the amount complex object via the v-model strategy and handles it appropriately. That is well tested at this point.The json schema for an salaryFormDataSchema that gets passed to the
schema
attribute evaluates to:The value for salaryFormUiSchema evaluates to
I attempted to reverse engineer one of the existing renderers and so have wrapped my custom MonetaryAmountField in the ControlWrapper as follows:
For completeness, here is the
MonetaryAmountField
file: