From dc52e9570a8be5b227d031643b0e41ffb9eb7558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Thu, 25 Aug 2016 01:52:20 +0200 Subject: [PATCH] =?UTF-8?q?Pr=C3=A9paration=20annulation=20sur=20page=20`H?= =?UTF-8?q?istorique`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - JS d'annulation de commande passé de `kpsul.html` vers `history.js` - Fix orthographe - Champs de filtres sur la page `Historique` plus propre --- kfet/static/kfet/js/history.js | 46 +++++++++++++++++++++++++------- kfet/templates/kfet/history.html | 8 +++--- kfet/templates/kfet/kpsul.html | 28 +++---------------- 3 files changed, 43 insertions(+), 39 deletions(-) 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 @@
opérations

Filtres

-
De
-
à
+
De
+
à
Caisses {{ filter_form.checkouts }}
-
Comtpes {{ filter_form.accounts }}
+
Comptes {{ filter_form.accounts }}
@@ -124,7 +124,7 @@ $(document).ready(function() { }); $("select").multipleSelect({ - width: 200, + width: '100%', filter: true, }); diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index 7bf27747..c5153f78 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -1086,28 +1086,6 @@ $(document).ready(function() { } }); - function cancelOpeGroup(opegroup) { - var $opegroup = khistory.$container.find('.opegroup').filter(function() { - return $(this).data('opegroup') == opegroup['id'] - }); - var tri = $opegroup.find('.trigramme').text(); - var amount = amountDisplay( - parseFloat(opegroup['amount'], opegroup['is_cof'], tri)) - $opegroup.find('.amount').text(amount); - } - - function cancelOpe(ope) { - var $ope = khistory.$container.find('.ope').filter(function() { - return $(this).data('ope') == 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); - } - // ----- // Synchronization // ----- @@ -1120,14 +1098,14 @@ $(document).ready(function() { for (var i=0; i