1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-02-24 17:11:18 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Nicolas Margulies
e479e1e3a4 Added messages for Hide/Show 2021-10-07 23:06:40 +02:00
Nicolas Margulies
82b0c83b1f Added a Hide/Show button for transaction templates, fixes #91 2021-10-07 22:54:01 +02:00
3 changed files with 97 additions and 43 deletions

View File

@ -4,7 +4,7 @@
import html
import django_tables2 as tables
from django.utils.html import format_html
from django.utils.html import format_html, mark_safe
from django_tables2.utils import A
from django.utils.translation import gettext_lazy as _
from note_kfet.middlewares import get_current_request
@ -197,6 +197,16 @@ class ButtonTable(tables.Table):
verbose_name=_("Edit"),
)
hideshow = tables.Column(
verbose_name= _("Hide/Show"),
accessor="pk",
attrs= {
'td': {
'class': 'col-sm-1',
'id': lambda record: "hideshow_" + str(record.pk),
}
})
delete_col = tables.TemplateColumn(template_code=DELETE_TEMPLATE,
extra_context={"delete_trans": _('delete')},
attrs={'td': {'class': 'col-sm-1'}},
@ -204,3 +214,13 @@ class ButtonTable(tables.Table):
def render_amount(self, value):
return pretty_money(value)
def render_hideshow(self, record):
val = '<button id="'
val += str(record.pk)
val += '" class="btn btn-secondary btn-sm" \
onclick="hideshow(' + str(record.id) + ',' + \
str(record.display).lower() + ')">'
val += str(_("Hide/Show"))
val += '</button>'
return mark_safe(val)

View File

@ -31,29 +31,29 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% block extrajavascript %}
<script type="text/javascript">
function refreshMatchedWords() {
$("tr").each(function() {
let pattern = $('#search_field').val();
if (pattern) {
$(this).find("td:eq(0), td:eq(1), td:eq(3), td:eq(6)").each(function () {
$(this).html($(this).text().replace(new RegExp(pattern, 'i'), "<mark>$&</mark>"));
});
}
});
}
function reloadTable() {
let pattern = $('#search_field').val();
$("#buttons_table").load(location.pathname + "?search=" + pattern.replace(" ", "%20") + " #buttons_table", refreshMatchedWords);
}
$(document).ready(function() {
let searchbar_obj = $("#search_field");
let timer_on = false;
let timer;
function refreshMatchedWords() {
$("tr").each(function() {
let pattern = searchbar_obj.val();
if (pattern) {
$(this).find("td:eq(0), td:eq(1), td:eq(3), td:eq(6)").each(function () {
$(this).html($(this).text().replace(new RegExp(pattern, 'i'), "<mark>$&</mark>"));
});
}
});
}
refreshMatchedWords();
function reloadTable() {
let pattern = searchbar_obj.val();
$("#buttons_table").load(location.pathname + "?search=" + pattern.replace(" ", "%20") + " #buttons_table", refreshMatchedWords);
}
searchbar_obj.keyup(function() {
if (timer_on)
clearTimeout(timer);
@ -77,5 +77,28 @@ SPDX-License-Identifier: GPL-3.0-or-later
addMsg('{% trans "Unable to delete button "%} #' + button_id, 'danger')
});
}
// on click of button "hide/show", call the API
function hideshow(id, displayed) {
$.ajax({
url: '/api/note/transaction/template/' + id + '/',
type: 'PATCH',
dataType: 'json',
headers: {
'X-CSRFTOKEN': CSRF_TOKEN
},
data: {
display: !displayed
},
success: function() {
if(displayed)
addMsg("{% trans "Button hidden"%}", 'success', 1000)
else addMsg("{% trans "Button displayed"%}", 'success', 1000)
reloadTable()
},
error: function (err) {
addMsg("{% trans "An error occured"%}", 'danger')
}})
}
</script>
{% endblock %}

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-09-28 17:02+0200\n"
"POT-Creation-Date: 2021-10-07 22:55+0200\n"
"PO-Revision-Date: 2020-11-16 20:02+0000\n"
"Last-Translator: Yohann D'ANELLO <ynerant@crans.org>\n"
"Language-Team: French <http://translate.ynerant.fr/projects/nk20/nk20/fr/>\n"
@ -279,7 +279,7 @@ msgstr "Prénom"
msgid "Note"
msgstr "Note"
#: apps/activity/tables.py:90 apps/member/tables.py:49
#: apps/activity/tables.py:90 apps/member/tables.py:50
msgid "Balance"
msgstr "Solde du compte"
@ -320,13 +320,13 @@ msgstr "Entrées"
msgid "Return to activity page"
msgstr "Retour à la page de l'activité"
#: apps/activity/templates/activity/activity_entry.html:89
#: apps/activity/templates/activity/activity_entry.html:124
#: apps/activity/templates/activity/activity_entry.html:94
#: apps/activity/templates/activity/activity_entry.html:129
msgid "Entry done, but caution: the user is not a Kfet member."
msgstr ""
"Entrée effectuée, mais attention : la personne n'est pas un adhérent Kfet."
#: apps/activity/templates/activity/activity_entry.html:127
#: apps/activity/templates/activity/activity_entry.html:132
msgid "Entry done!"
msgstr "Entrée effectuée !"
@ -404,33 +404,33 @@ msgstr "Créer une nouvelle activité"
msgid "Activities"
msgstr "Activités"
#: apps/activity/views.py:95
#: apps/activity/views.py:93
msgid "Activity detail"
msgstr "Détails de l'activité"
#: apps/activity/views.py:115
#: apps/activity/views.py:113
msgid "Update activity"
msgstr "Modifier l'activité"
#: apps/activity/views.py:142
#: apps/activity/views.py:140
msgid "Invite guest to the activity \"{}\""
msgstr "Invitation pour l'activité « {} »"
#: apps/activity/views.py:177
#: apps/activity/views.py:178
msgid "You are not allowed to display the entry interface for this activity."
msgstr ""
"Vous n'êtes pas autorisé à afficher l'interface des entrées pour cette "
"activité."
#: apps/activity/views.py:180
#: apps/activity/views.py:181
msgid "This activity does not support activity entries."
msgstr "Cette activité ne requiert pas d'entrées."
#: apps/activity/views.py:183
#: apps/activity/views.py:184
msgid "This activity is closed."
msgstr "Cette activité est fermée."
#: apps/activity/views.py:279
#: apps/activity/views.py:280
msgid "Entry for activity \"{}\""
msgstr "Entrées pour l'activité « {} »"
@ -466,7 +466,7 @@ msgstr "nouvelles données"
msgid "create"
msgstr "créer"
#: apps/logs/models.py:65 apps/note/tables.py:165 apps/note/tables.py:201
#: apps/logs/models.py:65 apps/note/tables.py:165 apps/note/tables.py:211
#: apps/permission/models.py:127 apps/treasury/tables.py:38
#: apps/wei/tables.py:74
msgid "delete"
@ -850,33 +850,33 @@ msgstr "l'adhésion commence le"
msgid "membership ends on"
msgstr "l'adhésion finit le"
#: apps/member/models.py:422
#: apps/member/models.py:428
#, python-brace-format
msgid "The role {role} does not apply to the club {club}."
msgstr "Le rôle {role} ne s'applique pas au club {club}."
#: apps/member/models.py:431 apps/member/views.py:651
#: apps/member/models.py:437 apps/member/views.py:651
msgid "User is already a member of the club"
msgstr "L'utilisateur est déjà membre du club"
#: apps/member/models.py:443 apps/member/views.py:660
#: apps/member/models.py:449 apps/member/views.py:660
msgid "User is not a member of the parent club"
msgstr "L'utilisateur n'est pas membre du club parent"
#: apps/member/models.py:496
#: apps/member/models.py:502
#, python-brace-format
msgid "Membership of {user} for the club {club}"
msgstr "Adhésion de {user} pour le club {club}"
#: apps/member/models.py:499 apps/note/models/transactions.py:389
#: apps/member/models.py:505 apps/note/models/transactions.py:389
msgid "membership"
msgstr "adhésion"
#: apps/member/models.py:500
#: apps/member/models.py:506
msgid "memberships"
msgstr "adhésions"
#: apps/member/tables.py:137
#: apps/member/tables.py:139
msgid "Renew"
msgstr "Renouveler"
@ -1535,7 +1535,7 @@ msgstr "Cliquez pour valider"
msgid "No reason specified"
msgstr "Pas de motif spécifié"
#: apps/note/tables.py:169 apps/note/tables.py:203 apps/treasury/tables.py:39
#: apps/note/tables.py:169 apps/note/tables.py:213 apps/treasury/tables.py:39
#: apps/treasury/templates/treasury/invoice_confirm_delete.html:30
#: apps/treasury/templates/treasury/sogecredit_detail.html:65
#: apps/wei/tables.py:75 apps/wei/tables.py:118
@ -1556,6 +1556,10 @@ msgstr "Supprimer"
msgid "Edit"
msgstr "Éditer"
#: apps/note/tables.py:201 apps/note/tables.py:224
msgid "Hide/Show"
msgstr "Afficher/Masquer"
#: apps/note/templates/note/conso_form.html:22
#: apps/note/templates/note/transaction_form.html:48
msgid "Please select a note"
@ -1685,6 +1689,18 @@ msgstr "le bouton a bien été supprimé "
msgid "Unable to delete button "
msgstr "Impossible de supprimer le bouton "
#: apps/note/templates/note/transactiontemplate_list.html:95
msgid "Button hidden"
msgstr "Bouton masqué"
#: apps/note/templates/note/transactiontemplate_list.html:96
msgid "Button displayed"
msgstr "Bouton affiché"
#: apps/note/templates/note/transactiontemplate_list.html:100
msgid "An error occured"
msgstr "Une erreur s'est produite"
#: apps/note/views.py:36
msgid "Transfer money"
msgstr "Transférer de l'argent"
@ -3501,8 +3517,3 @@ msgstr ""
"vous connecter. Vous devez vous rendre à la Kfet et payer les frais "
"d'adhésion. Vous devez également valider votre adresse email en suivant le "
"lien que vous avez reçu."
#~ msgid "You are not a Kfet member, so you can't use your note account."
#~ msgstr ""
#~ "Vous n'êtes pas adhérent Kfet, vous ne pouvez par conséquent pas utiliser "
#~ "votre compte note."