forked from DGNum/gestioCOF
Use api_with_auth in history
This commit is contained in:
parent
07290f6fec
commit
a173be4f7d
1 changed files with 5 additions and 35 deletions
|
@ -74,14 +74,7 @@ class History {
|
|||
});
|
||||
}
|
||||
|
||||
//TODO: permission management in another class ?
|
||||
//TODO: idem for confirmation
|
||||
cancel_operations(to_cancel, password='') {
|
||||
if (lock == 1)
|
||||
return false;
|
||||
lock = 1;
|
||||
var that = this;
|
||||
|
||||
if (window.kpsul) {
|
||||
var on_success = kpsul._env.coolReset;
|
||||
var focus_next = kpsul.account_manager._$input_trigramme;
|
||||
|
@ -91,35 +84,12 @@ class History {
|
|||
var focus_next = undefined;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url : Urls['kfet.kpsul.cancel_operations'](),
|
||||
method : "POST",
|
||||
data : to_cancel,
|
||||
beforeSend: function ($xhr) {
|
||||
$xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
||||
if (password != '')
|
||||
$xhr.setRequestHeader("KFetPassword", password);
|
||||
},
|
||||
api_with_auth({
|
||||
url: Urls['kfet.kpsul.cancel_operations'](),
|
||||
data: to_cancel,
|
||||
on_success: on_success,
|
||||
focus_next: focus_next,
|
||||
})
|
||||
.done(function(data) {
|
||||
on_success();
|
||||
lock = 0;
|
||||
})
|
||||
.fail(function($xhr) {
|
||||
var data = $xhr.responseJSON;
|
||||
switch ($xhr.status) {
|
||||
case 403:
|
||||
requestAuth(data, function(password) {
|
||||
cancelOperations(to_cancel, password);
|
||||
}, focus_next);
|
||||
break;
|
||||
case 400:
|
||||
displayErrors(getErrorsHtml(data));
|
||||
break;
|
||||
}
|
||||
lock = 0;
|
||||
});
|
||||
}
|
||||
|
||||
add_node(data) {
|
||||
|
|
Loading…
Reference in a new issue