Skip to content

Conversation

@teja-pola
Copy link

Closes #433

This pull request adds a search bar above the template table to enhance usability by allowing users to quickly find specific templates. The search function dynamically filters table rows as the user types. Additionally, when no matching templates are found, a "No results found" message is displayed to improve user feedback.

This feature improves navigation within the template library, making it easier to locate specific templates efficiently.

Changes

  • Added a search bar above the template table.
  • Implemented filtering functionality to show matching templates as the user types.
  • Displayed "No results found" when no matching templates exist.

Flags

N/A

Screenshots

BEFORE

Screenshot 2025-03-09 152213

AFTER

Screenshot 2025-03-09 152322

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to master from fork:branchname

let matchFound = false;
for (let i = 1; i < rows.length - 1; i++) { // Exclude the last row (noResultsRow)
let td = rows[i].getElementsByTagName("th")[0];

Choose a reason for hiding this comment

The 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
let td = rows[i].querySelector("th");
querySelector to target the first and avoid the need for the index 0.

What do you say?

<!-- Search Bar -->
<div class="field">
<div class="control">
<input type="text" id="searchInput" class="input" placeholder="SEARCH FOR TEMPLATE" onkeyup="filterTable()">

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

@DianaLease
Copy link
Member

LGTM but I'm not sure how to kick off those unit tests that are pending in the CI for this repo. @mttrbrts or @dselman, are you aware of how to fix that?

@teja-pola
Copy link
Author

LGTM but I'm not sure how to kick off those unit tests that are pending in the CI for this repo. @mttrbrts or @dselman, are you aware of how to fix that?

@DianaLease It looks like the CI pipeline hasn't run successfully in a long time. The failure seems to be due to deprecated Node.js versions (12.x and 16.x). Could we update GitHub Actions to use Node.js 20? I guess this should fix the CI issues and allow unit tests to run again.

@DianaLease
Copy link
Member

LGTM but I'm not sure how to kick off those unit tests that are pending in the CI for this repo. @mttrbrts or @dselman, are you aware of how to fix that?

@DianaLease It looks like the CI pipeline hasn't run successfully in a long time. The failure seems to be due to deprecated Node.js versions (12.x and 16.x). Could we update GitHub Actions to use Node.js 20? I guess this should fix the CI issues and allow unit tests to run again.

@teja-pola Want to try updating https://github.com/accordproject/cicero-template-library/blob/main/.github/workflows/build.yml and https://github.com/accordproject/cicero-template-library/blob/main/.github/workflows/build-and-publish.yml in your PR to use node 20 instead and see if that fixes it?

@teja-pola
Copy link
Author

LGTM but I'm not sure how to kick off those unit tests that are pending in the CI for this repo. @mttrbrts or @dselman, are you aware of how to fix that?

@DianaLease It looks like the CI pipeline hasn't run successfully in a long time. The failure seems to be due to deprecated Node.js versions (12.x and 16.x). Could we update GitHub Actions to use Node.js 20? I guess this should fix the CI issues and allow unit tests to run again.

@teja-pola Want to try updating https://github.com/accordproject/cicero-template-library/blob/main/.github/workflows/build.yml and https://github.com/accordproject/cicero-template-library/blob/main/.github/workflows/build-and-publish.yml in your PR to use node 20 instead and see if that fixes it?

@DianaLease tried doing so, but still tests are not checked. should i abort?

Copy link
Member

@DianaLease DianaLease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also change lines 7, 31, 35, and 39 in .github/workflows/build-and-publish.yml to point to main instead of master? And also line 7 in .github/workflows/build.yml? That should trigger the tests to run on your PR in the CI.

@teja-pola
Copy link
Author

@DianaLease Now please review again.

@Vatsal-Verma
Copy link

How about adding search by algolia instead of this?

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.

Add a Search Bar to Filter Templates in the Table

4 participants