Skip to content
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

feat: fill form by query params #5330

Closed
wants to merge 10 commits into from

Conversation

rallisf1
Copy link
Contributor

@rallisf1 rallisf1 commented Mar 20, 2023

ref: #1371
closes: #2862
Work In Progress

Change Summary

Added Prefill mode select in Form Share View with 4 options:

  • Allow pre-filling fields: parse fields from query params and fields remain editable
  • Disable pre-filling fields: disable parsing fields from query params
  • Lock pre-filled fields as read-only: parse fields from query params and fields become read-only
  • Hide pre-filled fields: parse fields from query params and fields become invisible

Note: My use-case didn't require per field options so the options above work for all the fields in the form

WIP:

  • Also works for "Has Many / Many To Many / Belongs To", probably more virtual fields but it doesn't populate the value list. I'd appreciate someone to step in on this
  • i18n, will do once this is finalized and accepted

How to use

Add &fieldname=value in the query params of the form url. Spaces and special characters work as expected in modern browsers (they handle the URL parsing). Special fields:

  • checkbox=1
  • multiselect=option1,option2...
  • date=2025-01-10 only accepts ISO format
  • duration=18000 must be in milliseconds
  • hasmany=id1|Title1;id2|Title2 | splits id from title and ; splits multiple values

Change type

  • feat: (new feature for the user, not a new feature for build script)
  • fix: (bug fix for the user, not a fix to a build script)
  • docs: (changes to the documentation)
  • style: (formatting, missing semi colons, etc; no production code change)
  • refactor: (refactoring production code, eg. renaming a variable)
  • test: (adding missing tests, refactoring tests; no production code change)
  • chore: (updating grunt tasks etc; no production code change)

Test/ Verification

Provide summary of changes.

Additional information / screenshots (optional)

d450b5dd-1472-4a46-b2fa-48c900aff708

ref: nocodb#1371
ref: 2862
Work In Progress
@pranavxc pranavxc requested a review from wingkwong March 22, 2023 08:49
@wingkwong wingkwong requested a review from dstala March 22, 2023 09:10
@wingkwong wingkwong added the 🛑 Status: Do Not Merge Used in PR only. The PR cannot be merged due to some reasons. label Mar 22, 2023
Copy link
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Prefer the following layout. Since users cannot construct the query param on UI, next to Pre-filled Fields, we may need an indicator / tooltip to show the details (e.g. what are those 4 options / how to construct the query params / what column types are currently supported etc). Ideally it should be a link to the documentation.
    image
  2. So far it looks good. Please proceed to add i18n to en.json
  3. Not working in survey mode
  4. Run npm run lint on nc-gui after all the changes.

packages/nc-gui/lib/types.ts Outdated Show resolved Hide resolved
Copy link
Member

@dstala dstala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • verified except for LinkToAnotherRecord; we can defer pre-filling of links in the first iteration.
  • [to be discussed; low priority] constructing URL is currently manual process. we can evaluate to add Generate pre-filled URL button. One can configure statically pre-filled value fields in form view & generate link. This button can be part of shared view modal.

fix: BelongsTo needs a single object while HasMany & ManyToMany neen an array
fix: read private key and label fields from column meta
it would take quite a refactoring to support pre-filled fields in survey mode, skipping for the initial release
also includes Survey Mode as it was missing
@rallisf1
Copy link
Contributor Author

This is finalized from my end.

To sum up:

  • This doesn't work in Survey mode and it acts like that in the UI and is mentioned in the Docs.
  • [Bug] The Virtual Cells save the pre-filled value (if provided) but don't populate their value list. I have no clue how to fix this.
  • i18n and all changes required have been made.

I want to thank @wingkwong for all his help and of course the rest of you for your inputs.

@wingkwong
Copy link
Member

Please resolve the conflicting files.

@wingkwong
Copy link
Member

Will review again after the next release.

@dstala dstala self-requested a review June 18, 2023 03:35
Copy link
Member

@dstala dstala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like form field for select fields (single select and multi select) is broken after rebase. I tried it out with following configuration, meta db project. Was unable to input select fields from shared form.

Node: v16.14.0
Arch: arm64
Platform: darwin
Docker: false
RootDB: sqlite3
PackageVersion: 0.109.1

I will continue to test this feature further & will capture additional here as and when I find.

@dstala
Copy link
Member

dstala commented Jul 3, 2023

@rallisf1 Can you help rebase this PR to latest develop?

@rallisf1
Copy link
Contributor Author

rallisf1 commented Jul 3, 2023

@rallisf1 Can you help rebase this PR to latest develop?

Kinda swamped this week but I'll try.

@dstala
Copy link
Member

dstala commented Mar 21, 2024

@rallisf1 thanks for this PR. as this was old, we prepared a separate PR based out of your proposal here & merged into develop.

@dstala dstala closed this Mar 21, 2024
@rallisf1
Copy link
Contributor Author

Gee thanks! I never got to updating this as you were refactoring a bit too fast for me to catch up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛑 Status: Do Not Merge Used in PR only. The PR cannot be merged due to some reasons.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Prefill form with default values
4 participants