From 8c02e5da0c36f6c7b93ae26cb513dcdf11764036 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 10 Apr 2017 15:40:29 -0300 Subject: [PATCH] Trigger event on history itself --- kfet/static/kfet/js/history.js | 4 ++-- kfet/static/kfet/js/kfet.api.js | 1 - kfet/static/kfet/js/kpsul.js | 2 +- kfet/templates/kfet/account_read.html | 2 +- kfet/templates/kfet/history.html | 2 +- kfet/templates/kfet/transfers.html | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/kfet/static/kfet/js/history.js b/kfet/static/kfet/js/history.js index 5b6ec75b..c7663509 100644 --- a/kfet/static/kfet/js/history.js +++ b/kfet/static/kfet/js/history.js @@ -1,4 +1,4 @@ -var cancelHistory = new Event("history_cancel"); +var cancelHistory = new Event("cancel_done"); class KHistory { @@ -72,7 +72,7 @@ class KHistory { } cancel_operations(to_cancel) { - var on_success = () => document.dispatchEvent(cancelHistory); + var on_success = () => $(this).trigger("cancel_done"); api_with_auth({ url: Urls['kfet.kpsul.cancel_operations'](), diff --git a/kfet/static/kfet/js/kfet.api.js b/kfet/static/kfet/js/kfet.api.js index 0f6a078e..d7fd5823 100644 --- a/kfet/static/kfet/js/kfet.api.js +++ b/kfet/static/kfet/js/kfet.api.js @@ -1016,7 +1016,6 @@ class ModelForest { var child_name = struct_data.children; if (data.children && data.children.length) { for (let child_data of data.children) { - console.log(child_data); var child = this.get_or_create(child_data.modelname, child_data.content, 1); var child_parent = struct[child_data.modelname]; child[child_parent] = node; diff --git a/kfet/static/kfet/js/kpsul.js b/kfet/static/kfet/js/kpsul.js index 8833d072..05e3654c 100644 --- a/kfet/static/kfet/js/kpsul.js +++ b/kfet/static/kfet/js/kpsul.js @@ -43,7 +43,7 @@ class KPsulManager { _init_events() { var that = this ; - $(document).on("history_cancel", function(e) { + $(this.history).on("cancel_done", function(e) { that.reset(true); that.focus; }); diff --git a/kfet/templates/kfet/account_read.html b/kfet/templates/kfet/account_read.html index 54b91de4..7fd2d9c7 100644 --- a/kfet/templates/kfet/account_read.html +++ b/kfet/templates/kfet/account_read.html @@ -109,7 +109,7 @@ $(document).ready(function() { var khistory = new KHistory({'no_trigramme': true}); - $(document).on("cancel_history", function(e) { + $(khistory).on("cancel_done", function(e) { khistory.selection.reset(); }); diff --git a/kfet/templates/kfet/history.html b/kfet/templates/kfet/history.html index d432079f..43e8df93 100644 --- a/kfet/templates/kfet/history.html +++ b/kfet/templates/kfet/history.html @@ -129,7 +129,7 @@ $(document).ready(function() { updateHistory(); }); - $(document).on("cancel_history", function(e) { + $(khistory).on("cancel_history", function(e) { khistory.selection.reset(); }); diff --git a/kfet/templates/kfet/transfers.html b/kfet/templates/kfet/transfers.html index 910c5ab9..69e5eb33 100644 --- a/kfet/templates/kfet/transfers.html +++ b/kfet/templates/kfet/transfers.html @@ -53,7 +53,7 @@ $(document).ready(function() { var history = new KHistory(); - $(document).on("cancel_history", function(e) { + $(khistory).on("cancel_done", function(e) { khistory.selection.reset(); });