minor imprevements to history

This commit is contained in:
Ludovic Stephan 2016-12-11 23:22:59 -02:00
parent a9e1cd01db
commit ee54b36696

View file

@ -62,6 +62,8 @@
$(document).ready(function() {
settings = { 'subvention_cof': parseFloat({{ settings.subvention_cof|unlocalize }})}
lock = 0 ;
khistory = new KHistory();
var $from_date = $('#from_date');
@ -166,7 +168,10 @@ $(document).ready(function() {
function confirmCancel(opes_to_cancel) {
var nb = opes_to_cancel.length;
var content = nb+" opérations vont être annulées";
var content = nb+' opération'.pluralize(nb)
+' va'.pluralize(nb, ' vont')
+ ' être'
+ ' annulée'.pluralize(nb);
$.confirm({
title: 'Confirmation',
content: content,
@ -180,50 +185,10 @@ $(document).ready(function() {
});
}
function requestAuth(data, callback) {
var content = getErrorsHtml(data);
content += '<input type="password" name="password" autofocus>',
$.confirm({
title: 'Authentification requise',
content: content,
backgroundDismiss: true,
animation:'top',
closeAnimation:'bottom',
keyboardEnabled: true,
confirm: function() {
var password = this.$content.find('input').val();
callback(password);
},
onOpen: function() {
var that = this;
this.$content.find('input').on('keypress', function(e) {
if (e.keyCode == 13)
that.$confirmButton.click();
});
},
});
}
function getErrorsHtml(data) {
var content = '';
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']) {
var url_base = "{% url 'kfet.account.update' LIQ}";
url_base = base_url(0, url_base.length-8);
for (var i=0; i<data['errors']['negative'].length; i++) {
content += '<a class="btn btn-primary" href="'+url_base+data['errors']['negative'][i]+'/edit" target="_blank">Autorisation de négatif requise pour '+data['errors']['negative'][i]+'</a>';
}
}
return content;
}
function cancelOperations(opes_array, password = '') {
if (lock == 1)
return false
lock = 1 ;
var data = { 'operations' : opes_array }
$.ajax({
dataType: "json",
@ -239,6 +204,7 @@ $(document).ready(function() {
})
.done(function(data) {
khistory.$container.find('.ui-selected').removeClass('ui-selected');
lock = 0 ;
})
.fail(function($xhr) {
var data = $xhr.responseJSON;
@ -252,6 +218,7 @@ $(document).ready(function() {
displayErrors(getErrorsHtml(data));
break;
}
lock = 0 ;
});
}