Skip to content

Commit

Permalink
At /console/published-projects/ a search tool has been added to the p…
Browse files Browse the repository at this point in the history
…age. Closes #2307
  • Loading branch information
rafgia committed Oct 3, 2024
1 parent 195fb14 commit 9b9eec3
Showing 1 changed file with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@
{% endblock %}

{% block content %}
<script src="{% static 'console/js/generic-filter.js' %}"></script>
<div class="card mb-3">
<div class="card-header">
Published Projects <span class="badge badge-pill badge-info">{{ projects.paginator.count }}</span>
</div>
<div class="card-body">
<div class="table-responsive">
<div class="row">
<div class="col-sm-8">
<label class="font-weight-bold" for="searchbox">Search for project:</label>
</div>
</div>
<div class="row">
<div class="col-sm-8">
<input id="searchbox" type="search" oninput="search();" placeholder="Search...">
</div>
</div>
<div class="table-responsive" id="searchitems">
<table class="table table-bordered">
<thead>
<tr>
Expand Down Expand Up @@ -48,3 +59,23 @@
</div>
</div>
{% endblock %}

{% block local_js_bottom %}
<script>
function search() {
const query = document.getElementById('searchbox').value.toLowerCase();
const rows = document.querySelectorAll('#searchitems tbody tr');

rows.forEach(row => {
const projectTitle = row.querySelector('td a').textContent.toLowerCase();
if (projectTitle.includes(query)) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
}

document.getElementById('searchbox').addEventListener('input', search);
</script>
{% endblock %}

0 comments on commit 9b9eec3

Please sign in to comment.