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: add extra_params option #36

Merged
merged 11 commits into from
Feb 1, 2024
Merged

feat: add extra_params option #36

merged 11 commits into from
Feb 1, 2024

Conversation

michaelroudnitski
Copy link
Member

@michaelroudnitski michaelroudnitski commented Feb 1, 2024

  • needed an easier way to supply and retain additional params
    • e.g. when an author workbench user is in a tab, we may rely on a query param to be present in the request (?tab=my_organizations) to ensure the tab does not change unexpectedly when the user searches something

Solution

add a new named parameter to SnFilterable::MainComponent. extra_params: { tab: "my_organizations" } will add a hidden form input with name tab and value my_organizations

@michaelroudnitski michaelroudnitski requested a review from a team as a code owner February 1, 2024 22:56
@@ -24,14 +24,16 @@ class MainComponent < ViewComponent::Base
# @param [String, nil] search_filter_name Optional, enable's and set's the search filter, specified by the filter's parameter name
# @param [Boolean] show_sidebar If true, will show the sidebar with the filters.
# @param [Boolean] update_url_on_submit If true, will update the URL in the user's browser on form submission.
def initialize(frame_id:, filtered:, filters:, url: nil, search_filter_name: nil, show_sidebar: true, update_url_on_submit: true)
# @param [Hash] extra_params Optional, allows for custom form values to be supplied. Useful if you need to retain non-filterable query params
Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't sure on a great name for this variable, let me know if you have any suggestions

Copy link
Contributor

Choose a reason for hiding this comment

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

i think the name is fine, I guess we could maybe do hidden_params to convey that it will generate hidden inputs.

@@ -24,14 +24,16 @@ class MainComponent < ViewComponent::Base
# @param [String, nil] search_filter_name Optional, enable's and set's the search filter, specified by the filter's parameter name
# @param [Boolean] show_sidebar If true, will show the sidebar with the filters.
# @param [Boolean] update_url_on_submit If true, will update the URL in the user's browser on form submission.
def initialize(frame_id:, filtered:, filters:, url: nil, search_filter_name: nil, show_sidebar: true, update_url_on_submit: true)
# @param [Hash] extra_params Optional, allows for custom form values to be supplied. Useful if you need to retain non-filterable query params
Copy link
Contributor

Choose a reason for hiding this comment

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

i think the name is fine, I guess we could maybe do hidden_params to convey that it will generate hidden inputs.

@michaelroudnitski michaelroudnitski merged commit 9b937c4 into main Feb 1, 2024
3 checks passed
@michaelroudnitski michaelroudnitski deleted the add-extra-params branch February 1, 2024 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants