Préparation annulation sur page Historique

- JS d'annulation de commande passé de `kpsul.html` vers `history.js`
- Fix orthographe
- Champs de filtres sur la page `Historique` plus propre
This commit is contained in:
Aurélien Delobelle 2016-08-25 01:52:20 +02:00
parent c4fa4ea20c
commit dc52e9570a
3 changed files with 43 additions and 39 deletions

View file

@ -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 = {