Files
fln-django-template/templates/pages/dashboard.html
2026-03-01 07:03:16 +07:00

141 lines
6.7 KiB
HTML

{% extends 'base.html' %}
{% load static custom_filters %}
<!-- [ Main Content ] start -->
{% block content %}
{% if card_title %}
<div class="row mt-3">
<div class="col-12 mb-4">
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{% if card_title %}
<div class="card shadow-lg border-0">
<div class="card-body p-5">
<div class="d-flex justify-content-between align-items-center border-bottom pb-2 mb-4">
<h6 class="fw-bold mb-0">
{{ card_title }}
</h6>
</div>
<div class="row g-4 mb-4">
{% for field in form %}
<div class="col-12 col-md-6">
<label for="{{ field.id_for_label }}" class="form-label fw-semibold">
{{ field.label }}
</label>
{{ field }}
{% if field.help_text %}
<div class="form-text ms-1">
{{ field.help_text }}
</div>
{% endif %}
{# HANYA tampilkan preview jika ini adalah field image #}
{% if field.name == 'image' and enable_preview_image %}
<div class="mt-2">
{% if item.image %}
<img id="preview" src="{{ item.image.url }}" class="img-thumbnail w-25" alt="Preview">
{% else %}
<img id="preview" src="{% static 'images/placeholder.jpg' %}" class="img-thumbnail w-25" alt="Default">
{% endif %}
</div>
{% endif %}
</div>
{% endfor %}
</div>
<hr class="my-5">
<div class="d-flex justify-content-between align-items-center">
<div>
{% if item %}
<button class="btn bz-btn-outline-primary btn-bz-size" onclick="window.history.back();">Cancel</button>
{% endif %}
<button type="submit" name="action" value="save" class="btn bz-btn-primary btn-bz-size">Submit</button>
</div>
<div>
{{ buttons_action|safe }}
</div>
</div>
</div>
</div>
{% endif %}
</form>
</div>
</div>
{% endif %}
{% if items %}
<div class="row mt-3">
<div class="col-12 mb-4">
<div class="card shadow-lg border-0">
<div class="card-body p-5">
<div class="d-flex justify-content-between align-items-center border-bottom pb-2 mb-4">
<h6 class="fw-bold mb-0">
List View
</h6>
{{ top_dropdown|safe }}
</div>
<div class="table-responsive">
<table class="table table-hover table-bordered tableDatatables w-100">
<thead>
<tr class="align-middle">
<th class="mw-25">No.</th>
{% for key, value in fields.items %}
<th>{{ value }}</th>
{% endfor %}
<th style="width:10%">Action</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>{{ forloop.counter }}</td>
{% for field in fields %}
{% if field == 'image' %}
<td style="width: 150px;">
<img id="imagePreview" src="{% if item.image %}{{ item.image.url }}{% else %}{% static 'images/placeholder.jpg' %}{% endif %}" class="img-thumbnail" alt="Preview">
</td>
{% else %}
<td>
{{ item|get_field_value:field|safe }}
{% if field == 'location' %}
{% if item.maps_location %}
<div class="mt-1">
{# Hilangkan |urlencode jika datanya sudah berupa link utuh #}
<a href="{{ item.maps_location }}"
target="_blank"
class="btn btn-link btn-sm p-0 text-decoration-none"
style="font-size: 0.75rem;">
View on Maps
</a>
</div>
{% endif %}
{% elif field == 'event_name' %}
{{ item.copy_link }}
{% endif %}
</td>
{% endif %}
{% endfor %}
<td>
{% if item.buttons_action %}
<button type="button" class="btn btn-warning btn-bz-size dropdown-toggle" data-bs-toggle="collapse" data-bs-target="#act-{{ item.id }}">Options </button>
<div id="act-{{ item.id }}" class="collapse mt-1">
{% for value in item.buttons_action %}
{{ value|safe }}
{% endfor %}
</div>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock content %}