[FIX] BASE: #604

This commit is contained in:
Horilla
2025-03-26 14:02:20 +05:30
parent 681f4f87d8
commit 416fde56c4
7 changed files with 77 additions and 17 deletions

View File

@@ -1,33 +1,35 @@
{% load i18n %}
{% if messages %}
<script>reloadMessage();</script>
<span hx-get="{% url 'announcement-single-view' form.instance.id %}?instance_ids={{instance_ids}}" hx-target="#objectDetailsModalTarget" hx-trigger="load">
<span hx-get="{% url 'announcement-single-view' form.instance.id %}?instance_ids={{instance_ids}}"
hx-target="#objectDetailsModalTarget" hx-trigger="load"></span>
<span hx-get="{% url 'announcement-list' %}" hx-trigger="load" hx-target="#announcementListCard"
hx-on-htmx-after-request="setTimeout(() => {$('.oh-modal_close--custom').click();}, 500);"></span>
{% endif %}
{% if form.errors %}
<!-- form errors -->
<div class="oh-wrapper">
<div class="oh-alert-container">
{% for error in form.non_field_errors %}
<div class="oh-alert oh-alert--animated oh-alert--danger">
{{ error }}
<div class="oh-wrapper">
<div class="oh-alert-container">
{% for error in form.non_field_errors %}
<div class="oh-alert oh-alert--animated oh-alert--danger">
{{ error }}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
</div>
{% endif %}
<div class="oh-modal__dialog-header">
<h5 class="oh-modal__dialog-title" id="announcementUpdateModalLabel">{% trans "Edit Announcement." %}</span>
<h5 class="oh-modal__dialog-title" id="announcementUpdateModalLabel">{% trans "Update" %} {{form.verbose_name}}
<button type="button" class="oh-modal_close--custom"
onclick="$(this).closest('.oh-modal--show').removeClass('oh-modal--show');">
<ion-icon name="close-outline" role="img" aria-label="close outline"></ion-icon>
</button>
</div>
<div class="oh-modal__dialog-body">
<form hx-post="{% url 'update-announcement' form.instance.id %}?instance_ids={{instance_ids}}" hx-target="#objectUpdateModalTarget"
hx-encoding="multipart/form-data" class="oh-profile-section">
<form hx-post="{{request.get_full_path}}" hx-target="#{{hx_target}}" hx-encoding="multipart/form-data"
class="oh-profile-section">
{% csrf_token %}
{{form.as_p}}
<div class="d-flex flex-row-reverse">

View File

@@ -0,0 +1,49 @@
{% load static %}
{% load i18n %}
{% load widget_tweaks %}
<div class="oh-profile-section__card">
<div class="row">
<div class="col-12">{{ form.non_field_errors }}</div>
{% for field in form.visible_fields %}
<div class="col-12" id="id_{{field.name}}_parent_div">
<div class="oh-label__info" for="id_{{ field.name }}">
<label class="oh-label {% if field.field.required %} required-star{% endif %}"
for="id_{{ field.name }}">{% trans field.label %}</label>
{% if field.help_text != '' %}
<span class="oh-info mr-2" title="{{ field.help_text|safe }}"></span>
{% endif %}
</div>
{% if field.field.widget.input_type == 'checkbox' %}
<div class="oh-switch" style="width: 30px;">{{ field|add_class:'oh-switch__checkbox' }}</div>
{% else %}
{{ field|add_class:'form-control' }}
{% endif %}
{{ field.errors }}
{% if field.name == "attachments" and field.field.widget.input_type == "file" and field.field.widget.attrs.multiple %}
{% if form.instance.pk %}
<div class="d-flex mt-2 mb-2">
{% for file in form.instance.attachments.all %}
<a href="{{ file.file.url }}" rel="noopener noreferrer" target="_blank"
id="objectFileItem{{ file.id }}">
<span class="oh-file-icon oh-file-icon--pdf"
onmouseover="enlargeImage('{{ file.file.url }}',$(this))" style="width: 40px; height: 40px">
<img src="{% static 'images/ui/minus-icon.png' %}"
style="display: block; width: 50%; height: 50%"
hx-confirm="{% trans 'Are you sure do you want to delete this file ?' %}"
hx-post="{% url 'remove-announcement-file' form.instance.pk file.id %}"
hx-target="#objectFileItem{{ file.id }}"
hx-swap="outerHTML"
onclick="event.stopPropagation();event.preventDefault()" />
</span>
</a>
{% endfor %}
</div>
{% endif %}
{% endif %}
</div>
{% endfor %}
</div>
{% for field in form.hidden_fields %}
{{ field }}
{% endfor %}
</div>

View File

@@ -399,5 +399,4 @@
if (!localStorageroratingWorkTypeCells) {
$("#roratingWorkTypeCells").find("[type=checkbox]").prop("checked", true);
}
$("[type=checkbox]").change();
</script>