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 {
|
class KHistory {
|
||||||
|
|
||||||
static get default_options {
|
static get default_options() {
|
||||||
return {
|
return {
|
||||||
'templates': {
|
'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>',
|
'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) {
|
cancel_operations(to_cancel) {
|
||||||
if (window.kpsul) {
|
var on_success = () => document.dispatchEvent(cancelHistory);
|
||||||
var on_success = kpsul._env.coolReset;
|
|
||||||
var focus_next = kpsul;
|
|
||||||
} else {
|
|
||||||
var on_success = () => this.selection.reset()
|
|
||||||
var focus_next = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
api_with_auth({
|
api_with_auth({
|
||||||
url: Urls['kfet.kpsul.cancel_operations'](),
|
url: Urls['kfet.kpsul.cancel_operations'](),
|
||||||
data: to_cancel,
|
data: to_cancel,
|
||||||
on_success: on_success,
|
on_success: on_success,
|
||||||
focus_next: focus_next,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ class KPsulManager {
|
||||||
this.checkout_manager = new CheckoutManager(this);
|
this.checkout_manager = new CheckoutManager(this);
|
||||||
this.article_manager = new ArticleManager(this);
|
this.article_manager = new ArticleManager(this);
|
||||||
this.history = new KHistory();
|
this.history = new KHistory();
|
||||||
|
|
||||||
|
this._init_events();
|
||||||
}
|
}
|
||||||
|
|
||||||
reset(soft) {
|
reset(soft) {
|
||||||
|
@ -39,6 +41,14 @@ class KPsulManager {
|
||||||
return this;
|
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});
|
var khistory = new KHistory({'no_trigramme': true});
|
||||||
|
|
||||||
|
$(document).on("cancel_history", function(e) {
|
||||||
|
khistory.selection.reset();
|
||||||
|
});
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// Synchronization
|
// Synchronization
|
||||||
// -----
|
// -----
|
||||||
|
|
|
@ -129,6 +129,10 @@ $(document).ready(function() {
|
||||||
updateHistory();
|
updateHistory();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on("cancel_history", function(e) {
|
||||||
|
khistory.selection.reset();
|
||||||
|
});
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// Synchronization
|
// Synchronization
|
||||||
// -----
|
// -----
|
||||||
|
|
|
@ -51,11 +51,12 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Lock to avoid multiple requests
|
|
||||||
window.lock = 0;
|
|
||||||
|
|
||||||
var history = new KHistory();
|
var history = new KHistory();
|
||||||
|
|
||||||
|
$(document).on("cancel_history", function(e) {
|
||||||
|
khistory.selection.reset();
|
||||||
|
});
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// Synchronization
|
// Synchronization
|
||||||
// -----
|
// -----
|
||||||
|
|
Loading…
Reference in a new issue