mirror of https://gitlab.crans.org/bde/nk20
Filter buttons list with visible buttons only
This commit is contained in:
parent
2bc2048076
commit
5ea531fe68
|
@ -214,8 +214,7 @@ class RecurrentTransaction(Transaction):
|
|||
|
||||
template = models.ForeignKey(
|
||||
TransactionTemplate,
|
||||
null=True,
|
||||
on_delete=models.SET_NULL,
|
||||
on_delete=models.PROTECT,
|
||||
)
|
||||
category = models.ForeignKey(
|
||||
TemplateCategory,
|
||||
|
|
|
@ -129,13 +129,14 @@ class ButtonTable(tables.Table):
|
|||
'table table-bordered condensed table-hover'
|
||||
}
|
||||
row_attrs = {
|
||||
'class': lambda record: 'table-row ' + 'table-success' if record.display else 'table-danger',
|
||||
'class': lambda record: 'table-row ' + ('table-success' if record.display else 'table-danger'),
|
||||
'id': lambda record: "row-" + str(record.pk),
|
||||
'data-href': lambda record: record.pk
|
||||
}
|
||||
|
||||
model = TransactionTemplate
|
||||
exclude = ('id',)
|
||||
order_by = ('type', '-display', 'destination__name', 'name',)
|
||||
|
||||
edit = tables.LinkColumn('note:template_update',
|
||||
args=[A('pk')],
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-04-27 03:19+0200\n"
|
||||
"POT-Creation-Date: 2020-04-27 03:55+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -46,7 +46,7 @@ msgstr ""
|
|||
#: apps/activity/models.py:23 apps/activity/models.py:48
|
||||
#: apps/member/models.py:99 apps/member/models.py:202
|
||||
#: apps/note/models/notes.py:188 apps/note/models/transactions.py:24
|
||||
#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:237
|
||||
#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:236
|
||||
#: templates/member/club_info.html:13 templates/member/profile_info.html:14
|
||||
#: templates/registration/future_profile_detail.html:16
|
||||
msgid "name"
|
||||
|
@ -238,12 +238,12 @@ msgstr ""
|
|||
msgid "create"
|
||||
msgstr ""
|
||||
|
||||
#: apps/logs/models.py:61 apps/note/tables.py:144
|
||||
#: apps/logs/models.py:61 apps/note/tables.py:145
|
||||
#: templates/activity/activity_detail.html:67
|
||||
msgid "edit"
|
||||
msgstr ""
|
||||
|
||||
#: apps/logs/models.py:62 apps/note/tables.py:120 apps/note/tables.py:149
|
||||
#: apps/logs/models.py:62 apps/note/tables.py:120 apps/note/tables.py:150
|
||||
msgid "delete"
|
||||
msgstr ""
|
||||
|
||||
|
@ -672,33 +672,33 @@ msgstr ""
|
|||
msgid "Transfer"
|
||||
msgstr ""
|
||||
|
||||
#: apps/note/models/transactions.py:227
|
||||
#: apps/note/models/transactions.py:226
|
||||
msgid "Template"
|
||||
msgstr ""
|
||||
|
||||
#: apps/note/models/transactions.py:242
|
||||
#: apps/note/models/transactions.py:241
|
||||
msgid "first_name"
|
||||
msgstr ""
|
||||
|
||||
#: apps/note/models/transactions.py:247
|
||||
#: apps/note/models/transactions.py:246
|
||||
msgid "bank"
|
||||
msgstr ""
|
||||
|
||||
#: apps/note/models/transactions.py:253
|
||||
#: apps/note/models/transactions.py:252
|
||||
#: templates/activity/activity_entry.html:17
|
||||
#: templates/note/transaction_form.html:24
|
||||
msgid "Credit"
|
||||
msgstr ""
|
||||
|
||||
#: apps/note/models/transactions.py:253 templates/note/transaction_form.html:28
|
||||
#: apps/note/models/transactions.py:252 templates/note/transaction_form.html:28
|
||||
msgid "Debit"
|
||||
msgstr ""
|
||||
|
||||
#: apps/note/models/transactions.py:269 apps/note/models/transactions.py:274
|
||||
#: apps/note/models/transactions.py:268 apps/note/models/transactions.py:273
|
||||
msgid "membership transaction"
|
||||
msgstr ""
|
||||
|
||||
#: apps/note/models/transactions.py:270
|
||||
#: apps/note/models/transactions.py:269
|
||||
msgid "membership transactions"
|
||||
msgstr ""
|
||||
|
||||
|
@ -714,11 +714,11 @@ msgstr ""
|
|||
msgid "No reason specified"
|
||||
msgstr ""
|
||||
|
||||
#: apps/note/tables.py:122 apps/note/tables.py:151
|
||||
#: apps/note/tables.py:122 apps/note/tables.py:152
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
#: apps/note/tables.py:146 templates/member/club_info.html:55
|
||||
#: apps/note/tables.py:147 templates/member/club_info.html:55
|
||||
#: templates/note/conso_form.html:128
|
||||
msgid "Edit"
|
||||
msgstr ""
|
||||
|
@ -819,6 +819,7 @@ msgstr ""
|
|||
#: templates/activity/activity_invite.html:8
|
||||
#: templates/django_filters/rest_framework/form.html:5
|
||||
#: templates/member/add_members.html:14 templates/member/club_form.html:9
|
||||
#: templates/note/transactiontemplate_form.html:15
|
||||
#: templates/treasury/invoice_form.html:46
|
||||
msgid "Submit"
|
||||
msgstr ""
|
||||
|
@ -1306,22 +1307,30 @@ msgid "Current price"
|
|||
msgstr ""
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:9
|
||||
msgid "search button"
|
||||
msgid "Search button"
|
||||
msgstr ""
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:13
|
||||
#: templates/note/transactiontemplate_list.html:11
|
||||
msgid "Name of the button..."
|
||||
msgstr ""
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:16
|
||||
msgid "Display visible buttons only"
|
||||
msgstr ""
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:21
|
||||
msgid "New button"
|
||||
msgstr ""
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:20
|
||||
#: templates/note/transactiontemplate_list.html:28
|
||||
msgid "buttons listing "
|
||||
msgstr ""
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:70
|
||||
#: templates/note/transactiontemplate_list.html:86
|
||||
msgid "button successfully deleted "
|
||||
msgstr ""
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:74
|
||||
#: templates/note/transactiontemplate_list.html:90
|
||||
msgid "Unable to delete button "
|
||||
msgstr ""
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-04-27 03:19+0200\n"
|
||||
"POT-Creation-Date: 2020-04-27 03:55+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -42,7 +42,7 @@ msgstr "Vous ne pouvez pas inviter plus de 3 personnes à cette activité."
|
|||
#: apps/activity/models.py:23 apps/activity/models.py:48
|
||||
#: apps/member/models.py:99 apps/member/models.py:202
|
||||
#: apps/note/models/notes.py:188 apps/note/models/transactions.py:24
|
||||
#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:237
|
||||
#: apps/note/models/transactions.py:44 apps/note/models/transactions.py:236
|
||||
#: templates/member/club_info.html:13 templates/member/profile_info.html:14
|
||||
#: templates/registration/future_profile_detail.html:16
|
||||
msgid "name"
|
||||
|
@ -234,12 +234,12 @@ msgstr "Nouvelles données"
|
|||
msgid "create"
|
||||
msgstr "Créer"
|
||||
|
||||
#: apps/logs/models.py:61 apps/note/tables.py:144
|
||||
#: apps/logs/models.py:61 apps/note/tables.py:145
|
||||
#: templates/activity/activity_detail.html:67
|
||||
msgid "edit"
|
||||
msgstr "Modifier"
|
||||
|
||||
#: apps/logs/models.py:62 apps/note/tables.py:120 apps/note/tables.py:149
|
||||
#: apps/logs/models.py:62 apps/note/tables.py:120 apps/note/tables.py:150
|
||||
msgid "delete"
|
||||
msgstr "Supprimer"
|
||||
|
||||
|
@ -675,33 +675,33 @@ msgstr "transactions"
|
|||
msgid "Transfer"
|
||||
msgstr "Virement"
|
||||
|
||||
#: apps/note/models/transactions.py:227
|
||||
#: apps/note/models/transactions.py:226
|
||||
msgid "Template"
|
||||
msgstr "Bouton"
|
||||
|
||||
#: apps/note/models/transactions.py:242
|
||||
#: apps/note/models/transactions.py:241
|
||||
msgid "first_name"
|
||||
msgstr "prénom"
|
||||
|
||||
#: apps/note/models/transactions.py:247
|
||||
#: apps/note/models/transactions.py:246
|
||||
msgid "bank"
|
||||
msgstr "banque"
|
||||
|
||||
#: apps/note/models/transactions.py:253
|
||||
#: apps/note/models/transactions.py:252
|
||||
#: templates/activity/activity_entry.html:17
|
||||
#: templates/note/transaction_form.html:24
|
||||
msgid "Credit"
|
||||
msgstr "Crédit"
|
||||
|
||||
#: apps/note/models/transactions.py:253 templates/note/transaction_form.html:28
|
||||
#: apps/note/models/transactions.py:252 templates/note/transaction_form.html:28
|
||||
msgid "Debit"
|
||||
msgstr "Débit"
|
||||
|
||||
#: apps/note/models/transactions.py:269 apps/note/models/transactions.py:274
|
||||
#: apps/note/models/transactions.py:268 apps/note/models/transactions.py:273
|
||||
msgid "membership transaction"
|
||||
msgstr "Transaction d'adhésion"
|
||||
|
||||
#: apps/note/models/transactions.py:270
|
||||
#: apps/note/models/transactions.py:269
|
||||
msgid "membership transactions"
|
||||
msgstr "Transactions d'adhésion"
|
||||
|
||||
|
@ -717,11 +717,11 @@ msgstr "Cliquez pour valider"
|
|||
msgid "No reason specified"
|
||||
msgstr "Pas de motif spécifié"
|
||||
|
||||
#: apps/note/tables.py:122 apps/note/tables.py:151
|
||||
#: apps/note/tables.py:122 apps/note/tables.py:152
|
||||
msgid "Delete"
|
||||
msgstr "Supprimer"
|
||||
|
||||
#: apps/note/tables.py:146 templates/member/club_info.html:55
|
||||
#: apps/note/tables.py:147 templates/member/club_info.html:55
|
||||
#: templates/note/conso_form.html:128
|
||||
msgid "Edit"
|
||||
msgstr "Éditer"
|
||||
|
@ -824,6 +824,7 @@ msgstr "Trésorerie"
|
|||
#: templates/activity/activity_invite.html:8
|
||||
#: templates/django_filters/rest_framework/form.html:5
|
||||
#: templates/member/add_members.html:14 templates/member/club_form.html:9
|
||||
#: templates/note/transactiontemplate_form.html:15
|
||||
#: templates/treasury/invoice_form.html:46
|
||||
msgid "Submit"
|
||||
msgstr "Envoyer"
|
||||
|
@ -1317,22 +1318,30 @@ msgid "Current price"
|
|||
msgstr "Prix actuel"
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:9
|
||||
msgid "search button"
|
||||
msgid "Search button"
|
||||
msgstr "Chercher un bouton"
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:13
|
||||
#: templates/note/transactiontemplate_list.html:11
|
||||
msgid "Name of the button..."
|
||||
msgstr "Nom du bouton ..."
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:16
|
||||
msgid "Display visible buttons only"
|
||||
msgstr "N'afficher que les boutons visibles uniquement"
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:21
|
||||
msgid "New button"
|
||||
msgstr "Nouveau bouton"
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:20
|
||||
#: templates/note/transactiontemplate_list.html:28
|
||||
msgid "buttons listing "
|
||||
msgstr "Liste des boutons"
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:70
|
||||
#: templates/note/transactiontemplate_list.html:86
|
||||
msgid "button successfully deleted "
|
||||
msgstr "Le bouton a bien été supprimé"
|
||||
|
||||
#: templates/note/transactiontemplate_list.html:74
|
||||
#: templates/note/transactiontemplate_list.html:90
|
||||
msgid "Unable to delete button "
|
||||
msgstr "Impossible de supprimer le bouton "
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{form|crispy}}
|
||||
<button class="btn btn-primary" type="submit">Submit</button>
|
||||
<button class="btn btn-primary" type="submit">{% trans "Submit" %}</button>
|
||||
</form>
|
||||
|
||||
{% if price_history %}
|
||||
{% if price_history and price_history.1 %}
|
||||
<hr>
|
||||
|
||||
<h4>{% trans "Price history" %}</h4>
|
||||
|
|
|
@ -6,9 +6,17 @@
|
|||
<div class="row justify-content-center mb-4">
|
||||
<div class="col-md-10 text-center">
|
||||
<h4>
|
||||
{% trans "search button" %}
|
||||
{% trans "Search button" %}
|
||||
</h4>
|
||||
<input class="form-control mx-auto w-25" type="text" onkeyup="search_field_moved();return(false);" id="search_field"/>
|
||||
<input class="form-control mx-auto w-25" type="text" id="search_field" placeholder="{% trans "Name of the button..." %}">
|
||||
<div class="form-group">
|
||||
<div id="div_active_only" class="form-check">
|
||||
<label for="active_only" class="form-check-label">
|
||||
<input type="checkbox" name="active_only" class="checkboxinput form-check-input" id="active_only">
|
||||
{% trans "Display visible buttons only" %}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<a class="btn btn-primary text-center my-1" href="{% url 'note:template_create' %}">{% trans "New button" %}</a>
|
||||
</div>
|
||||
|
@ -29,50 +37,63 @@
|
|||
|
||||
{% block extrajavascript %}
|
||||
<script>
|
||||
/* fonction appelée à la fin du timer */
|
||||
function getInfo() {
|
||||
var asked = $("#search_field").val();
|
||||
/* on ne fait la requête que si on a au moins un caractère pour chercher */
|
||||
var sel = $(".table-row");
|
||||
if (asked.length >= 1) {
|
||||
$.getJSON("/api/note/transaction/template/?format=json&search="+asked, function(buttons){
|
||||
let selected_id = buttons.results.map((a => "#row-"+a.id));
|
||||
$(".table-row,"+selected_id.join()).show();
|
||||
$(".table-row").not(selected_id.join()).hide();
|
||||
|
||||
});
|
||||
}else{
|
||||
// show everything
|
||||
$('table tr').show();
|
||||
}
|
||||
}
|
||||
var timer;
|
||||
var timer_on;
|
||||
/* Fontion appelée quand le texte change (délenche le timer) */
|
||||
function search_field_moved(secondfield) {
|
||||
if (timer_on) { // Si le timer a déjà été lancé, on réinitialise le compteur.
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout("getInfo(" + secondfield + ")", 300);
|
||||
/* fonction appelée à la fin du timer */
|
||||
function getInfo() {
|
||||
var asked = $("#search_field").val();
|
||||
/* on ne fait la requête que si on a au moins un caractère pour chercher */
|
||||
if (asked.length >= 1) {
|
||||
$.getJSON("/api/note/transaction/template/?format=json&search=" + asked + ($("#active_only").is(":checked") ? "&display=true" : ""), function(buttons) {
|
||||
console.log(buttons);
|
||||
let selected_id = buttons.results.map((a => "#row-" + a.id));
|
||||
console.log(".table-row " + selected_id.join());
|
||||
$(".table-row " + selected_id.join()).removeClass('d-none');
|
||||
$(".table-row").not(selected_id.join()).addClass('d-none');
|
||||
});
|
||||
}
|
||||
else {
|
||||
if ($("#active_only").is(":checked")) {
|
||||
$('.table-success').removeClass('d-none');
|
||||
$('.table-danger').addClass('d-none');
|
||||
}
|
||||
else {
|
||||
// show everything
|
||||
$('table tr').removeClass('d-none');
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // Sinon, on le lance et on enregistre le fait qu'il tourne.
|
||||
timer = setTimeout("getInfo(" + secondfield + ")", 300);
|
||||
timer_on = true;
|
||||
|
||||
var timer;
|
||||
var timer_on;
|
||||
/* Fontion appelée quand le texte change (délenche le timer) */
|
||||
function search_field_moved() {
|
||||
if (timer_on) { // Si le timer a déjà été lancé, on réinitialise le compteur.
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(getInfo, 300);
|
||||
}
|
||||
else { // Sinon, on le lance et on enregistre le fait qu'il tourne.
|
||||
timer = setTimeout(getInfo, 300);
|
||||
timer_on = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// on click of button "delete" , call the API
|
||||
function delete_button(button_id){
|
||||
$.ajax({
|
||||
url:"/api/note/transaction/template/"+button_id+"/",
|
||||
method:"DELETE",
|
||||
headers: {"X-CSRFTOKEN": CSRF_TOKEN}
|
||||
})
|
||||
.done(function(){
|
||||
addMsg('{% trans "button successfully deleted "%}','success');
|
||||
$("#buttons_table").load("{% url 'note:template_list' %} #buttons_table");
|
||||
})
|
||||
.fail(function(){
|
||||
addMsg(' {% trans "Unable to delete button "%} #' + button_id,'danger' )
|
||||
});
|
||||
}
|
||||
// on click of button "delete" , call the API
|
||||
function delete_button(button_id) {
|
||||
$.ajax({
|
||||
url:"/api/note/transaction/template/"+button_id+"/",
|
||||
method:"DELETE",
|
||||
headers: {"X-CSRFTOKEN": CSRF_TOKEN}
|
||||
})
|
||||
.done(function(){
|
||||
addMsg('{% trans "button successfully deleted "%}','success');
|
||||
$("#buttons_table").load("{% url 'note:template_list' %} #buttons_table");
|
||||
})
|
||||
.fail(function(){
|
||||
addMsg(' {% trans "Unable to delete button "%} #' + button_id,'danger' )
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$("#search_field").keyup(search_field_moved);
|
||||
$("#active_only").change(search_field_moved);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in New Issue