Compare commits
No commits in common. "30edcec39c81f379c65f953d232b618c4251d47f" and "785edd1f88a693382c0de1fe6903ea7b192b4de8" have entirely different histories.
30edcec39c
...
785edd1f88
18
app.py
18
app.py
@ -568,24 +568,6 @@ def delete_habit():
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
@app.route('/delete-list', methods=['POST'])
|
|
||||||
@login_required
|
|
||||||
def delete_list():
|
|
||||||
list_id = request.get_json()["listId"]
|
|
||||||
|
|
||||||
habit_list = HabitList.get(list_id)
|
|
||||||
|
|
||||||
if habit_list is None:
|
|
||||||
return {"error": "List not found"}
|
|
||||||
|
|
||||||
# Check if habit belongs to user
|
|
||||||
if current_user not in habit_list.get_users():
|
|
||||||
return {"error": "List does not belong to user"}
|
|
||||||
|
|
||||||
habit_list.delete()
|
|
||||||
return {}
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/reorder', methods=['POST'])
|
@app.route('/reorder', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def reorder_habits():
|
def reorder_habits():
|
||||||
|
|||||||
@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
<div class="modal fade" id="listenModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
|
||||||
<div class="modal-dialog">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h1 class="modal-title fs-5" id="exampleModalLabel">Bestätige</h1>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
Möchtest du diese Liste wirklich löschen?
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">abbrechen</button>
|
|
||||||
<button type="button" class="btn btn-primary btn-danger" data-bs-dismiss="modal"
|
|
||||||
onclick="deleteList(selectedListId)">Löschen
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
<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 %}
|
||||||
|
|
||||||
<li class="nav-item" role="presentation" id="tab-{{ habit_list.id }}">
|
<li class="nav-item" role="presentation">
|
||||||
<a class="nav-link {% if habit_list == habit_lists[0] %} active {% endif %}"
|
<a class="nav-link {% if habit_list == habit_lists[0] %} active {% endif %}"
|
||||||
id="simple-tab-{{habit_list.id}}"
|
id="simple-tab-{{habit_list.id}}"
|
||||||
data-bs-toggle="tab" href="#simple-tabpanel-{{habit_list.id}}" role="tab"
|
data-bs-toggle="tab" href="#simple-tabpanel-{{habit_list.id}}" role="tab"
|
||||||
@ -63,22 +63,6 @@
|
|||||||
{% for habit_list in habit_lists %}
|
{% for habit_list in habit_lists %}
|
||||||
<div class="tab-pane {% if habit_list == habit_lists[0] %} active {% endif %}"
|
<div class="tab-pane {% if habit_list == habit_lists[0] %} active {% endif %}"
|
||||||
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}}">
|
||||||
|
|
||||||
<!-- Beschreibung und Löschen von der Liste -->
|
|
||||||
<div class="row mb-3">
|
|
||||||
<div class="col">
|
|
||||||
{{ habit_list.description }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-2">
|
|
||||||
<button type="button" class="btn btn-xs me-3" data-bs-toggle="modal"
|
|
||||||
data-bs-target="#listenModal" style="width: 40px; height: 40px"
|
|
||||||
onclick="setSelectedListId({{ habit_list.id }})">
|
|
||||||
<i class="bi bi-trash3"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<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 -->
|
||||||
@ -119,7 +103,7 @@
|
|||||||
{% 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>
|
||||||
@ -188,9 +172,5 @@
|
|||||||
selectedHabitId = habitId;
|
selectedHabitId = habitId;
|
||||||
}
|
}
|
||||||
|
|
||||||
var selectedListId = null;
|
|
||||||
|
|
||||||
function setSelectedListId(listId) {
|
|
||||||
selectedlistId = listId;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -76,28 +76,6 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteList(listId) {
|
|
||||||
// Make a POST request to /delete with the habit id
|
|
||||||
|
|
||||||
axios.post('/delete-list', {listId: listId}, {
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
}
|
|
||||||
}).then(function (response) {
|
|
||||||
// Handle the success response if needed
|
|
||||||
console.log(response.data);
|
|
||||||
|
|
||||||
// Remove the habit from the DOM
|
|
||||||
var habitElement = document.getElementById("simple-tabpanel-" + listId);
|
|
||||||
habitElement.remove();
|
|
||||||
var habitElement = document.getElementById("tab-" + listId);
|
|
||||||
habitElement.remove();
|
|
||||||
}).catch(function (error) {
|
|
||||||
// Handle the error if needed
|
|
||||||
console.error('Error:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', (event) => {
|
document.addEventListener('DOMContentLoaded', (event) => {
|
||||||
var elements = document.querySelectorAll('.task-list').values()
|
var elements = document.querySelectorAll('.task-list').values()
|
||||||
|
|||||||
@ -47,10 +47,6 @@
|
|||||||
{% include 'components/delete_button.html' %}
|
{% include 'components/delete_button.html' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if current_user.is_authenticated %}
|
|
||||||
{% include 'components/delete_list.html' %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% include 'components/scripts.html' %}
|
{% include 'components/scripts.html' %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user