WIP: Aureplop/kpsul js refactor #501
4 changed files with 18 additions and 7 deletions
|
@ -40,7 +40,7 @@
|
|||
width:90px;
|
||||
}
|
||||
|
||||
#history .opegroup .info {
|
||||
#history .opegroup .infos {
|
||||
text-align:center;
|
||||
width:145px;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ function KHistory(options={}) {
|
|||
var addcost_for = ope['addcost_for__trigramme'];
|
||||
if (addcost_for) {
|
||||
var addcost_amount = parseFloat(ope['addcost_amount']);
|
||||
$ope_html.find('.addcost').text('('+amountDisplay(addcost_amount, is_cof)+'UKF pour '+addcost_for+')');
|
||||
$ope_html.find('.addcost').text('('+amountDisplay(addcost_amount, is_cof)+' UKF pour '+addcost_for+')');
|
||||
}
|
||||
|
||||
if (ope['canceled_at'])
|
||||
|
@ -88,7 +88,7 @@ function KHistory(options={}) {
|
|||
|
||||
this.cancelOpe = function(ope, $ope = null) {
|
||||
if (!$ope)
|
||||
$ope = this.findOpe(ope['id']);
|
||||
$ope = this.findOpe(ope['id'], ope['type']);
|
||||
|
||||
var cancel = 'Annulé';
|
||||
var canceled_at = dateUTCToParis(ope['canceled_at']);
|
||||
|
@ -123,7 +123,7 @@ function KHistory(options={}) {
|
|||
.data('id', opegroup['id'])
|
||||
.find('.time').text(at).end()
|
||||
.find('.trigramme').text(trigramme).end()
|
||||
.find('.info').text("Transferts").end()
|
||||
.find('.infos').text("Transferts").end()
|
||||
.find('.amount').text(amount).end()
|
||||
.find('.comment').text(comment).end();
|
||||
|
||||
|
@ -155,7 +155,7 @@ function KHistory(options={}) {
|
|||
});
|
||||
}
|
||||
|
||||
this.findOpe = function(id, type) {
|
||||
this.findOpe = function(id, type='ope') {
|
||||
return this.$container.find('.ope').filter(function() {
|
||||
return ($(this).data('id') == id && $(this).data('type') == type)
|
||||
});
|
||||
|
@ -175,7 +175,7 @@ KHistory.default_options = {
|
|||
container: '#history',
|
||||
template_day: '<div class="day"></div>',
|
||||
template_opegroup: '<div class="opegroup"><span class="time"></span><span class="trigramme"></span><span class="amount"></span><span class="valid_by"></span><span class="comment"></span></div>',
|
||||
template_transfergroup: '<div class="opegroup"><span class="time"></span><span class="info"></span><span class="valid_by"></span><span class="comment"></span></div>',
|
||||
template_transfergroup: '<div class="opegroup"><span class="time"></span><span class="infos"></span><span class="valid_by"></span><span class="comment"></span></div>',
|
||||
template_ope: '<div class="ope"><span class="amount"></span><span class="infos1"></span><span class="infos2"></span><span class="addcost"></span><span class="canceled"></span></div>',
|
||||
template_transfer: '<div class="ope"><span class="amount"></span><span class="infos1"></span><span class="glyphicon glyphicon-arrow-right"></span><span class="infos2"></span><span class="canceled"></span></div>',
|
||||
display_trigramme: true,
|
||||
|
|
|
@ -1211,7 +1211,7 @@ $(document).ready(function() {
|
|||
// DEL (Suppr)
|
||||
var opes_to_cancel = [];
|
||||
khistory.$container.find('.ope.ui-selected').each(function () {
|
||||
opes_to_cancel.push($(this).data('ope'));
|
||||
opes_to_cancel.push($(this).data('type')+' '+$(this).data('id'));
|
||||
});
|
||||
if (opes_to_cancel.length > 0)
|
||||
cancelOperations(opes_to_cancel);
|
||||
|
|
|
@ -1053,6 +1053,7 @@ def kpsul_perform_operations(request):
|
|||
websocket_data = {}
|
||||
websocket_data['opegroups'] = [{
|
||||
'add': True,
|
||||
'type': 'opegroup',
|
||||
'id': operationgroup.pk,
|
||||
'amount': operationgroup.amount,
|
||||
'checkout__name': operationgroup.checkout.name,
|
||||
|
@ -1282,10 +1283,20 @@ def kpsul_cancel_operations(request):
|
|||
for ope in opes:
|
||||
websocket_data['opes'].append({
|
||||
'cancellation': True,
|
||||
'type': 'ope',
|
||||
'id': ope,
|
||||
'canceled_by__trigramme': canceled_by__trigramme,
|
||||
'canceled_at': canceled_at,
|
||||
})
|
||||
for ope in transfers:
|
||||
websocket_data['opes'].append({
|
||||
'cancellation': True,
|
||||
'type': 'transfer',
|
||||
'id': ope,
|
||||
'canceled_by__trigramme': canceled_by__trigramme,
|
||||
'canceled_at': canceled_at,
|
||||
})
|
||||
|
||||
# Need refresh from db cause we used update on querysets
|
||||
checkouts_pk = [checkout.pk for checkout in to_checkouts_balances]
|
||||
checkouts = (Checkout.objects
|
||||
|
|
Loading…
Reference in a new issue