Added list_attribute addition

This commit is contained in:
Verox001 2024-02-28 11:18:14 +01:00
parent 7e9d445051
commit 2a6aa0b04f

View File

@ -1,6 +1,6 @@
<div class="flex-fill col-md-8 col-12 card bg-light p-6 mb-6"> <div class="flex-fill col-md-8 col-12 card bg-light p-6 mb-6">
<! -- Listen erstellen --> <!-- Listen erstellen -->
<div class="row mb-3"> <div class="row mb-3">
<h5 class="col-9"> <h5 class="col-9">
📋 Gewohnheiten 📋 Gewohnheiten
@ -11,7 +11,7 @@
</a> </a>
</div> </div>
<! -- Tabs zur Auswahl --> <!-- Tabs zur Auswahl -->
<ul class="nav nav-tabs card-header-tabs" role="tablist"> <ul class="nav nav-tabs card-header-tabs" role="tablist">
{% for habit_list in habit_lists %} {% for habit_list in habit_lists %}
@ -25,6 +25,39 @@
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
<script>
document.addEventListener('DOMContentLoaded', function () {
// Select all the tab links
const tabLinks = document.querySelectorAll('.nav-link');
tabLinks.forEach(function(link) {
// Add a click event listener to each tab link
link.addEventListener('click', function(e) {
// Prevent the default action
e.preventDefault();
// Get the tab ID
const tabId = this.getAttribute('href').match(/simple-tabpanel-(\d+)/)[1];
// Update the URL with the new query parameter
const newUrl = updateQueryStringParameter(window.location.href, 'list', tabId);
window.history.pushState({path:newUrl}, '', newUrl);
});
});
// Update the URL with the new query parameter
function updateQueryStringParameter(uri, key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (uri.match(re)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
}
else {
return uri + separator + key + "=" + value;
}
}
});
</script>
<div class="tab-content pt-5" id="tab-content"> <div class="tab-content pt-5" id="tab-content">
{% for habit_list in habit_lists %} {% for habit_list in habit_lists %}
@ -32,7 +65,7 @@
id="simple-tabpanel-{{habit_list.id}}" role="tabpanel" aria-labelledby="simple-tab-{{habit_list.id}}"> id="simple-tabpanel-{{habit_list.id}}" role="tabpanel" aria-labelledby="simple-tab-{{habit_list.id}}">
<div class="row mb-3 align-items-center"> <div class="row mb-3 align-items-center">
<! -- Personen die zur Liste gehören --> <!-- Personen die zur Liste gehören -->
<div class="col-2"> <div class="col-2">
<div class="avatar-stack"> <div class="avatar-stack">
<img class="avatar" src="/images/avatar/1.jpg"/> <img class="avatar" src="/images/avatar/1.jpg"/>
@ -42,7 +75,7 @@
</div> </div>
</div> </div>
<! -- Knopf für das Hinzufügen einer Person zur gemeinsamen Liste --> <!-- Knopf für das Hinzufügen einer Person zur gemeinsamen Liste -->
<div class="col-1"> <div class="col-1">
<button type="button" class="btn" <button type="button" class="btn"
style="width: 40px; height: 40px; min-height: 3em;"> style="width: 40px; height: 40px; min-height: 3em;">
@ -54,7 +87,7 @@
<div class="col-6"></div> <div class="col-6"></div>
<! -- neue Gewohnheiten erstellen --> <!-- neue Gewohnheiten erstellen -->
<a class="col-3 btn btn-primary" role="button" href="/habit?list={{ habit_list.id }}"> <a class="col-3 btn btn-primary" role="button" href="/habit?list={{ habit_list.id }}">
Gewohnheit erstellen Gewohnheit erstellen
</a> </a>
@ -64,30 +97,30 @@
{% for habit in habit_list.habits %} {% for habit in habit_list.habits %}
<li class="row d-flex align-items-center mb-2" id="habit-{{ habit.id }}"> <li class="row d-flex align-items-center mb-2" id="habit-{{ habit.id }}">
<! -- Handle zum verschieben --> <!-- Handle zum verschieben -->
<div class="col-auto drag-handle" style="cursor: grab;"> <div class="col-auto drag-handle" style="cursor: grab;">
<i class="bi bi-grip-vertical"></i> <i class="bi bi-grip-vertical"></i>
</div> </div>
<! -- Checkbox --> <!-- Checkbox -->
<div class="col-auto"> <div class="col-auto">
<input {% if habit.checked %} checked {% endif %} type="checkbox" class="task-checkbox" <input {% if habit.checked %} checked {% endif %} type="checkbox" class="task-checkbox"
id="{{ habit.id }}" id="{{ habit.id }}"
onclick="sendPostRequest('{{ habit.id }}')"> onclick="sendPostRequest('{{ habit.id }}')">
</div> </div>
<! -- Name --> <!-- Name -->
<div class="col" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis"> <div class="col" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
{{ habit.name }} {{ habit.name }}
</div> </div>
<! -- Beschreibung --> <!-- Beschreibung -->
<div class="col-md-3 d-none d-md-block text-black text-opacity-50" <div class="col-md-3 d-none d-md-block text-black text-opacity-50"
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis"> style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
{{ habit.note }} {{ habit.note }}
</div> </div>
<! -- Streak --> <!-- Streak -->
<div class="col-2" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis"> <div class="col-2" style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
{% if not habit.streak == 0 %} {% if not habit.streak == 0 %}
{{ habit.streak }} 🔥 {{ habit.streak }} 🔥
@ -95,14 +128,14 @@
</div> </div>
<! -- Knopf für das Löschen einer Gewohnheit --> <!-- Knopf für das Löschen einer Gewohnheit -->
<button type="button" class="btn btn-xs me-3" data-bs-toggle="modal" <button type="button" class="btn btn-xs me-3" data-bs-toggle="modal"
data-bs-target="#exampleModal" style="width: 40px; height: 40px" data-bs-target="#exampleModal" style="width: 40px; height: 40px"
onclick="setSelectedHabitId({{ habit.id }})"> onclick="setSelectedHabitId({{ habit.id }})">
<i class="bi bi-trash3"></i> <i class="bi bi-trash3"></i>
</button> </button>
<! -- Knopf für die Einstellungen einer Gewohnheit --> <!-- Knopf für die Einstellungen einer Gewohnheit -->
<button type="button" class="btn" <button type="button" class="btn"
style="width: 40px; height: 40px; min-height: 3em;"> style="width: 40px; height: 40px; min-height: 3em;">
@ -110,7 +143,7 @@
</button> </button>
<! -- Progressbar --> <!-- Progressbar -->
<div class="col-12"> <div class="col-12">
<div class="progress" style="height: 2px; width: 90%"> <div class="progress" style="height: 2px; width: 90%">
<div class="progress-bar" id="progress-bar-{{ habit.id }}" role="progressbar" <div class="progress-bar" id="progress-bar-{{ habit.id }}" role="progressbar"