Affichage des erreurs lors d'une commande
This commit is contained in:
parent
ee583c3cfb
commit
97b54deb5d
1 changed files with 45 additions and 2 deletions
|
@ -310,9 +310,11 @@ $(document).ready(function() {
|
|||
// -----
|
||||
|
||||
function requestAuth(data, callback) {
|
||||
var content = getErrorsHtml(data);
|
||||
content += '<input type="password" name="password" autofocus>',
|
||||
$.confirm({
|
||||
title: 'Authentification requise',
|
||||
content: '<input type="password" name="password" autofocus>',
|
||||
content: content,
|
||||
backgroundDismiss: true,
|
||||
animation:'top',
|
||||
closeAnimation:'bottom',
|
||||
|
@ -332,6 +334,44 @@ $(document).ready(function() {
|
|||
});
|
||||
}
|
||||
|
||||
// -----
|
||||
// Errors ajax
|
||||
// -----
|
||||
|
||||
function getErrorsHtml(data) {
|
||||
var content = '';
|
||||
if ('operation_group' in data['errors']) {
|
||||
content += 'Général';
|
||||
content += '<ul>';
|
||||
if (data['errors']['operation_group'].indexOf('on_acc') != -1)
|
||||
content += '<li>Pas de compte sélectionné</li>';
|
||||
if (data['errors']['operation_group'].indexOf('checkout') != -1)
|
||||
content += '<li>Pas de caisse sélectionnée</li>';
|
||||
content += '</ul>';
|
||||
}
|
||||
if ('missing_perms' in data['errors']) {
|
||||
content += 'Permissions manquantes';
|
||||
content += '<ul>';
|
||||
for (var i=0; i<data['errors']['missing_perms'].length; i++)
|
||||
content += '<li>'+data['errors']['missing_perms'][i]+'</li>';
|
||||
content += '</ul>';
|
||||
}
|
||||
if ('negative' in data['errors'])
|
||||
content += '<a class="btn btn-primary" href="/k-fet/accounts/'+account_data['trigramme']+'/edit" target="_blank">Autorisation de négatif requise</a>';
|
||||
return content;
|
||||
}
|
||||
|
||||
function displayErrors(html) {
|
||||
$.alert({
|
||||
title: 'Erreurs',
|
||||
content: html,
|
||||
backgroundDismiss: true,
|
||||
animation: 'top',
|
||||
closeAnimation: 'bottom',
|
||||
keyboardEnabled: true,
|
||||
});
|
||||
}
|
||||
|
||||
// -----
|
||||
// Perform operations
|
||||
// -----
|
||||
|
@ -362,6 +402,9 @@ $(document).ready(function() {
|
|||
case 403:
|
||||
requestAuth(data, performOperations);
|
||||
break;
|
||||
case 400:
|
||||
displayErrors(getErrorsHtml(data));
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -828,7 +871,7 @@ $(document).ready(function() {
|
|||
|
||||
operation_html
|
||||
.find('#id_form-__prefix__-type').val(type).end()
|
||||
.find('#id_form-__prefix__-amount').val(amount).end()
|
||||
.find('#id_form-__prefix__-amount').val((parseFloat(amount)).toFixed(2)).end()
|
||||
.find('#id_form-__prefix__-article').val(article).end()
|
||||
.find('#id_form-__prefix__-article_nb').val(article_nb).end()
|
||||
.find('#id_form-__prefix__-is_checkout').val(is_checkout);
|
||||
|
|
Loading…
Reference in a new issue