mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Improve behaviour of added packages in search box
This commit is contained in:
parent
618a768f9a
commit
b410ab3bcc
@ -99,11 +99,15 @@ function updateResults(packages) {
|
||||
document.getElementById("add_package_empty").style.display = packages.length === 0 ? "block" : "none";
|
||||
|
||||
const alreadyAdded = getAddedPackages();
|
||||
packages.filter(pkg => !alreadyAdded.includes(`${pkg.author}/${pkg.name}`)).slice(0, 5).forEach(pkg => {
|
||||
packages.slice(0, 5).forEach(pkg => {
|
||||
const result = document.createElement("a");
|
||||
result.classList.add("list-group-item");
|
||||
result.classList.add("list-group-item-action");
|
||||
result.innerText = `${pkg.title} by ${pkg.author}`;
|
||||
if (alreadyAdded.includes(`${pkg.author}/${pkg.name}`)) {
|
||||
result.classList.add("active");
|
||||
result.innerHTML = "<i class='fas fa-check mr-3 text-success'></i>" + result.innerHTML;
|
||||
}
|
||||
result.addEventListener("click", () => addPackage(pkg));
|
||||
results.appendChild(result);
|
||||
});
|
||||
|
@ -9,7 +9,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block scriptextra %}
|
||||
<script src="/static/collection_editor.js?v=3"></script>
|
||||
<script src="/static/collection_editor.js?v=4"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
Loading…
Reference in New Issue
Block a user