From 95f4150c6074126f2639028a07a629e46300f3d7 Mon Sep 17 00:00:00 2001
From: ulrich <not disclosed>
Date: Tue, 27 Dec 2016 09:53:54 +0000
Subject: [PATCH] Funktin Neue Rolle erstellt aber noch nicht mit Server verknuepft

---
 web/ui/ui.js |   48 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/web/ui/ui.js b/web/ui/ui.js
index 7782450..ce2d447 100644
--- a/web/ui/ui.js
+++ b/web/ui/ui.js
@@ -5,6 +5,7 @@
   $('#nutzerLoeschen').click(um_del_user);
   $('#nutzerNeu').click(um_new_user);
   $('#nutzerLoeschen').prop( "disabled", true );
+  $('#neueRolle').click(um_new_role);
   um_clear_user_form();
   um_apicall_get_user_list();
 }
@@ -23,21 +24,42 @@
 }
 
 function um_del_user() {
-  var users = [];
+  /*var users = [];
   $('#nutzerliste :selected').each(function(i, selected){
     users[i] = $(selected).text();
-  });
+  });*/
 
   //alert('delete user ' + users[0]);
-  var antwort = confirm("Wollen Sie den Nutzer " + users[0] + " loeschen?"); 
-  if (antwort == true) {
-    var user = new User(users[0], '-', '-', '-', '-');
-    um_apicall_del_user(self.serialisieren(user));
-  }  
+  var userId = um_get_first_selected_user_id();
+  if(userId !== 'none') {
+    var antwort = confirm("Wollen Sie den Nutzer " + usersId + " loeschen?"); 
+    if (antwort === true) {
+      var user = new User(userId, '-', '-', '-', '-');
+      um_apicall_del_user(self.serialisieren(user));
+    }  
+  }
 }
 
 function um_new_user() {
   alert('show form to enter new user');
+}
+
+/* ----------- role functions ------------ */
+
+function um_new_role() {
+  var userId = um_get_first_selected_user_id();
+  if(userId === 'none') {
+    alert('Es wurde kein Benutzer ausgewaehlt.');
+  } else {
+    var answer = prompt("Name der Rolle", "");
+    if (answer === null) {
+      alert("Es wurde Cancel betaetigt.");
+    } else if(answer !== "") {
+      alert("Rolle fuer Benutzer " + userId + " anlegen: " + answer);
+    } else {
+      alert("OK betaetigt, aber Keine Rolle angegeben.");
+    }
+  }
 }
 
 /* ----------- ui interaction ------------ */
@@ -82,6 +104,18 @@
   $('#kennwortw').val('');
 }
 
+function um_get_first_selected_user_id() {
+  var userId = 'none';
+  var userIds = [];
+  $('#nutzerliste :selected').each(function(i, selected){
+    userIds[i] = $(selected).text();
+  });
+  if(userIds.length > 0) {
+    userId = userIds[0];
+  }
+  return userId;
+}
+
 /* ---- api calls ----- */
 
 function um_apicall_create_user(user) {

--
Gitblit v1.9.3