-
Notifications
You must be signed in to change notification settings - Fork 93
feat: Add HTMX-powered search to snippet list (#510) #660
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
Open
Theminacious
wants to merge
4
commits into
django:main
Choose a base branch
from
Theminacious:feature/htmx-table-search
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f8aedef
feat: add HTMX-powered search to snippet list (#510)
Theminacious d5f5e17
refactor: address code review feedback
Theminacious e1287a0
fix: tighten HTMX search behavior and tests
Theminacious f554f6d
refactor: apply senior review polish (query operator, OOB updates, tr…
Theminacious File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| {% load core_tags %} | ||
|
|
||
| <div id="snippet-table"> | ||
| {% if object_list %} | ||
|
|
||
| {% component 'snippet_list' snippet_list=object_list / %} | ||
|
|
||
| {% component 'pagination' pagination_obj=pagination / %} | ||
|
|
||
| {% else %} | ||
|
|
||
| <div class="text-center py-12"> | ||
| <h3 class="text-xl font-medium text-gray-500">No snippets found</h3> | ||
| </div> | ||
|
|
||
| {% endif %} | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,55 @@ | ||
| {% extends "base.html" %} | ||
| {% load core_tags %} | ||
| {% load static %} | ||
|
|
||
| {% block bodyclass %}snippet-list{% endblock %} | ||
| {% block head_title %}Snippet list{% endblock %} | ||
|
|
||
| {% block new_content_header %} | ||
| <header class="bg-transparent"> | ||
| <h1 class="my-20 text-center float-none font-header text-8xl md:text-left">{{ hits }} snippet{{ hits|pluralize }}</h1> | ||
| <div class="my-4 flex justify-between px-4"> | ||
| <div></div> | ||
| {% component 'sorting_tabs' object_list=object_list / %} | ||
| </div> | ||
| </header> | ||
| <header class="bg-transparent"> | ||
|
|
||
| <h1 class="my-20 text-center float-none font-header text-8xl md:text-left"> | ||
| {{ hits }} snippet{{ hits|pluralize }} | ||
| </h1> | ||
|
|
||
| <div class="my-4 flex flex-col md:flex-row gap-4 justify-between items-center px-4"> | ||
|
|
||
| <form | ||
| method="get" | ||
| action="{{ request.path }}" | ||
| hx-get="{{ request.path }}" | ||
| hx-target="#snippet-table" | ||
| hx-swap="outerHTML" | ||
| hx-trigger="input changed delay:500ms from:input[name='q'], search" | ||
| hx-push-url="true" | ||
| class="w-full md:w-auto" | ||
| > | ||
|
Theminacious marked this conversation as resolved.
Theminacious marked this conversation as resolved.
|
||
| <label for="search-input" class="sr-only">Search snippets</label> | ||
| <input | ||
| id="search-input" | ||
| type="search" | ||
| name="q" | ||
| value="{{ query|default:'' }}" | ||
| placeholder="Search snippets..." | ||
| minlength="3" | ||
| class="w-full md:w-96 px-4 py-2 border-2 border-gray-300 rounded-lg focus:border-green-500 focus:ring-0" | ||
| > | ||
|
Theminacious marked this conversation as resolved.
Theminacious marked this conversation as resolved.
|
||
| {% for key, value in request.GET.items %} | ||
| {% if key != 'q' and key != 'page' %} | ||
| <input type="hidden" name="{{ key }}" value="{{ value }}"> | ||
| {% endif %} | ||
| {% endfor %} | ||
| </form> | ||
|
|
||
| {% component 'sorting_tabs' object_list=object_list / %} | ||
|
|
||
| </div> | ||
|
|
||
| </header> | ||
| {% endblock %} | ||
|
|
||
| {% block content %} | ||
| {% if object_list %} | ||
| {% component 'snippet_list' snippet_list=object_list / %} | ||
| {% component 'pagination' pagination_obj=pagination / %} | ||
| {% endif %} | ||
| {% endblock %} | ||
|
|
||
| {% include "cab/partials/_snippet_table.html" %} | ||
|
|
||
| {#{% block sidebar %}#} | ||
| {# <nav class="filter">#} | ||
| {# <h3>Filter by date</h3>#} | ||
| {# <ul>#} | ||
| {# <li{% if not months %} class="active"{% endif %}><a href="{{ request.path }}">Any time</a></li>#} | ||
| {# <li{% if months == 3 %} class="active"{% endif %}><a href="{{ request.path }}?months=3">3 months</a></li>#} | ||
| {# <li{% if months == 6 %} class="active"{% endif %}><a href="{{ request.path }}?months=6">6 months</a></li>#} | ||
| {# <li{% if months == 12 %} class="active"{% endif %}><a href="{{ request.path }}?months=12">1 year</a></li>#} | ||
| {# </ul>#} | ||
| {# </nav>#} | ||
| {##} | ||
| {# <p><a rel="alternate" href="{% url 'cab_feed_latest' %}" type="application/atom+xml"><i class="fa fa-fw fa-rss-square"></i>Feed of latest snippets</a></p>#} | ||
| {#{% endblock %}#} | ||
| {% endblock %} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.