Merge branch 'Aufinal/freeze_transferts' into 'k-fet'

Fix un freeze dans l'écran de tranfert

Vide l'input caché lorsque le trigramme correspondant est effacé ; effacer une ligne de transfert n'empêche plus de valider le groupe.

Note : ne fonctionne pas sur la première ligne ; à cause de la façon dont django gère le nombre minimal de forms, celle ci doit toujours être remplie.

Fix #98 

See merge request !118
This commit is contained in:
Aurélien Delobelle 2016-12-03 18:12:34 +01:00
commit 17f2202f0e

View file

@ -34,12 +34,12 @@
<tr class="transfer_form" id="{{ form.prefix }}"> <tr class="transfer_form" id="{{ form.prefix }}">
<td class="from_acc_data"></td> <td class="from_acc_data"></td>
<td class="from_acc"> <td class="from_acc">
<input type="text" name="from_acc" class="input_from_acc" autocomplete="off" spellcheck="false"> <input type="text" name="from_acc" class="input_from_acc" maxlength="3" autocomplete="off" spellcheck="false">
{{ form.from_acc }} {{ form.from_acc }}
</td> </td>
<td class="amount">{{ form.amount }}</td> <td class="amount">{{ form.amount }}</td>
<td class="to_acc"> <td class="to_acc">
<input type="text" name="to_acc" class="input_to_acc" autocomplete="off" spellcheck="false"> <input type="text" name="to_acc" class="input_to_acc" maxlength="3" autocomplete="off" spellcheck="false">
{{ form.to_acc }} {{ form.to_acc }}
</td> </td>
<td class="to_acc_data"></td> <td class="to_acc_data"></td>
@ -71,18 +71,21 @@ $(document).ready(function () {
var $next = $form.next('.transfer_form').find('.from_acc input'); var $next = $form.next('.transfer_form').find('.from_acc input');
} }
var $input_id = $input.next('input'); var $input_id = $input.next('input');
getAccountData(trigramme, function(data) { if (isValidTrigramme(trigramme)) {
$input_id.val(data.id); getAccountData(trigramme, function(data) {
$data.text(data.name); $input_id.val(data.id);
$next.focus(); $data.text(data.name);
}); $next.focus();
});
} else {
$input_id.val('');
$data.text('');
}
} }
$('.input_from_acc, .input_to_acc').on('input', function() { $('.input_from_acc, .input_to_acc').on('input', function() {
var tri = $(this).val().toUpperCase(); var tri = $(this).val().toUpperCase();
if (isValidTrigramme(tri)) { updateAccountData(tri, $(this));
updateAccountData(tri, $(this));
}
}); });
$('#transfers_form').on('submit', function(e) { $('#transfers_form').on('submit', function(e) {