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

Add filtering and search to list views for various requests #584

Open
matthew-li opened this issue Mar 4, 2024 · 1 comment
Open

Add filtering and search to list views for various requests #584

matthew-li opened this issue Mar 4, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@matthew-li
Copy link
Collaborator

Some admin-accessible list views for requests have (a) search and (b) pagination capabilities, while others do not. Ensure that all of these views have both.

From a glance, the following do not:

  • New Project Requests
  • (MyBRC only) New Vector Project Requests
  • Project Renewal Requests
  • (MyBRC only) Secure Directory Requests
  • (MyBRC only) Service Units Purchase Requests

Avoid duplicating code--refactor common logic so that it is reusable as much as possible. Some reusable constructs may already exist.

@matthew-li
Copy link
Collaborator Author

The beginnings of a template (coldfront/templates/common/list_search.html) for de-duplicating logic that I'd started writing a while back:

<div class="mb-3" id="accordion">
  <div class="card">
    <div class="card-header">
      <a id="expand_button" role="button" class="card-link " data-toggle="collapse" href="#collapseOne">
        <i class="fas fa-filter" aria-hidden="true"></i> Search
        <i id="plus_minus" class="fas {{ list_search_expand_accordion|get_icon }} float-right"></i>
      </a>
    </div>
    <div id="collapseOne" class="collapse {{ list_search_expand_accordion }}" data-parent="#accordion">
      <div class="card-body">
        <form id="filter_form" method="GET" action="{{ list_search_url }}" autocomplete="off">
          {{ list_search_form|crispy }}
          <input type="submit" class="btn btn-primary" value="Search">
          <button id="form_reset_button" type="button" class="btn btn-secondary">Reset</button>
        </form>
      </div>
    </div>
  </div>
</div>
<hr>

{% comment %}
- Usage:
    - View:
        - Add 'expand_list_search_expand_accordion' (str) to context data.
            - Set it to 'show' to have the search tool expanded on page load.
            - Set it to anything else to have the search tool collapsed on page load.
    - Template:
        - Define the URL to search against (probably the URL of the current view).
        - Define arguments to pass to the URL.
        - Include the search tool, passing the URL to it.
        - Example code:
            {% url 'your-url' optional_args=here as list_search_url %}
            {% include 'common/list_search.html' with list_search_url=list_search_url with list_search_form=list_search_form %}
{% endcomment %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants