# 86 Comment field length

* removes comment field length limit
* adds improvements for rendering large comments
This commit is contained in:
mpeltriaux 2022-02-02 12:54:45 +01:00
parent 1eecc5fa48
commit edad33e662
15 changed files with 91 additions and 27 deletions

View File

@ -346,10 +346,9 @@ class NewActionModalForm(BaseModalForm):
)
comment = forms.CharField(
required=False,
max_length=200,
label=_("Comment"),
label_suffix=_(""),
help_text=_("Additional comment, maximum {} letters").format(200),
help_text=_("Additional comment"),
widget=forms.Textarea(
attrs={
"rows": 5,

View File

@ -1,4 +1,5 @@
{% load i18n l10n fontawesome_5 humanize %}
{% load i18n l10n fontawesome_5 humanize ksp_filters %}
<div id="actions" class="card">
<div class="card-header rlp-r">
<div class="row">
@ -55,7 +56,11 @@
{% endfor %}
</td>
<td class="align-middle">{{ action.amount|floatformat:2|intcomma }} {{ action.unit_humanize }}</td>
<td class="align-middle">{{ action.comment|default_if_none:"" }}</td>
<td class="align-middle">
<div class="scroll-150">
{{ action.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:action-remove' obj.id action.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove action' %}">

View File

@ -47,7 +47,11 @@
{% trans deadline.type_humanized %}
</td>
<td class="align-middle">{{ deadline.date|default_if_none:"---" }}</td>
<td class="align-middle">{{ deadline.comment }}</td>
<td class="align-middle">
<div class="scroll-150">
{{ deadline.comment }}
</div>
</td>
<td>
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:deadline-remove' obj.id deadline.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove deadline' %}">

View File

@ -45,8 +45,12 @@
{{ doc.title }}
</a>
</td>
<td class="align-middle">{{ doc.comment }}</td>
<td>
<td class="align-middle">
<div class="scroll-150">
{{ doc.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:remove-doc' doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove document' %}">
{% fa5_icon 'trash' %}

View File

@ -1,4 +1,4 @@
{% load i18n l10n fontawesome_5 humanize %}
{% load i18n l10n fontawesome_5 humanize ksp_filters %}
<div id="actions" class="card">
<div class="card-header rlp-r">
<div class="row">
@ -36,7 +36,7 @@
<th scope="col">
{% trans 'Comment' %}
</th>
{% if default_member and has_access %}
{% if is_default_member and has_access %}
<th scope="col">
{% trans 'Action' %}
</th>
@ -55,7 +55,11 @@
{% endfor %}
</td>
<td class="align-middle">{{ action.amount|floatformat:2|intcomma }} {{ action.unit_humanize }}</td>
<td class="align-middle">{{ action.comment|default_if_none:"" }}</td>
<td class="align-middle">
<div class="scroll-150">
{{ action.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:acc:action-remove' obj.id action.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove action' %}">

View File

@ -45,8 +45,12 @@
{% trans deadline.type_humanized %}
</td>
<td class="align-middle">{{ deadline.date|default_if_none:"---" }}</td>
<td class="align-middle">{{ deadline.comment }}</td>
<td>
<td class="align-middle">
<div class="scroll-150">
{{ deadline.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:acc:deadline-remove' obj.id deadline.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove deadline' %}">
{% fa5_icon 'trash' %}

View File

@ -43,8 +43,12 @@
{{ doc.title }}
</a>
</td>
<td class="align-middle">{{ doc.comment }}</td>
<td>
<td class="align-middle">
<div class="scroll-150">
{{ doc.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:acc:remove-doc' doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove document' %}">
{% fa5_icon 'trash' %}

View File

@ -1,4 +1,4 @@
{% load i18n l10n fontawesome_5 humanize %}
{% load i18n l10n fontawesome_5 humanize ksp_filters %}
<div id="actions" class="card">
<div class="card-header rlp-r">
<div class="row">
@ -53,7 +53,11 @@
{% endfor %}
</td>
<td class="align-middle">{{ action.amount|floatformat:2|intcomma }} {{ action.unit_humanize }}</td>
<td class="align-middle">{{ action.comment|default_if_none:"" }}</td>
<td class="align-middle">
<div class="scroll-150">
{{ action.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'ema:action-remove' obj.id action.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove action' %}">

View File

@ -45,8 +45,12 @@
{% trans deadline.type_humanized %}
</td>
<td class="align-middle">{{ deadline.date|default_if_none:"---" }}</td>
<td class="align-middle">{{ deadline.comment }}</td>
<td>
<td class="align-middle">
<div class="scroll-150">
{{ deadline.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'ema:deadline-remove' obj.id deadline.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove deadline' %}">
{% fa5_icon 'trash' %}

View File

@ -43,8 +43,12 @@
{{ doc.title }}
</a>
</td>
<td class="align-middle">{{ doc.comment }}</td>
<td>
<td class="align-middle">
<div class="scroll-150">
{{ doc.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'ema:remove-doc' doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove document' %}">
{% fa5_icon 'trash' %}

View File

@ -45,8 +45,12 @@
{{ doc.title }}
</a>
</td>
<td class="align-middle">{{ doc.comment }}</td>
<td>
<td class="align-middle">
<div class="scroll-150">
{{ doc.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'intervention:remove-doc' doc.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove document' %}">
{% fa5_icon 'trash' %}

View File

@ -47,8 +47,12 @@
{{ pay.amount|floatformat:2 }} €
</td>
<td class="align-middle">{{ pay.due_on|default_if_none:"---" }}</td>
<td class="align-middle">{{ pay.comment }}</td>
<td>
<td class="align-middle">
<div class="scroll-150">
{{ pay.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'compensation:pay:remove' pay.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove payment' %}">
{% fa5_icon 'trash' %}

View File

@ -56,8 +56,12 @@
</a>
{% endif %}
</td>
<td class="align-middle">{{ rev.comment }}</td>
<td>
<td class="align-middle">
<div class="scroll-150">
{{ rev.comment }}
</div>
</td>
<td class="align-middle">
{% if is_default_member and has_access %}
<button data-form-url="{% url 'intervention:remove-revocation' rev.id %}" class="btn btn-default btn-modal" title="{% trans 'Remove revocation' %}">
{% fa5_icon 'trash' %}

View File

@ -52,3 +52,19 @@ def default_if_zero(val1, val2):
"""
return val1 if val1 > 0 else val2
@register.filter("shorten")
def shorten(val, length):
""" Returns val shortened to the first number of length character
Args:
val (str): The value
length (int): The number of characters left
Returns:
"""
if val is not None and len(val) > length:
val = f"{val[:length]}..."
return val

View File

@ -23,7 +23,7 @@
{% include 'navbars/navbar.html' %}
{% endblock %}
</header>
<div class="container-fluid mt-3 px-5">
<div class="container-fluid mt-3">
<div class="">
{% for message in messages %}
<div class="row alert alert-{{ message.tags }}">