2024-03-10 22:02:57 +01:00
<!-- suppress HtmlUnknownTarget -->
2024-03-06 10:52:47 +01:00
< div class = "flex-fill col-md-7 col-lg-8 col-12 card bg-light p-6 mb-6" >
2024-02-20 20:55:06 +01:00
2024-02-28 11:18:14 +01:00
<!-- Listen erstellen -->
2024-02-20 20:55:06 +01:00
< div class = "row mb-3" >
2024-03-10 21:02:33 +01:00
< h5 class = "col-9" > 📋 Gewohnheiten< / h5 >
< a class = "col-3 btn btn-primary p" role = "button" href = "/habit-list" > Neue Liste erstellen< / a >
2024-02-28 10:46:26 +01:00
< / div >
2024-02-20 20:55:06 +01:00
2024-02-28 11:18:14 +01:00
<!-- Tabs zur Auswahl -->
2024-02-20 20:55:06 +01:00
< ul class = "nav nav-tabs card-header-tabs" role = "tablist" >
{% for habit_list in habit_lists %}
2024-03-05 11:15:43 +01:00
< li class = "nav-item" role = "presentation" id = "tab-{{ habit_list.id }}" >
2024-03-11 19:07:50 +01:00
< a class = "nav-link {% if (active_list is not none and active_list == habit_list.id) or (active_list is none and habit_list == habit_lists[0]) %} active {% endif %}"
2024-02-20 20:55:06 +01:00
id="simple-tab-{{habit_list.id}}"
data-bs-toggle="tab" href="#simple-tabpanel-{{habit_list.id}}" role="tab"
aria-controls="simple-tabpanel-{{habit_list.id}}" aria-selected="true">
{{habit_list.name}}
< / a >
< / li >
{% endfor %}
< / ul >
2024-03-10 21:02:33 +01:00
2024-02-28 11:18:14 +01:00
< 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) {
2024-03-10 22:02:57 +01:00
const re = new RegExp("([?& ])" + key + "=.*?(& |$)", "i");
const separator = uri.indexOf('?') !== -1 ? "& " : "?";
2024-02-28 11:18:14 +01:00
if (uri.match(re)) {
return uri.replace(re, '$1' + key + "=" + value + '$2');
}
else {
return uri + separator + key + "=" + value;
}
}
});
< / script >
2024-02-20 20:55:06 +01:00
< div class = "tab-content pt-5" id = "tab-content" >
{% for habit_list in habit_lists %}
2024-03-11 19:07:50 +01:00
< div class = "tab-pane {% if (active_list is not none and active_list == habit_list.id) or (active_list is none and habit_list == habit_lists[0]) %} active {% endif %}"
2024-02-20 20:55:06 +01:00
id="simple-tabpanel-{{habit_list.id}}" role="tabpanel" aria-labelledby="simple-tab-{{habit_list.id}}">
2024-03-05 11:15:43 +01:00
<!-- Beschreibung und Löschen von der Liste -->
2024-03-07 17:54:06 +01:00
< div class = "row" >
2024-03-05 11:15:43 +01:00
< div class = "col" >
{{ habit_list.description }}
< / div >
2024-03-07 14:20:45 +01:00
< div class = "col-1" >
2024-03-05 11:15:43 +01:00
< button type = "button" class = "btn btn-xs me-3" data-bs-toggle = "modal"
2024-03-07 17:54:06 +01:00
data-bs-target="#listenModal"
2024-03-06 11:04:32 +01:00
onclick="{
localStorage.setItem('selectedListId', {{ habit_list.id }});
}">
2024-03-07 14:20:45 +01:00
<!-- - onclick="setSelectedListId({{ habit_list.id }})" -->
2024-03-05 11:15:43 +01:00
< i class = "bi bi-trash3" > < / i >
< / button >
< / div >
< / div >
2024-02-28 10:46:26 +01:00
< div class = "row mb-3 align-items-center" >
2024-02-28 11:18:14 +01:00
<!-- Personen die zur Liste gehören -->
2024-03-01 09:25:36 +01:00
{% if habit_list.get_users()[0].id == current_user.id %}
{% if habit_list.get_users()|length > 1 %}
2024-03-01 09:17:52 +01:00
< div class = "col" >
2024-02-28 10:46:26 +01:00
< div class = "avatar-stack" >
2024-03-01 09:17:52 +01:00
{% for user in habit_list.get_users() %}
{% if current_user.id != user.id %}
2024-03-07 14:20:45 +01:00
< img class = "avatar" src = "/{{user.profile_image}}" data-toggle = "tooltip" data-placement = "top"
2024-03-10 22:02:57 +01:00
title="{{user.name}}" alt=""/>
2024-03-01 09:17:52 +01:00
{% endif %}
{% endfor %}
2024-02-28 10:46:26 +01:00
< / div >
< / div >
2024-03-01 09:25:36 +01:00
{% endif %}
2024-02-28 10:46:26 +01:00
2024-03-01 09:17:52 +01:00
< div class = "col" >
2024-03-07 17:54:06 +01:00
<!-- Knopf für das Hinzufügen einer Person zur gemeinsamen Liste -->
< a class = "me-5" href = "/users?habit_list={{habit_list.id}}" style = "width: 40px; height: 40px; min-height: 3em;"
2024-03-07 14:20:45 +01:00
data-toggle="tooltip" data-placement="top" title="Benutzer einladen">
2024-03-07 15:48:39 +01:00
< i class = "bi bi-person-fill-add" style = "font-size: 24px;" > < / i >
2024-03-01 08:50:33 +01:00
< / a >
2024-03-07 17:54:06 +01:00
<!-- Knopf für das Bearbeiten von Personen zur gemeinsamen Liste -->
{% if habit_list.get_users()|length > 1 %}
< a href = "/users-edit?habit_list={{habit_list.id}}" style = "width: 40px; height: 40px; min-height: 3em;"
data-toggle="tooltip" data-placement="top" title="Benutzer bearbeiten">
< i class = "bi bi-pencil" > < / i >
< / a >
{% endif %}
2024-02-28 10:46:26 +01:00
< / div >
2024-03-01 09:25:36 +01:00
{% else %}
2024-03-07 19:22:32 +01:00
< div class = "row" >
2024-03-07 18:39:15 +01:00
< a class = "me-5" href = "/users-leave?habit_list={{habit_list.id}}" style = "width: 40px; height: 40px; min-height: 3em;"
data-toggle="tooltip" data-placement="top" title="Liste verlassen">
< i class = "bi bi-box-arrow-left" style = "font-size: 24px;" > < / i >
< / a >
2024-03-07 19:22:32 +01:00
< div class = "col" >
< div class = "avatar-stack" >
{% for user in habit_list.get_users() %}
{% if current_user.id != user.id %}
< img class = "avatar" src = "/{{user.profile_image}}" data-toggle = "tooltip" data-placement = "top"
2024-03-10 22:02:57 +01:00
title="{{user.name}}" alt=""/>
2024-03-07 19:22:32 +01:00
{% endif %}
{% endfor %}
< / div >
2024-03-07 18:39:15 +01:00
< / div >
2024-03-07 19:22:32 +01:00
2024-03-01 09:25:36 +01:00
{% endif %}
2024-02-28 10:46:26 +01:00
2024-03-07 17:54:06 +01:00
< div class = "col-4" > < / div >
2024-02-28 10:46:26 +01:00
2024-02-28 11:18:14 +01:00
<!-- neue Gewohnheiten erstellen -->
2024-02-20 20:55:06 +01:00
< a class = "col-3 btn btn-primary" role = "button" href = "/habit?list={{ habit_list.id }}" >
Gewohnheit erstellen
< / a >
< / div >
< ul class = "task-list row" >
{% for habit in habit_list.habits %}
< li class = "row d-flex align-items-center mb-2" id = "habit-{{ habit.id }}" >
2024-02-28 10:46:26 +01:00
2024-03-05 11:15:43 +01:00
<!-- Handle zum Verschieben -->
2024-02-20 20:55:06 +01:00
< div class = "col-auto drag-handle" style = "cursor: grab;" >
< i class = "bi bi-grip-vertical" > < / i >
< / div >
2024-02-28 10:46:26 +01:00
2024-02-28 11:18:14 +01:00
<!-- Checkbox -->
2024-02-20 20:55:06 +01:00
< div class = "col-auto" >
< input { % if habit . checked % } checked { % endif % } type = "checkbox" class = "task-checkbox"
2024-03-10 22:02:57 +01:00
id="{{ habit.id }}" onclick="sendPostRequest('{{ habit.id }}')">
2024-02-20 20:55:06 +01:00
< / div >
2024-02-28 11:18:14 +01:00
<!-- Name -->
2024-02-20 20:55:06 +01:00
< div class = "col" style = "white-space: nowrap; overflow: hidden; text-overflow: ellipsis" >
{{ habit.name }}
< / div >
2024-02-28 11:18:14 +01:00
<!-- Beschreibung -->
2024-03-01 10:30:41 +01:00
< div class = "col-md-4 d-none d-md-block text-black text-opacity-50"
2024-02-20 20:55:06 +01:00
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
{{ habit.note }}
< / div >
2024-02-28 11:18:14 +01:00
<!-- Streak -->
2024-03-07 14:20:45 +01:00
< div class = "col-2" id = "streak-{{ habit.id }}"
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis">
2024-02-20 20:55:06 +01:00
{% if not habit.streak == 0 %}
2024-03-05 09:45:14 +01:00
{{ habit.streak }} 🔥
2024-02-20 20:55:06 +01:00
{% endif %}
< / div >
2024-02-28 11:18:14 +01:00
<!-- Knopf für das Löschen einer Gewohnheit -->
2024-02-28 10:46:26 +01:00
< button type = "button" class = "btn btn-xs me-3" data-bs-toggle = "modal"
2024-02-20 20:55:06 +01:00
data-bs-target="#exampleModal" style="width: 40px; height: 40px"
onclick="setSelectedHabitId({{ habit.id }})">
< i class = "bi bi-trash3" > < / i >
< / button >
2024-02-28 10:46:26 +01:00
2024-03-01 10:30:41 +01:00
<!-- Knopf für das Bearbeiten der Gewohnheit -->
2024-03-07 14:20:45 +01:00
< a type = "button" class = "btn" href = "{{ url_for('edit_habit') }}?habit={{ habit.id }}"
aria-current="page"
style="width: 40px; height: 40px; min-height: 3em;">
2024-02-28 10:46:26 +01:00
2024-03-01 08:19:53 +01:00
< i class = "bi bi-pencil" > < / i >
< / a >
2024-02-28 10:46:26 +01:00
2024-02-28 11:18:14 +01:00
<!-- Progressbar -->
2024-02-20 20:55:06 +01:00
< div class = "col-12" >
< div class = "progress" style = "height: 2px; width: 90%" >
< div class = "progress-bar" id = "progress-bar-{{ habit.id }}" role = "progressbar"
style="width: {{ habit.percentage }}%; background-color: {% if habit.percentage >= 100 %} green {% else %} primary {% endif %}"
aria-valuenow="{{ habit.percentage }}" aria-valuemin="0"
aria-valuemax="100">< / div >
< / div >
< / div >
< / li >
{% endfor %}
< / ul >
< / div >
{% endfor %}
< / div >
2024-03-10 21:02:33 +01:00
< / div >
2024-02-20 20:55:06 +01:00
< / div >
< script >
2024-03-10 21:02:33 +01:00
var selectedHabitId = null;
2024-02-20 20:55:06 +01:00
2024-03-10 21:02:33 +01:00
function setSelectedHabitId(habitId) {
selectedHabitId = habitId;
}
2024-02-20 20:55:06 +01:00
2024-03-10 21:02:33 +01:00
var selectedListId = null;
2024-03-07 14:20:45 +01:00
2024-03-10 21:02:33 +01:00
function setSelectedListId(listId) {
selectedlistId = listId;
}
2024-02-20 20:55:06 +01:00
< / script >