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 search to Published Projects page in the console #2307 #2309

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ <h4 class="card-title">{{ project.title }}</h4>
Authors: {% for author in authors %}{{ author|show_all_author_info|safe }} {% endfor %}<br>
Created: {{ project.creation_datetime|date }}. Submitted: {{ project.submission_datetime|date }}.<br>
Storage Used: {{ storage_info.readable_used }} / {{ storage_info.readable_allowance }}<br>
Version: {{ project.version }}
{% if project.is_new_version %}<br>Latest Published Version: <a href="{% url 'published_project' latest_version.slug latest_version.version %}" target="_blank">{{ latest_version.version }}</a>{% endif %}
Version: {{ project.version }} {% if project.is_new_version %}<em style="color:blue;">(This is an update of the latest published version.)</em>{% endif %}
{% if project.is_new_version %}<br>Latest Published Version: <a href="{% url 'published_project' latest_version.slug latest_version.version %}" target="_blank">{{ latest_version.version }}</a> {% else %} <br>No latest version available. {% endif %}
{% if project.latest_reminder %}
<br>Latest reminder email sent on: {{ project.latest_reminder }}
{% endif %}
Expand Down
Loading