admin: fix rendering of FileInput

This commit is contained in:
Jens Langhammer 2020-11-29 19:40:28 +01:00
parent 0a2c0464df
commit 5c5adfcccc
6 changed files with 18 additions and 17 deletions

View file

@ -31,6 +31,7 @@ class ApplicationForm(forms.ModelForm):
"name": forms.TextInput(),
"meta_launch_url": forms.TextInput(),
"meta_publisher": forms.TextInput(),
"meta_icon": forms.FileInput(),
}
help_texts = {
"meta_launch_url": _(

View file

@ -57,7 +57,7 @@
{% endif %}
</div>
</div>
{% elif field.field.widget|fieldtype == "ClearableFileInput" %}
{% elif field.field.widget|fieldtype == "FileInput" %}
<div class="pf-c-form__group-label">
<label class="pf-c-form__label" for="{{ field.name }}-{{ forloop.counter0 }}">
<span class="pf-c-form__label-text">{{ field.label }}</span>
@ -68,13 +68,17 @@
</div>
<div class="pf-c-form__group-control">
<div class="c-form__horizontal-group">
<div class="pf-c-file-upload">
<div class="pf-c-file-upload__file-select">
<div class="pf-c-input-group">
{{ field|css_class:"pf-c-form-control" }}
</div>
</div>
</div>
{% if field.help_text %}
<p class="pf-c-form__helper-text">{{ field.help_text|safe }}</p>
{% endif %}
{% if field.value %}
<a target="_blank" href="{{ field.value.url }}" class="pf-c-form__helper-text">
{% blocktrans with current=field.value %}
Currently set to {{current}}.
{% endblocktrans %}
</a>
{% endif %}
</div>
</div>
{% else %}

View file

@ -95,13 +95,6 @@ def form_verbose_name(obj) -> str:
return verbose_name(obj._meta.model)
@register.filter
def debug(obj) -> str:
"""Output object to logger"""
LOGGER.debug(obj)
return ""
@register.filter
def doc(obj) -> str:
"""Return docstring of object"""

2
web/dist/main.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -52,6 +52,9 @@ export class ModalButton extends LitElement {
updateHandlers() {
// Ensure links close the modal
this.querySelectorAll<HTMLAnchorElement>("[slot=modal] a").forEach((a) => {
if (a.target == "_blank") {
return;
}
// Make click on a close the modal
a.addEventListener("click", (e) => {
e.preventDefault();