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

Fix(SavedSearch): Force user to validate criteria before saved search #18385

Open
wants to merge 1 commit into
base: 10.0/bugfixes
Choose a base branch
from

Conversation

stonebuzz
Copy link
Contributor

@stonebuzz stonebuzz commented Nov 26, 2024

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • It fixes !35211

Perhaps an alternative to #18376.

After further review, I believe the issue here is that the saved search system expects the user to execute a search based on their criteria at least once (to include them in the URL).

See GenericView.js L102

const bs_modal = new bootstrap.Modal(modal.get(0), {show: false});
modal.on('show.bs.modal', () => {
    const params = JSON.parse(modal.attr('data-params'));
    params['url'] = window.location.pathname + window.location.search;
    modal.find('.modal-body').load(CFG_GLPI.root_doc + '/ajax/savedsearch.php', params);
});

If the user does not execute a search at least once, the default search for the item type is used and saved in the database.

Since I don’t see how to extract the search

image

convert it into a URL as shown here

image

and then pass it to the modal (from GenericView.js L102)

I simply propose checking whether window.location.search is not empty or does not correspond to a search reset (reset=reset).

Screenshots (if appropriate):

@stonebuzz
Copy link
Contributor Author

Awaiting user feedback
!35211

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

Successfully merging this pull request may close these issues.

1 participant