Auto-complete first and last name for credits and debits

This commit is contained in:
Yohann D'ANELLO 2020-03-14 15:36:03 +01:00 committed by Bombar Maxime
parent 040bb27528
commit 717891869d
4 changed files with 26 additions and 10 deletions

View File

@ -28,8 +28,7 @@ class TransactionCreate(LoginRequiredMixin, TemplateView):
Add some context variables in template such as page title Add some context variables in template such as page title
""" """
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context['title'] = _('Transfer money from your account ' context['title'] = _('Transfer money')
'to one or others')
context['polymorphic_ctype'] = ContentType.objects.get_for_model(Transaction).pk context['polymorphic_ctype'] = ContentType.objects.get_for_model(Transaction).pk
context['special_polymorphic_ctype'] = ContentType.objects.get_for_model(SpecialTransaction).pk context['special_polymorphic_ctype'] = ContentType.objects.get_for_model(SpecialTransaction).pk
context['special_types'] = NoteSpecial.objects.order_by("special_type").all() context['special_types'] = NoteSpecial.objects.order_by("special_type").all()

View File

@ -443,7 +443,7 @@ msgid "membership transactions"
msgstr "" msgstr ""
#: apps/note/views.py:29 #: apps/note/views.py:29
msgid "Transfer money from your account to one or others" msgid "Transfer money"
msgstr "" msgstr ""
#: apps/note/views.py:139 #: apps/note/views.py:139

View File

@ -456,8 +456,8 @@ msgid "membership transactions"
msgstr "transactions d'adhésion" msgstr "transactions d'adhésion"
#: apps/note/views.py:29 #: apps/note/views.py:29
msgid "Transfer money from your account to one or others" msgid "Transfer money"
msgstr "Transfert d'argent de ton compte vers un ou plusieurs autres" msgstr "Transferts d'argent"
#: note_kfet/settings/__init__.py:63 #: note_kfet/settings/__init__.py:63
msgid "" msgid ""

View File

@ -9,7 +9,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
<div class="row"> <div class="row">
<div class="col-xl-12"> <div class="col-xl-12">
<div class="btn-group btn-group-toggle" style="width: 100%" data-toggle="buttons"> <div class="btn-group btn-group-toggle" style="width: 100%; padding: 0 0 2em 0" data-toggle="buttons">
<label class="btn btn-sm btn-outline-primary active"> <label class="btn btn-sm btn-outline-primary active">
<input type="radio" name="transaction_type" id="type_gift" checked> <input type="radio" name="transaction_type" id="type_gift" checked>
Virement Virement
@ -93,7 +93,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
<div class="col-md-12" id="dests_div"> <div class="col-md-12" id="dests_div">
<div class="card border-info shadow mb-4"> <div class="card border-info shadow mb-4">
<div class="card-header"> <div class="card-header">
<p class="card-text font-weight-bold"> <p class="card-text font-weight-bold" id="dest_title">
Sélection des destinataires Sélection des destinataires
</p> </p>
</div> </div>
@ -153,34 +153,51 @@ SPDX-License-Identifier: GPL-2.0-or-later
} }
$(document).ready(function() { $(document).ready(function() {
autoCompleteNote("source_note", "source_alias_matched", "source_note_list", sources, sources_notes_display, autoCompleteNote("source_note", "source_alias_matched", "source_note_list", sources, sources_notes_display,
"source_alias", "source_note"); "source_alias", "source_note");
autoCompleteNote("dest_note", "dest_alias_matched", "dest_note_list", dests, dests_notes_display, autoCompleteNote("dest_note", "dest_alias_matched", "dest_note_list", dests, dests_notes_display,
"dest_alias", "dest_note"); "dest_alias", "dest_note", null, null, function() {
let last = dests_notes_display[dests_notes_display.length - 1];
dests_notes_display.length = 0;
dests_notes_display.push(last);
last[3] = 1;
$.getJSON("/api/user/" + last[2].user + "/", function(user) {
$("#last_name").val(user.last_name);
$("#first_name").val(user.first_name);
});
return true;
});
}); });
$("#type_gift").click(function() { $("#type_gift").click(function() {
$("#emitters_div").hide(); $("#emitters_div").hide();
$("#external_div").hide(); $("#external_div").hide();
$("#dests_div").attr('class', 'col-md-12'); $("#dests_div").attr('class', 'col-md-12');
$("#dest_title").text("Sélection des destinataires");
}); });
$("#type_transfer").click(function() { $("#type_transfer").click(function() {
$("#emitters_div").show(); $("#emitters_div").show();
$("#external_div").hide(); $("#external_div").hide();
$("#dests_div").attr('class', 'col-md-6'); $("#dests_div").attr('class', 'col-md-6');
$("#dest_title").text("Sélection des destinataires");
}); });
$("#type_credit").click(function() { $("#type_credit").click(function() {
$("#emitters_div").hide(); $("#emitters_div").hide();
$("#external_div").show(); $("#external_div").show();
$("#dests_div").attr('class', 'col-md-6'); $("#dests_div").attr('class', 'col-md-6');
$("#dest_title").text("Note à créditer");
}); });
$("#type_debit").click(function() { $("#type_debit").click(function() {
$("#emitters_div").hide(); $("#emitters_div").hide();
$("#external_div").show(); $("#external_div").show();
$("#dests_div").attr('class', 'col-md-6'); $("#dests_div").attr('class', 'col-md-6');
$("#dest_title").text("Note à prélever");
}); });
$("#transfer").click(function() { $("#transfer").click(function() {