poprawki w js

This commit is contained in:
Mateusz Gruszczyński
2025-07-15 23:55:50 +02:00
parent 9dcd144b34
commit 53394469de
5 changed files with 112 additions and 71 deletions

View File

@@ -87,40 +87,58 @@ Lista: <strong>{{ list.title }}</strong>
<ul id="items" class="list-group mb-3">
{% for item in items %}
<li data-name="{{ item.name|lower }}" id="item-{{ item.id }}"
class="list-group-item d-flex justify-content-between align-items-center flex-wrap clickable-item
{% if item.purchased %}bg-success text-white{% elif item.not_purchased %}bg-warning text-dark{% else %}item-not-checked{% endif %}">
<li data-name="{{ item.name|lower }}" id="item-{{ item.id }}"
class="list-group-item d-flex justify-content-between align-items-center flex-wrap clickable-item
{% if item.purchased %}bg-success text-white{% elif item.not_purchased %}bg-warning text-dark{% else %}item-not-checked{% endif %}">
<div class="d-flex align-items-center gap-3 flex-grow-1">
<div class="d-flex align-items-center gap-3 flex-grow-1">
<input id="checkbox-{{ item.id }}" class="large-checkbox" type="checkbox"
{% if item.purchased %}checked{% endif %}
{% if list.is_archived %}disabled{% endif %}>
{% if list.is_archived or item.not_purchased %}disabled{% endif %}>
<span id="name-{{ item.id }}" class="text-white">
{{ item.name }}
{% if item.quantity and item.quantity > 1 %}
<span class="badge bg-secondary">x{{ item.quantity }}</span>
{% endif %}
</span>
<span id="name-{{ item.id }}" class="{% if item.purchased %}text-white{% else %}text-white{% endif %}">
{{ item.name }}
{% if item.quantity and item.quantity > 1 %}
<span class="badge bg-secondary">x{{ item.quantity }}</span>
{% endif %}
</span>
{% if item.note %}
<small class="text-danger ms-4">[ <b>{{ item.note }}</b> ]</small>
<small class="text-danger ms-4">[ <b>{{ item.note }}</b> ]</small>
{% endif %}
{% if item.not_purchased_reason %}
<small class="text-dark ms-4">[ <b>Powód: {{ item.not_purchased_reason }}</b> ]</small>
<small class="text-dark ms-4">[ <b>Powód: {{ item.not_purchased_reason }}</b> ]</small>
{% endif %}
</div>
<div class="mt-2 mt-md-0 d-flex gap-1">
<button class="btn btn-sm btn-outline-warning"
{% if list.is_archived %}disabled{% else %}onclick="editItem({{ item.id }}, '{{ item.name }}', {{ item.quantity or 1 }})"{% endif %}>
✏️
</button>
<button class="btn btn-sm btn-outline-danger"
{% if list.is_archived %}disabled{% else %}onclick="deleteItem({{ item.id }})"{% endif %}>
🗑️
</button>
<div class="btn-group btn-group-sm" role="group">
{% if item.not_purchased %}
<button type="button" class="btn btn-outline-success"
{% if list.is_archived %}disabled{% else %}onclick="unmarkNotPurchased({{ item.id }})"{% endif %}>
✅ Przywróć
</button>
{% else %}
<button type="button" class="btn btn-outline-light"
{% if list.is_archived %}disabled{% else %}onclick="markNotPurchasedModal(event, {{ item.id }})"{% endif %}>
⚠️
</button>
{% endif %}
{% if not is_share %}
<button type="button" class="btn btn-outline-warning"
{% if list.is_archived %}disabled{% else %}onclick="editItem({{ item.id }}, '{{ item.name }}', {{ item.quantity or 1 }})"{% endif %}>
✏️
</button>
<button type="button" class="btn btn-outline-danger"
{% if list.is_archived %}disabled{% else %}onclick="deleteItem({{ item.id }})"{% endif %}>
🗑️
</button>
{% endif %}
</div>
</li>
{% else %}
<li id="empty-placeholder"
class="list-group-item bg-dark text-secondary text-center w-100">
@@ -186,11 +204,15 @@ Lista: <strong>{{ list.title }}</strong>
</div>
{% block scripts %}
<script>
window.IS_SHARE = false;
</script>
<script src="{{ url_for('static_bp.serve_js', filename='mass_add.js') }}"></script>
<script>
setupList({{ list.id }}, '{{ current_user.username if current_user.is_authenticated else 'Gość' }}');
</script>
<script src="{{ url_for('static_bp.serve_js', filename='receipt_upload.js') }}"></script>
{% endblock %}
{% endblock %}

View File

@@ -27,50 +27,52 @@
<ul id="items" class="list-group mb-3">
{% for item in items %}
<li data-name="{{ item.name|lower }}" id="item-{{ item.id }}"
class="list-group-item d-flex justify-content-between align-items-center flex-wrap clickable-item
{% if item.purchased %}bg-success text-white{% elif item.not_purchased %}bg-warning text-dark{% else %}item-not-checked{% endif %}">
<div class="d-flex align-items-center gap-3 flex-grow-1">
<li data-name="{{ item.name|lower }}" id="item-{{ item.id }}"
class="list-group-item d-flex justify-content-between align-items-center flex-wrap clickable-item
{% if item.purchased %}bg-success text-white{% elif item.not_purchased %}bg-warning text-dark{% else %}item-not-checked{% endif %}">
<input id="checkbox-{{ item.id }}" class="large-checkbox" type="checkbox"
{% if item.purchased %}checked{% endif %}
{% if list.is_archived %}disabled{% endif %}>
<div class="d-flex align-items-center gap-3 flex-grow-1">
<span id="name-{{ item.id }}" class="{% if item.purchased %}text-white{% else %}text-white{% endif %}">
{{ item.name }}
{% if item.quantity and item.quantity > 1 %}
<span class="badge bg-secondary">x{{ item.quantity }}</span>
<input id="checkbox-{{ item.id }}" class="large-checkbox" type="checkbox"
{% if item.purchased %}checked{% endif %}
{% if list.is_archived or item.not_purchased %}disabled{% endif %}>
<span id="name-{{ item.id }}" class="text-white">
{{ item.name }}
{% if item.quantity and item.quantity > 1 %}
<span class="badge bg-secondary">x{{ item.quantity }}</span>
{% endif %}
</span>
{% if item.note %}
<small class="text-danger ms-4">[ <b>{{ item.note }}</b> ]</small>
{% endif %}
</span>
{% if item.not_purchased_reason %}
<small class="text-dark ms-4">[ <b>Powód: {{ item.not_purchased_reason }}</b> ]</small>
{% endif %}
</div>
{% if item.note %}
<small class="text-danger ms-4">[ <b>{{ item.note }}</b> ]</small>
{% endif %}
{% if item.not_purchased_reason %}
<small class="text-dark ms-4">[ <b>Powód: {{ item.not_purchased_reason }}</b> ]</small>
{% endif %}
</div>
<div class="btn-group btn-group-sm" role="group">
{% if item.not_purchased %}
<button type="button" class="btn btn-outline-success"
{% if list.is_archived %}disabled{% else %}onclick="unmarkNotPurchased({{ item.id }})"{% endif %}>
✅ Przywróć
</button>
{% else %}
<button type="button" class="btn btn-outline-light"
{% if list.is_archived %}disabled{% else %}onclick="markNotPurchasedModal(event, {{ item.id }})"{% endif %}>
⚠️
</button>
<button type="button" class="btn btn-outline-light"
{% if list.is_archived %}disabled{% else %}onclick="openNoteModal(event, {{ item.id }})"{% endif %}>
📝
</button>
{% endif %}
</div>
<div class="btn-group btn-group-sm" role="group">
{% if item.not_purchased %}
<button type="button" class="btn btn-outline-success"
{% if list.is_archived %}disabled{% else %}onclick="unmarkNotPurchased({{ item.id }})"{% endif %}>
✅ Przywróć
</button>
{% else %}
<button type="button" class="btn btn-outline-light"
{% if list.is_archived %}disabled{% else %}onclick="markNotPurchasedModal(event, {{ item.id }})"{% endif %}>
⚠️
</button>
<button type="button" class="btn btn-outline-light"
{% if list.is_archived %}disabled{% else %}onclick="openNoteModal(event, {{ item.id }})"{% endif %}>
📝
</button>
{% endif %}
</div>
</li>
</li>
{% else %}
<li id="empty-placeholder"
class="list-group-item bg-dark text-secondary text-center w-100">
@@ -160,6 +162,9 @@
</div>
{% block scripts %}
<script>
window.IS_SHARE = true;
</script>
<script src="{{ url_for('static_bp.serve_js', filename='notes.js') }}"></script>
<script src="{{ url_for('static_bp.serve_js', filename='clickable_row.js') }}"></script>
<script src="{{ url_for('static_bp.serve_js', filename='receipt_section.js') }}"></script>