diff --git a/kfet/static/kfet/js/history.js b/kfet/static/kfet/js/history.js index 9d35e5eb..e99acd5a 100644 --- a/kfet/static/kfet/js/history.js +++ b/kfet/static/kfet/js/history.js @@ -48,19 +48,25 @@ function KHistory(options={}) { $ope_html.find('.addcost').text('('+amountDisplay(addcost_amount, is_cof)+'UKF pour '+addcost_for+')'); } - if (ope['canceled_at']) { - var canceled_at = dateUTCToParis(ope['canceled_at']); - var canceled_by = ope['canceled_by__trigramme']; - var cancel = 'Annulé'; - if (canceled_by) - cancel += ' par '+canceled_by; - cancel += ' le '+canceled_at.format('DD/MM/YY à HH:mm:ss'); - $ope_html.addClass('canceled').find('.canceled').text(cancel); - } + if (ope['canceled_at']) + this.cancelOpe(ope, $ope_html); return $ope_html; } + this.cancelOpe = function(ope, $ope = null) { + if (!$ope) + $ope = this.findOpe(ope['id']); + + var cancel = 'Annulé'; + var canceled_at = dateUTCToParis(ope['canceled_at']); + if (ope['canceled_by__trigramme']) + cancel += ' par '+ope['canceled_by__trigramme']; + cancel += ' le '+canceled_at.format('DD/MM/YY à HH:mm:ss'); + + $ope.addClass('canceled').find('.canceled').text(cancel); + } + this._opeGroupHtml = function(opegroup) { var $opegroup_html = $(this.template_opegroup); @@ -83,7 +89,6 @@ function KHistory(options={}) { if (opegroup['valid_by__trigramme']) $opegroup_html.find('.valid_by').text('Par '+opegroup['valid_by__trigramme']); - return $opegroup_html; } @@ -98,6 +103,27 @@ function KHistory(options={}) { var $day = $(this.template_day).prependTo(this.$container); return $day.data('date', at_ser).text(at.format('D MMMM')); } + + this.findOpeGroup = function(id) { + return this.$container.find('.opegroup').filter(function() { + return $(this).data('opegroup') == id + }); + } + + this.findOpe = function(id) { + return this.$container.find('.ope').filter(function() { + return $(this).data('ope') == id + }); + } + + this.cancelOpeGroup = function(opegroup) { + var $opegroup = this.findOpeGroup(opegroup['id']); + var trigramme = $opegroup.find('.trigramme').text(); + var amount = amountDisplay( + parseFloat(opegroup['amount'], opegroup['is_cof'], trigramme)); + $opegroup.find('.amount').text(amount); + } + } KHistory.default_options = { diff --git a/kfet/templates/kfet/history.html b/kfet/templates/kfet/history.html index b1f50422..d8db7032 100644 --- a/kfet/templates/kfet/history.html +++ b/kfet/templates/kfet/history.html @@ -29,10 +29,10 @@