Remove deprecated history functions

This commit is contained in:
Ludovic Stephan 2017-03-18 02:28:01 -03:00
parent 5c9c206f68
commit 14b922634d

View file

@ -157,9 +157,6 @@
</div> </div>
</div> </div>
<div id="history2">
</div>
<form id="operationgroup_form" style="display:none;">{{ operationgroup_form }}</form> <form id="operationgroup_form" style="display:none;">{{ operationgroup_form }}</form>
<form id="operation_formset" style="display:none;">{{ operation_formset }}</form> <form id="operation_formset" style="display:none;">{{ operation_formset }}</form>
@ -299,55 +296,6 @@ $(document).ready(function() {
performOperations(); 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 // Articles data
// ----- // -----
@ -625,29 +573,6 @@ $(document).ready(function() {
formset_container.find('#id_form-'+opeindex+'-DELETE').prop('checked', true); 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'); var previousop_container = $('#previous_op');
function updatePreviousOp() { 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 // Synchronization
// ----- // -----
@ -781,29 +676,19 @@ $(document).ready(function() {
socket.onmessage = function(e) { socket.onmessage = function(e) {
var data = $.extend({}, websocket_msg_default, JSON.parse(e.data)); var data = $.extend({}, websocket_msg_default, JSON.parse(e.data));
for (var i=0; i<data['opegroups'].length; i++) { kpsul.history.update_data(data);
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]);
}
}
for (var i=0; i<data['checkouts'].length; i++) { for (var i=0; i<data['checkouts'].length; i++) {
if (checkout_data['id'] == data['checkouts'][i]['id']) { if (checkout_data['id'] == data['checkouts'][i]['id']) {
checkout_data['balance'] = data['checkouts'][i]['balance']; checkout_data['balance'] = data['checkouts'][i]['balance'];
displayCheckoutData(); displayCheckoutData();
} }
} }
for (var i=0; i<data['articles'].length; i++) { /* for (var i=0; i<data['articles'].length; i++) {
var article = data['articles'][i]; var article = data['articles'][i];
articles_container.find('#data-article-'+article['id']+' .stock') articles_container.find('#data-article-'+article['id']+' .stock')
.text(article['stock']); .text(article['stock']);
} }*/
if (data['addcost']) { if (data['addcost']) {
Config.set('addcost_for', data['addcost']['for']); Config.set('addcost_for', data['addcost']['for']);
Config.set('addcost_amount', data['addcost']['amount']); Config.set('addcost_amount', data['addcost']['amount']);
@ -830,11 +715,10 @@ $(document).ready(function() {
coolReset(give_tri_focus); coolReset(give_tri_focus);
kpsul.checkout_manager.reset(); kpsul.checkout_manager.reset();
resetPreviousOp(); resetPreviousOp();
khistory.reset();
Config.reset(function() { Config.reset(function() {
kpsul.article_manager.reset_data(); kpsul.article_manager.reset_data();
displayAddcost(); displayAddcost();
getHistory(); kpsul.history.reset();
}); });
} }
@ -915,6 +799,7 @@ $(document).ready(function() {
updateBasketAmount: updateBasketAmount, updateBasketAmount: updateBasketAmount,
updateBasketRel: updateBasketRel, updateBasketRel: updateBasketRel,
performOperations: performOperations, performOperations: performOperations,
coolReset: coolReset,
}; };
window.kpsul = new KPsulManager(env); window.kpsul = new KPsulManager(env);