From aeec9d368ba8068277214eee9e63775f44eb6d02 Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Thu, 30 Sep 2021 10:48:27 +0200
Subject: [PATCH] Add edit_mode listener to qrcode.js

---
 src/core/js/ext_qrcode.js | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/core/js/ext_qrcode.js b/src/core/js/ext_qrcode.js
index 56f49d44..d075ef88 100644
--- a/src/core/js/ext_qrcode.js
+++ b/src/core/js/ext_qrcode.js
@@ -163,16 +163,23 @@ var ext_qrcode = function ($, connection, getEntityVersion, getEntityID, QRCode,
         $(entity).find(`.${_buttons_list_class} .${_qrcode_button_class}`).remove();
     }
 
+    var _init = function () {
+        for (let entity of $(".caosdb-entity-panel")) {
+            remove_qrcode_button(entity);
+            add_qrcode_to_entity(entity);
+        }
+    }
+
     /**
      * Initialize this module and append a QR Code button to all entities panels on the page.
      *
      * Removes all respective buttons if present before adding a new one.
      */
     var init = function () {
-        for (let entity of $(".caosdb-entity-panel")) {
-            remove_qrcode_button(entity);
-            add_qrcode_to_entity(entity);
-        }
+        _init();
+
+        // edit-mode-listener
+        document.body.addEventListener(edit_mode.end_edit.type, _init, true);
     };
 
     return {
-- 
GitLab