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

Form structure changed with path_selector widget #3845

Closed
fordste5 opened this issue Oct 4, 2024 · 5 comments
Closed

Form structure changed with path_selector widget #3845

fordste5 opened this issue Oct 4, 2024 · 5 comments
Milestone

Comments

@fordste5
Copy link

fordste5 commented Oct 4, 2024

We recently updated our OnDemand installation to 3.1.7 and are now in the process of updating all of our interactive apps to use path_selector instead of data-filepicker.

We have applications that provide dynamic forms with logic in form.js to hide/unhide fields. The javascript is straightforward:

/**
 * Hide an option by form_id
 *
 */
function hide_option(form_id) {
  let form_element = $(form_id);
  let parent = form_element.parent();
  parent.hide();
}

/**
 * Show an option by form_id
 *
 */
function show_option(form_id) {
  let form_element = $(form_id);
  let parent = form_element.parent();
  parent.show();
}

This works fine for data-filepicker, but with the new path_selector widget it doesn't hide the "Select Path" button, only the text field and help text.

Examining the HTML, it looks like other fields are wrapped in a single div, while the path_selector widget has a div for the text field and help text inside another div that also includes the "Select Path" button.

We could add some extra logic to form.js to jump up one more parent for these particular fields, but I think it would be helpful if the path_selector widget divs were structured the same way as other fields.

@osc-bot osc-bot added this to the Backlog milestone Oct 4, 2024
@johrstrom
Copy link
Contributor

Do data-hide directives work for you? If so, seems like you can replace that form.js - or at least that portion of it.

https://osc.github.io/ood-documentation/latest/how-tos/app-development/interactive/dynamic-form-widgets.html?#hiding-entire-elements

@johrstrom
Copy link
Contributor

Also just to close the loop on this: here's the 3.1.x implementation of that same data-hide functionality. Looks like we try to find the first parent that has form-group class, and we hide it.

$(`#${changeId}`).parents().each(function(_i, parent) {
if(parent.classList.contains('form-group')) {
changeElement = $(parent);
}
});

Though - you should be careful here because the implementation has changed and will need updating again once you upgrade to 4.0 (the next release).

But that said - data-hide directives in the YAML will continue to work from 3.1 and beyond, even if the implementation of them change behind the scenes.

@fordste5
Copy link
Author

fordste5 commented Oct 4, 2024

I tested the data-hide functionality and it works like a charm. Thanks for the information!

@johrstrom
Copy link
Contributor

OK - so I take it this ticket is good to close?

@fordste5
Copy link
Author

fordste5 commented Oct 6, 2024

Yes, good to close.

@fordste5 fordste5 closed this as completed Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants