Remove deprecated history functions
This commit is contained in:
parent
5c9c206f68
commit
14b922634d
1 changed files with 6 additions and 121 deletions
|
@ -157,9 +157,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="history2">
|
||||
</div>
|
||||
|
||||
<form id="operationgroup_form" style="display:none;">{{ operationgroup_form }}</form>
|
||||
<form id="operation_formset" style="display:none;">{{ operation_formset }}</form>
|
||||
|
||||
|
@ -299,55 +296,6 @@ $(document).ready(function() {
|
|||
performOperations();
|
||||
});
|
||||
|
||||
// -----
|
||||
// Cancel operations
|
||||
// -----
|
||||
|
||||
var cancelButton = $('#cancel_operations');
|
||||
var cancelForm = $('#cancel_form');
|
||||
|
||||
function cancelOperations(opes_array, password = '') {
|
||||
if (lock == 1)
|
||||
return false
|
||||
lock = 1;
|
||||
var data = { 'operations' : opes_array }
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url : "{% url 'kfet.kpsul.cancel_operations' %}",
|
||||
method : "POST",
|
||||
data : data,
|
||||
beforeSend: function ($xhr) {
|
||||
$xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
||||
if (password != '')
|
||||
$xhr.setRequestHeader("KFetPassword", password);
|
||||
},
|
||||
|
||||
})
|
||||
.done(function(data) {
|
||||
coolReset();
|
||||
lock = 0;
|
||||
})
|
||||
.fail(function($xhr) {
|
||||
var data = $xhr.responseJSON;
|
||||
switch ($xhr.status) {
|
||||
case 403:
|
||||
requestAuth(data, function(password) {
|
||||
cancelOperations(opes_array, password);
|
||||
}, account_manager._$input_trigramme);
|
||||
break;
|
||||
case 400:
|
||||
displayErrors(getErrorsHtml(data));
|
||||
break;
|
||||
}
|
||||
lock = 0;
|
||||
});
|
||||
}
|
||||
|
||||
// Event listeners
|
||||
cancelButton.on('click', function() {
|
||||
cancelOperations();
|
||||
});
|
||||
|
||||
// -----
|
||||
// Articles data
|
||||
// -----
|
||||
|
@ -625,29 +573,6 @@ $(document).ready(function() {
|
|||
formset_container.find('#id_form-'+opeindex+'-DELETE').prop('checked', true);
|
||||
}
|
||||
|
||||
// -----
|
||||
// History
|
||||
// -----
|
||||
|
||||
var khistory = new KHistory();
|
||||
|
||||
function getHistory() {
|
||||
var data = {
|
||||
from: moment().subtract(1, 'days').format('YYYY-MM-DD HH:mm:ss'),
|
||||
};
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url : "{% url 'kfet.history.json' %}",
|
||||
method : "POST",
|
||||
data : data,
|
||||
})
|
||||
.done(function(data) {
|
||||
for (var i=0; i<data['opegroups'].length; i++) {
|
||||
khistory.addOpeGroup(data['opegroups'][i]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var previousop_container = $('#previous_op');
|
||||
|
||||
function updatePreviousOp() {
|
||||
|
@ -738,36 +663,6 @@ $(document).ready(function() {
|
|||
}
|
||||
|
||||
|
||||
// -----
|
||||
// Cancel from history
|
||||
// -----
|
||||
|
||||
khistory.$container.selectable({
|
||||
filter: 'div.opegroup, div.ope',
|
||||
selected: function(e, ui) {
|
||||
$(ui.selected).each(function() {
|
||||
if ($(this).hasClass('opegroup')) {
|
||||
var opegroup = $(this).data('opegroup');
|
||||
$(this).siblings('.ope').filter(function() {
|
||||
return $(this).data('opegroup') == opegroup
|
||||
}).addClass('ui-selected');
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
$(document).on('keydown', function (e) {
|
||||
if (e.keyCode == 46) {
|
||||
// DEL (Suppr)
|
||||
var opes_to_cancel = [];
|
||||
khistory.$container.find('.ope.ui-selected').each(function () {
|
||||
opes_to_cancel.push($(this).data('type')+' '+$(this).data('id'));
|
||||
});
|
||||
if (opes_to_cancel.length > 0)
|
||||
cancelOperations(opes_to_cancel);
|
||||
}
|
||||
});
|
||||
|
||||
// -----
|
||||
// Synchronization
|
||||
// -----
|
||||
|
@ -781,29 +676,19 @@ $(document).ready(function() {
|
|||
socket.onmessage = function(e) {
|
||||
var data = $.extend({}, websocket_msg_default, JSON.parse(e.data));
|
||||
|
||||
for (var i=0; i<data['opegroups'].length; i++) {
|
||||
if (data['opegroups'][i]['add']) {
|
||||
khistory.addOpeGroup(data['opegroups'][i]);
|
||||
} else if (data['opegroups'][i]['cancellation']) {
|
||||
khistory.cancelOpeGroup(data['opegroups'][i]);
|
||||
}
|
||||
}
|
||||
for (var i=0; i<data['opes'].length; i++) {
|
||||
if (data['opes'][i]['cancellation']) {
|
||||
khistory.cancelOpe(data['opes'][i]);
|
||||
}
|
||||
}
|
||||
kpsul.history.update_data(data);
|
||||
|
||||
for (var i=0; i<data['checkouts'].length; i++) {
|
||||
if (checkout_data['id'] == data['checkouts'][i]['id']) {
|
||||
checkout_data['balance'] = data['checkouts'][i]['balance'];
|
||||
displayCheckoutData();
|
||||
}
|
||||
}
|
||||
for (var i=0; i<data['articles'].length; i++) {
|
||||
/* for (var i=0; i<data['articles'].length; i++) {
|
||||
var article = data['articles'][i];
|
||||
articles_container.find('#data-article-'+article['id']+' .stock')
|
||||
.text(article['stock']);
|
||||
}
|
||||
}*/
|
||||
if (data['addcost']) {
|
||||
Config.set('addcost_for', data['addcost']['for']);
|
||||
Config.set('addcost_amount', data['addcost']['amount']);
|
||||
|
@ -830,11 +715,10 @@ $(document).ready(function() {
|
|||
coolReset(give_tri_focus);
|
||||
kpsul.checkout_manager.reset();
|
||||
resetPreviousOp();
|
||||
khistory.reset();
|
||||
Config.reset(function() {
|
||||
kpsul.article_manager.reset_data();
|
||||
displayAddcost();
|
||||
getHistory();
|
||||
kpsul.history.reset();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -915,6 +799,7 @@ $(document).ready(function() {
|
|||
updateBasketAmount: updateBasketAmount,
|
||||
updateBasketRel: updateBasketRel,
|
||||
performOperations: performOperations,
|
||||
coolReset: coolReset,
|
||||
};
|
||||
|
||||
window.kpsul = new KPsulManager(env);
|
||||
|
|
Loading…
Reference in a new issue