Advanced usage of VueDataUI #226
tjones-ieee
started this conversation in
Show and tell
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone,
I wanted to create a discussion thread for some advanced usage of VueDataUI. My company has committed to using this amazing project, and like any third-party library, it comes with some challenges. I won't go into the specifics of why the content of this discussion is being created, but you may surmise the reason(s).
Note: my company is not IEEE.
Everything I provide will at a minimum require Vuetify and TypeScript. It's the core component library we use, so some refactoring may be required.
Binding to VueDataUI Configurations
The first challenge we faced was creating the ability to bind to any property within a default configuration. Alec's brilliant foresight of this is demonstrated by the existence of the
getVueDataUiConfig
function. With this, most (if not all - we haven't got that far yet) component configurations have a default configuration object - importantly, it's not just an interface or a type, it's a real object.This enables you to have a full object by default and make it reactive.
However, as amazing as it is to have a default object, in TypeScript it will respect the type definition - meaning every property is optional. This creates an impossibility to maintaining a typed object while being able to use Vue binding to components or even setting the value of a deeply nested property within TypeScript. In other words, the below is not possible without either having lots of error messages or Vue component binding warnings (or potentially even breaking your App):
Fix: Binding to VueDataUI Configurations
At first, we figured a good approach would be to wrap all properties within a separate ComputedRef getter/setter, that way we could safely mutate any property within the VueDataUI Configuration. However, this presents two issues: first is manually creating every single property (e.g., there are over 100 in vue-ui-xy), and second is the flattening of the object model. Neither are ideal. Instead, we've come up with a way (with a little assistance to ChatGPT, full disclosure) to use a generic binding composable.
This does two things: first is it maintains the object structure of the VueDataUI configuration, and secondly it maintains the "depth" when setting property values. For example:
Solution
Usage
Mutation within TypeScript
Mutation by components
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions