From e40fbd83596e39c19a99b13ccce04b0c43076b5c Mon Sep 17 00:00:00 2001 From: ulrich <ulrich@uhilger.de> Date: Wed, 28 Dec 2016 18:14:21 +0000 Subject: [PATCH] Anpassungen an der Gestaltung (in Arbeit) --- web/ui/ui.js | 57 +++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 41 insertions(+), 16 deletions(-) diff --git a/web/ui/ui.js b/web/ui/ui.js index af818d5..b0ccf4e 100644 --- a/web/ui/ui.js +++ b/web/ui/ui.js @@ -1,7 +1,11 @@ function um_init() { $('#user-form').hide(); + $('#nav').hide(); + $('#role-form').hide(); + $('#user-role-form').hide(); $('.user-save-btn').click(um_user_save); + $('.user-cancel-btn').click(um_back_from_new_user); $('#nutzerliste').click(um_user_list_click); $('#nutzerLoeschen').click(um_del_user); $('#nutzerNeu').click(um_new_user); @@ -39,10 +43,6 @@ um_apicall_del_user(self.serialisieren(user)); } } -} - -function um_new_user() { - alert('show form to enter new user'); } /* ----------- role functions ------------ */ @@ -84,10 +84,23 @@ /* ----------- ui interaction ------------ */ function um_user_list_click() { + $('#nav-back-btn').click(um_back_from_roles); $('#nutzerLoeschen').prop( "disabled", false ); $('#rollen :selected').prop("selected", false); var userId = um_get_first_selected_user_id(); + $('#userid').html(userId); um_apicall_get_user_roles(userId); + $('#user-list-form').hide(); + $('#nav').show(); + $('#role-form').show(); + $('#user-role-form').show(); +} + +function um_new_user() { + $('#nav-back-btn').click(um_back_from_new_user); + $('#user-list-form').hide(); + $('#user-form').show(); + $('#nav').show(); } function um_role_list_click() { @@ -98,6 +111,19 @@ $('#nutzerRolleEntziehen').prop( "disabled", false ); } +function um_back_from_roles() { + $('#user-list-form').show(); + $('#nav').hide(); + $('#role-form').hide(); + $('#user-role-form').hide(); +} + +function um_back_from_new_user() { + $('#user-list-form').show(); + $('#nav').hide(); + $('#user-form').hide(); + um_clear_user_form(); +} /* ------- ui i/o ------ */ @@ -160,7 +186,6 @@ return roleId; } -// {"List":[{"List":[{"String":"ROLE_NAME"},{"String":"testrolle1"}]}]} function um_show_user_role_list(resp) { $("#nutzerrollen").empty(); var rollen = resp.List[0]; @@ -178,7 +203,6 @@ var rolle = rollen.List[i]; $("#rollen").append('<option value=' + rolle.String + '>' + rolle.String + '</option>'); } - //$('#neueRolle').prop( "disabled", true ); $('#rolleErteilen').prop( "disabled", true ); } @@ -195,9 +219,8 @@ type: "POST", dataType : "html", success: function( resp ) { - //$('#fehler').html('Antwort: ' + resp); um_apicall_get_user_list(); - um_clear_user_form(); + um_back_from_new_user(); }, error: function( xhr, status, errorThrown ) { $('#fehler').html("Error: " + errorThrown + " Status: " + status); @@ -249,15 +272,15 @@ }); } -// public UserRole grantRole(String userId, String roleName) +// http]://example.com/um/api?c=de.uhilger.um.api.UserMgr&m=testmethode function um_apicall_grant_role(userId, roleName, isNewRole) { + var ur = new UserRole(userId, roleName); var m = 'grantRole'; var u = '../svc/' + m; $.ajax({ url: u, data: { - p1: userId, - p2: roleName + p: self.serialisieren(ur) }, type: "POST", dataType : "html", @@ -277,13 +300,13 @@ } function um_apicall_revoke_role(userId, roleName) { + var ur = new UserRole(userId, roleName); var m = 'revokeRole'; var u = '../svc/' + m; $.ajax({ url: u, data: { - p1: userId, - p2: roleName + p: self.serialisieren(ur) }, type: "POST", dataType : "html", @@ -299,7 +322,6 @@ }); } -//public List getUserRoleNames(String userId) function um_apicall_get_user_roles(userId) { var m = 'getUserRoleNames'; var u = '../svc/' + m + '?p=' + userId; @@ -308,7 +330,6 @@ type: "GET", dataType : "json", success: function( resp ) { - // Antwort in Liste anzeigen um_show_user_role_list(resp); }, error: function( xhr, status, errorThrown ) { @@ -328,7 +349,6 @@ type: "GET", dataType : "json", success: function( resp ) { - // Antwort in Liste anzeigen um_show_role_list(resp); }, error: function( xhr, status, errorThrown ) { @@ -354,4 +374,9 @@ this.firstName = fn; this.lastName = ln; this.email = em; +} + +function UserRole(u, r) { + this.userId = u; + this.role = r; } \ No newline at end of file -- Gitblit v1.9.3