-
Notifications
You must be signed in to change notification settings - Fork 34
RuleSlot exact rule identification #81
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
Comments
Hi @DJManuel and thank you very much for your feedback. One thing I can't follow is this statement:
How, would the component's identifier help you in the RuleSlot context to avoid having several components of the same type? Pertaining the problem you're trying to solve:
You may want to check #47 which seem to be related. I think my suggestion with a concrete code sample should help - it basically extends a dropdown component. Is that what you're looking for? |
Thank you for your quick resonse,
The reason for this is to clearly identify the exact rule based on its identifier (that is unique) instead of the component name (that is the same for multiple components with different data). The reason for the exact identification of the rule is due to having an additional element in the rule where data is stored that is needed within the dropdown component. I have created a codesanbox here. In the example, the 3 rules in the query should be The main difference between this sandbox example and the implementation I am doing is that instead of passing the data directly through the "dbdata" element / props, I would only pass an arguments for a vuex getter call to get the correct data for the specific dropdown. Thank you! |
Have you looked at this code sandbox sample I referred you to in the linked thread above? The only difference is that you have to declare some logic from where the data shall be passed onto your component. In this sample, I demonstrate it with individual AJAX requests via axios upon the component's mount event. Note that the That said, all you'd want to do is to pass a slightly different for logic for...
If it doesn't solve your problem, please let me know why 😉 |
Yes, I have had a look at it but there are a few issues that I found with this implementation. Also, I have tried to implement it and it didn't work as expected. I have created a PR #83 for this change to be implemented. Thank you! |
Hey there, thanks for the great work. I have the exact same issue, and although your "extend" trick can do the job, I think it would make more sense to have the option to directly pass props to the components. Maybe something like that:
Having the identifier also works but then again it required additional work. What do you guys think? I'm happy to collaborate on this |
Hi, first of all thank you for such a great library!
I am facing an issue where I have multiple rules using the same component.
I noticed this behavior when trying to get data into the (custom) component of a (custom / scoped) RuleSlot. Within this component, I have a drop-down that eventually will fetch data from a DB / API. In the end there will be ~30 rules that have a dropdown selection, and in my opinion it is not worth creating 30 custom (pretty much duplicate) dropdown components. Therefor I am trying to use a single component in multiple rules, with different data fetched in the dropdown.
One of the main issue is the identification of the exact rule based on the data that is being forwarded into the RuleSlot:
src/QueryBuilderRule.vue#L81 and src/QueryBuilderRule.vue#L42
Only with this information currently provided, the exact rule can only be found out by matching the
ruleComponent
(andruleData
, dependend ifinitialValue
is different):however, as I have multiple rules that have the same component, this won't work (it only give back the first element in the rules array it finds).
To fix this behavior, the
identifier
from the rules would be needed inside the RuleSlot.Basically in the
get ruleSlotProps
(src/QueryBuilderRule.vue#L42) adding one item to the object being forwarded to the RuleSlot:When this
ruleIdentifier
is available in the RuleSlot the ruleName (and exact rule) can be found:Thank you!
The text was updated successfully, but these errors were encountered: