From f2fa9085d0a75a88e4bd3c1a72dec8ef2d596027 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Wed, 11 Jul 2012 22:03:29 +0000 Subject: [PATCH] do not display admin createbox if admin already created git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1360439 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/index.html | 1 - .../src/main/webapp/js/archiva/main.js | 3 +- .../src/main/webapp/js/redback/user.js | 50 +++++++++++++------ 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html index d1c1bf26f..f7d744fa7 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html @@ -159,7 +159,6 @@ window.archivaRuntimeInfo=data; require(['sammy','archiva.main','domReady!'],function (domReady) { - $.log("startArchivaApplication"); startArchivaApplication(); $("#loadingDiv").hide(); }) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index a220541ee..eeb372a6a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -65,7 +65,8 @@ function() { return; } // by default display search screen - window.sammyArchivaApplication.setLocation("#search"); + $.log("location:"+window.sammyArchivaApplication.getLocation()); + //window.sammyArchivaApplication.setLocation("#search"); } hasKarma=function(karmaName){ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js index ea11fa92b..3994edc58 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js @@ -289,6 +289,8 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno return; } self.user.createAdmin(); + // go to search when admin created + window.sammyArchivaApplication.setLocation("#search"); } } @@ -296,24 +298,40 @@ define("redback.user",["jquery","utils","i18n","jquery.validate","knockout","kno * open a modal box to create admin user */ adminCreateBox=function() { - $.log("adminCreateBox"); - window.redbackModel.createUser=true; - $("#main-content").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}'); - var viewModel = new AdminUserViewModel(); - ko.applyBindings(viewModel,$("#main-content" ).get(0)); - $("#user-create").validate({ - rules: { - confirmPassword: { - equalTo: "#password" - } - }, - showErrors: function(validator, errorMap, errorList) { - customShowError("#main-content #user-create",validator,errorMap,errorMap); - } + + $.ajax("restServices/redbackServices/userService/isAdminUserExists", { + type: "GET", + dataType: 'json', + success: function(data) { + var adminExists = data; + if (adminExists == false) { + + window.redbackModel.createUser=true; + $("#main-content").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}'); + var viewModel = new AdminUserViewModel(); + ko.applyBindings(viewModel,$("#main-content" ).get(0)); + $.log("adminCreateBox"); + $("#user-create").validate({ + rules: { + confirmPassword: { + equalTo: "#password" + } + }, + showErrors: function(validator, errorMap, errorList) { + customShowError("#main-content #user-create",validator,errorMap,errorMap); + } + + }); + // desactivate roles pill when adding user + $("#edit_user_details_pills_headers").hide(); + + } else { + window.sammyArchivaApplication.setLocation("#search"); + } + + } }); - // desactivate roles pill when adding user - $("#edit_user_details_pills_headers").hide(); } /**