forked from DGNum/gestioCOF
Add cancel_history event
This commit is contained in:
parent
cfb39b1050
commit
983a55780f
5 changed files with 26 additions and 12 deletions
|
@ -1,6 +1,8 @@
|
|||
var cancelHistory = new Event("history_cancel");
|
||||
|
||||
class KHistory {
|
||||
|
||||
static get default_options {
|
||||
static get default_options() {
|
||||
return {
|
||||
'templates': {
|
||||
'purchase': '<div class="ope"><span class="amount"></span><span class="infos1"></span><span class="infos2"></span><span class="addcost"></span><span class="canceled"></span></div>',
|
||||
|
@ -70,19 +72,12 @@ class KHistory {
|
|||
}
|
||||
|
||||
cancel_operations(to_cancel) {
|
||||
if (window.kpsul) {
|
||||
var on_success = kpsul._env.coolReset;
|
||||
var focus_next = kpsul;
|
||||
} else {
|
||||
var on_success = () => this.selection.reset()
|
||||
var focus_next = undefined;
|
||||
}
|
||||
var on_success = () => document.dispatchEvent(cancelHistory);
|
||||
|
||||
api_with_auth({
|
||||
url: Urls['kfet.kpsul.cancel_operations'](),
|
||||
data: to_cancel,
|
||||
on_success: on_success,
|
||||
focus_next: focus_next,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ class KPsulManager {
|
|||
this.checkout_manager = new CheckoutManager(this);
|
||||
this.article_manager = new ArticleManager(this);
|
||||
this.history = new KHistory();
|
||||
|
||||
this._init_events();
|
||||
}
|
||||
|
||||
reset(soft) {
|
||||
|
@ -39,6 +41,14 @@ class KPsulManager {
|
|||
return this;
|
||||
}
|
||||
|
||||
_init_events() {
|
||||
var that = this ;
|
||||
$(document).on("history_cancel", function(e) {
|
||||
that.reset(true);
|
||||
that.focus;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -109,6 +109,10 @@ $(document).ready(function() {
|
|||
|
||||
var khistory = new KHistory({'no_trigramme': true});
|
||||
|
||||
$(document).on("cancel_history", function(e) {
|
||||
khistory.selection.reset();
|
||||
});
|
||||
|
||||
// -----
|
||||
// Synchronization
|
||||
// -----
|
||||
|
|
|
@ -129,6 +129,10 @@ $(document).ready(function() {
|
|||
updateHistory();
|
||||
});
|
||||
|
||||
$(document).on("cancel_history", function(e) {
|
||||
khistory.selection.reset();
|
||||
});
|
||||
|
||||
// -----
|
||||
// Synchronization
|
||||
// -----
|
||||
|
|
|
@ -51,11 +51,12 @@
|
|||
$(document).ready(function() {
|
||||
'use strict';
|
||||
|
||||
// Lock to avoid multiple requests
|
||||
window.lock = 0;
|
||||
|
||||
var history = new KHistory();
|
||||
|
||||
$(document).on("cancel_history", function(e) {
|
||||
khistory.selection.reset();
|
||||
});
|
||||
|
||||
// -----
|
||||
// Synchronization
|
||||
// -----
|
||||
|
|
Loading…
Reference in a new issue