-
Notifications
You must be signed in to change notification settings - Fork 128
feat(index): Added search bar for template filtering #434
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
teja-pola
wants to merge
3
commits into
accordproject:main
Choose a base branch
from
teja-pola:teja/i433/add-search-bar
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 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,15 @@ | |
| <section class="section"> | ||
| <div class="container"> | ||
| <h2 class="title is-2">Templates</h2> | ||
| <table class="table box versions"> | ||
|
|
||
| <!-- Search Bar --> | ||
| <div class="field"> | ||
| <div class="control"> | ||
| <input type="text" id="searchInput" class="input" placeholder="SEARCH FOR TEMPLATE" onkeyup="filterTable()"> | ||
| </div> | ||
| </div> | ||
|
|
||
| <table class="table box versions" id="templateTable"> | ||
| <thead> | ||
| <tr> | ||
| <th>Name</th> | ||
|
|
@@ -26,8 +34,8 @@ | |
| <th>Type</th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {% for name, val in templateIndex |dictsort%} | ||
| <tbody id="tableBody"> | ||
| {% for name, val in templateIndex | dictsort %} | ||
| <tr> | ||
| <th> | ||
| <a href="{{name}}.html"> | ||
|
|
@@ -36,12 +44,19 @@ | |
| {% else %} | ||
| {{name}} | ||
| {% endif %} | ||
| <a> | ||
| </a> | ||
| </th> | ||
| <td>{{val.description}}</td> | ||
| <td>{{val.ciceroVersion}}</td> | ||
| <td>{% if val.type === 0 %}Contract{% else %}Clause{% endif %}</td> | ||
| </tr> | ||
| {% endfor %} | ||
|
|
||
| <!-- No Results Row (Hidden by Default) --> | ||
| <tr id="noResultsRow" style="display: none;"> | ||
| <td colspan="4" class="has-text-centered">No results found</td> | ||
| </tr> | ||
|
|
||
| </tbody> | ||
| <tfoot> | ||
| <tr> | ||
|
|
@@ -58,4 +73,32 @@ | |
| </div> | ||
| </section> | ||
|
|
||
| {% endblock %} | ||
| <!-- JavaScript for Search Functionality --> | ||
| <script> | ||
| function filterTable() { | ||
teja-pola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let input = document.getElementById("searchInput"); | ||
| let filter = input.value.toLowerCase(); | ||
| let table = document.getElementById("templateTable"); | ||
| let rows = table.getElementsByTagName("tr"); | ||
| let noResultsRow = document.getElementById("noResultsRow"); | ||
| let matchFound = false; | ||
|
|
||
| for (let i = 1; i < rows.length - 1; i++) { // Exclude the last row (noResultsRow) | ||
| let td = rows[i].getElementsByTagName("th")[0]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getElementsByTagName is not the most concise way to access the first element, possible to use What do you say? |
||
| if (td) { | ||
| let textValue = td.textContent || td.innerText; | ||
| if (textValue.toLowerCase().indexOf(filter) > -1) { | ||
| rows[i].style.display = ""; | ||
| matchFound = true; | ||
| } else { | ||
| rows[i].style.display = "none"; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Show "No results found" row if no matches are found | ||
| noResultsRow.style.display = matchFound ? "none" : ""; | ||
| } | ||
| </script> | ||
|
|
||
| {% endblock %} | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@teja-pola if I am not wrong this is for searching templates, possible to make the id more related to that.
ex: id=searchTemplateInput