1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-08-11 00:15:21 +02:00

Visual improvement on manage page

This commit is contained in:
Ehouarn
2025-08-09 15:38:02 +02:00
parent b10b2fb3b6
commit 74f9c53c18
4 changed files with 66 additions and 25 deletions

View File

@@ -52,7 +52,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
</div>
{# User search with autocompletion #}
<div class="card-footer">
<input class="form-control mx-auto d-block" placeholder="{% trans "Name" %}" type="text" id="note" autofocus />
<input class="form-control mx-auto d-block mb-2" placeholder="{% trans "Name" %}" type="text" id="note" autofocus />
{% if user_family %}
<button class="btn btn-sm btn-secondary btn-block" id="select_my_family">
{% trans "Select my family" %} ({{ user_family.name }})
</button>
{% endif %}
</div>
</div>
</div>
@@ -210,6 +215,55 @@ SPDX-License-Identifier: GPL-3.0-or-later
document.getElementById("consume_all").addEventListener("click", function () {
$('#validationModal').modal('show');
});
{% if user_family %}
document.getElementById("select_my_family").addEventListener("click", function () {
// Simulate selecting the user's family
var userFamily = {
id: {{ user_family.id }},
name: "{{ user_family.name|escapejs }}",
display_image: "{{ user_family.display_image.url|default:'/static/member/img/default_picture.png'|escapejs }}"
};
// Check if family is already selected
var alreadySelected = false;
notes_display.forEach(function (d) {
if (d.id === userFamily.id) {
alreadySelected = true;
}
});
if (!alreadySelected) {
// Add the family to the selected families
var disp = {
name: userFamily.name,
id: userFamily.id,
family: userFamily,
};
notes_display.push(disp);
// Update the display
const family_list = $('#note_list');
let html = '';
notes_display.forEach(function (disp) {
html += li('note_' + disp.id, disp.name, '');
});
family_list.html(html);
// Add click handlers for removal
notes_display.forEach(function (disp) {
const line_obj = $('#note_' + disp.id);
line_obj.hover(function () {
displayFamily(disp.family, disp.name, 'user_note', 'profile_pic');
});
line_obj.click(removeFamily(disp, 'note', notes_display, 'note_list', 'user_note', 'profile_pic'));
});
// Display the family info
displayFamily(userFamily, userFamily.name, 'user_note', 'profile_pic');
}
});
{% endif %}
</script>
</script>
{% endblock %}