-
Notifications
You must be signed in to change notification settings - Fork 5
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
how to create a join field? #8
Comments
Exactly this scenario done in the new gantt chart @kevin8181 First, make the array of field names the user can choose the color field from. I start with an array of all the color fields on the associated table: https://github.com/saltcorn/svelte-gantt/blob/c70268d16e0043ec8bf357720cafea732b6a1f95/index.js#L35-L37 then loop through the key fields: https://github.com/saltcorn/svelte-gantt/blob/c70268d16e0043ec8bf357720cafea732b6a1f95/index.js#L38-L39 get the parent table, its fields, and append all color fields to the array of options, a string with a dot separating the key field from the field on the joined table: https://github.com/saltcorn/svelte-gantt/blob/c70268d16e0043ec8bf357720cafea732b6a1f95/index.js#L44-L46 cfg form field as normal: https://github.com/saltcorn/svelte-gantt/blob/c70268d16e0043ec8bf357720cafea732b6a1f95/index.js#L138-L145 in the run method, figure out if it is a join field i.e. has a dot: https://github.com/saltcorn/svelte-gantt/blob/c70268d16e0043ec8bf357720cafea732b6a1f95/index.js#L230 if yes, add a join field to the key in joinFields object is the variable name in the fetched rows, used here https://github.com/saltcorn/svelte-gantt/blob/c70268d16e0043ec8bf357720cafea732b6a1f95/index.js#L238 The use of the color variable here was very idiosyncratic according to the underlying library, hopefully you don't have to create the CSS classes as I do. to retrieve the color you still have to keep track of its name though like this: https://github.com/saltcorn/svelte-gantt/blob/c70268d16e0043ec8bf357720cafea732b6a1f95/index.js#L292-L293 |
for more examples of getJoinedRows and its joinFields argument, see this test file https://github.com/saltcorn/saltcorn/blob/master/packages/saltcorn-data/tests/table.test.ts |
maybe there should be a function for this? like pass a table, array of data types, parent depth, child depth, and get the values back? seems like something used often enough to make a standardized system either way I'll give this a try |
Hello. I agree Full calendar should use the joined fields. I have a table "_actions" with all the informations about a project, like the title ; and a table "_dates" with a join field "action" on _actions (relation type: one action to many dates). I use the view Calendar on the _dates table. I would like the title show on the calendar but the extension only propose the _dates fields for "Event title field". (Sorry for my english). Thanks for your answer. Aurélie |
@glutamate how do I make the color field show options for join fields? like if someone had a table of event types, and each one had a color field, and the events are children of the event types
The text was updated successfully, but these errors were encountered: