From 5e4151c324a4be5f08791b190a83e584062b18a6 Mon Sep 17 00:00:00 2001 From: ulrich <not disclosed> Date: Tue, 27 Dec 2016 13:08:15 +0000 Subject: [PATCH] bestehende Rolle erteilen --- web/ui/ui.js | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/web/ui/ui.js b/web/ui/ui.js index c6e9098..1a76637 100644 --- a/web/ui/ui.js +++ b/web/ui/ui.js @@ -1,5 +1,6 @@ function um_init() { + $('#user-form').hide(); $('.user-save-btn').click(um_user_save); $('#nutzerliste').click(um_user_list_click); $('#nutzerLoeschen').click(um_del_user); @@ -7,6 +8,7 @@ $('#nutzerLoeschen').prop( "disabled", true ); $('#nutzerRolleEntziehen').prop( "disabled", true ); $('#rolleErteilen').prop( "disabled", true ); + $('#rolleErteilen').click(um_grant_role); $('#neueRolle').click(um_new_role); $('#rollen').click(um_role_list_click); $('#nutzerrollen').click(um_user_role_list_click); @@ -61,10 +63,20 @@ } } +function um_grant_role() { + var roleIsNew = false; + var userId = um_get_first_selected_user_id(); + var roleId = um_get_first_selected_role_id(); + if(roleId !== 'none' && userId !== 'none') { + um_apicall_grant_role(userId, roleId, roleIsNew); + } +} + /* ----------- ui interaction ------------ */ function um_user_list_click() { $('#nutzerLoeschen').prop( "disabled", false ); + $('#rollen :selected').prop("selected", false); var userId = um_get_first_selected_user_id(); um_apicall_get_user_roles(userId); } @@ -115,6 +127,18 @@ return userId; } +function um_get_first_selected_role_id() { + var roleId = 'none'; + var roleIds = []; + $('#rollen :selected').each(function(i, selected){ + roleIds[i] = $(selected).text(); + }); + if(roleIds.length > 0) { + roleId = roleIds[0]; + } + return roleId; +} + // {"List":[{"List":[{"String":"ROLE_NAME"},{"String":"testrolle1"}]}]} function um_show_user_role_list(resp) { $("#nutzerrollen").empty(); @@ -136,6 +160,7 @@ //$('#neueRolle').prop( "disabled", true ); $('#rolleErteilen').prop( "disabled", true ); } + /* ---- api calls ----- */ function um_apicall_create_user(user) { -- Gitblit v1.9.3