From 9198aca61f9491cb8afa172c0584948fdd280695 Mon Sep 17 00:00:00 2001 From: ulrich <ulrich> Date: Thu, 21 May 2020 09:18:35 +0000 Subject: [PATCH] Dialog 'Neuer Nutzer' als separate Ansicht, 'Zurueck'-Steuerung geaendert --- web/ui/data/tpl/dlg-nutzer-neu.tpl | 2 +- web/ui/js/app.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/web/ui/data/tpl/dlg-nutzer-neu.tpl b/web/ui/data/tpl/dlg-nutzer-neu.tpl index 8f6392a..3909b4a 100644 --- a/web/ui/data/tpl/dlg-nutzer-neu.tpl +++ b/web/ui/data/tpl/dlg-nutzer-neu.tpl @@ -1,5 +1,5 @@ <div class="dlg-nutzer-neu"> - <span class="close-btn pointer-cursor">✖</span> + <!-- <span class="close-btn pointer-cursor">✖</span> --> <div class="dlg-behaelter"> <div class="dlg-nutzer-titel">Neuer Nutzer</div> <form class="nutzer-form"> diff --git a/web/ui/js/app.js b/web/ui/js/app.js index fbbf052..2f4f1f0 100644 --- a/web/ui/js/app.js +++ b/web/ui/js/app.js @@ -11,6 +11,7 @@ document.querySelector('#top-logout-btn').addEventListener('click', self.logout); document.querySelector('.west').style.flexBasis = '0em'; document.querySelector('.ost').style.flexBasis = '0em'; + self.zurueck_btn_aus(); self.get_login(); self.get_user_list(); }; @@ -18,12 +19,27 @@ /* Nutzerverwaltung */ this.nutzer_neu_dialog_zeigen = function () { + self.html_erzeugen( + 'data/tpl/dlg-nutzer-neu.tpl', + '', + function (html) { + document.querySelector("#nutzer").innerHTML = html; + var btn = document.getElementById('nutzer-speichern-btn'); + if(btn !== null) { + btn.addEventListener('click', self.nutzer_speichern); + } + self.zurueck_btn_ein(self.zurueck_zu_user_liste); + } + ); + + /* self.dialog_zeigen('data/tpl/dlg-nutzer-neu.tpl', '', function(){ var btn = document.getElementById('nutzer-speichern-btn'); if(btn !== null) { btn.addEventListener('click', self.nutzer_speichern); } }); + */ }; this.nutzerliste_klick = function(event) { @@ -87,7 +103,7 @@ self.alle_rollen_zeigen(); }); }); - document.querySelector('.zurueck-btn').style.color = 'black'; + //document.querySelector('.zurueck-btn').style.color = 'black'; }; this.nutzer_loeschen_bestaetigen = function() { @@ -106,6 +122,11 @@ }); }; + this.zurueck_zu_user_liste = function() { + self.zurueck_btn_aus(self.zurueck_zu_user_liste); + self.get_user_list(); + }; + this.alle_rollen_zeigen = function() { var m = 'getRoleNamesGranted'; var u = '../svc/' + m; @@ -115,9 +136,12 @@ JSON.parse(antwort2), function (html) { document.querySelector(".alle-rollen-behaelter").innerHTML = html; + self.zurueck_btn_ein(self.zurueck_zu_user_liste); + /* document.querySelector('.zurueck-btn').addEventListener('click', function (e) { self.get_user_list(); }); + */ self.addEvtListener('.avl-role-btn', 'click', self.grant_role_klick); }); }); @@ -240,7 +264,7 @@ vurl, inhalt, function (html) { - dlg.style.flexBasis = '18em'; + dlg.style.flexBasis = '9em'; setTimeout(function () { dlg.innerHTML = html; document.querySelector('.close-btn').addEventListener( @@ -273,7 +297,7 @@ var elem = document.getElementById('nutzer'); elem.innerHTML = h; self.addEvtListener('p.nutzer-liste-eintrag', 'click', self.nutzerliste_klick); - document.querySelector('.zurueck-btn').style.color = '#eee'; + //document.querySelector('.zurueck-btn').style.color = '#eee'; self.removeAllListeners('top-neu-btn'); var topBtn = document.querySelector('#top-neu-btn'); topBtn.title = "Neuer Benutzer"; @@ -288,7 +312,8 @@ self.get_user_list(); document.getElementById('nutzer-speichern-btn').removeEventListener( 'click', self.nutzer_speichern); - self.dialog_schliessen(); + //self.dialog_schliessen(); + self.zurueck_zu_user_liste(); }); }; @@ -359,7 +384,21 @@ } }; -/* ----- Hilfsfunktionen ----- */ + /* ---- Steuerung Bedienelemente ---- */ + + this.zurueck_btn_ein = function(callback) { + var btn = document.querySelector('.zurueck-btn'); + btn.addEventListener('click', callback); + btn.style.color = 'black'; + }; + + this.zurueck_btn_aus = function(listener) { + var btn = document.querySelector('.zurueck-btn'); + btn.removeEventListener('click', listener); + btn.style.color = '#eee'; + }; + + /* ----- Hilfsfunktionen ----- */ this.serialisieren = function(obj) { return '{"' + obj.constructor.name + '":' + JSON.stringify(obj) + '}'; @@ -373,8 +412,8 @@ } }; - this.removeAllListeners = function(elementId) { - var el = document.getElementById(elementId); + this.removeAllListeners = function(id) { + var el = document.getElementById(id); elClone = el.cloneNode(true); el.parentNode.replaceChild(elClone, el); }; // https://stackoverflow.com/questions/19469881/remove-all-event-listeners-of-specific-type -- Gitblit v1.9.3