]> source.dussan.org Git - archiva.git/commitdiff
do not display admin createbox if admin already created
authorOlivier Lamy <olamy@apache.org>
Wed, 11 Jul 2012 22:03:29 +0000 (22:03 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 11 Jul 2012 22:03:29 +0000 (22:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1360439 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js

index d1c1bf26f4f9ad6f9f83858458ba95d2c80f42b1..f7d744fa7ffc35213904baf2ef2d1993e42726f3 100644 (file)
                               window.archivaRuntimeInfo=data;
 
                               require(['sammy','archiva.main','domReady!'],function (domReady) {
-                                  $.log("startArchivaApplication");
                                   startArchivaApplication();
                                   $("#loadingDiv").hide();
                               })
index a220541ee4d516a87005a5c284cdaef4d005564e..eeb372a6a1a85f23e0389f2f015f12d1b2b54263 100644 (file)
@@ -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){
index ea11fa92b23a4a3f767ff883ffcbb500a049351e..3994edc580da3851d18d482d5ccbfb2a83b6a0ea 100644 (file)
@@ -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"
+
+
+    $.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");
         }
-      },
-      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();
   }
 
   /**