]> source.dussan.org Git - archiva.git/commitdiff
fix user edit/creation form in admin part
authorOlivier Lamy <olamy@apache.org>
Mon, 12 Dec 2011 16:12:27 +0000 (16:12 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 12 Dec 2011 16:12:27 +0000 (16:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1213293 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/user-edit.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/user-grids.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js

index 2a17d993eff161264787869ccc8cc30d0c718b38..115b3cb979f0e356a0af48cad7c4eb75d3bd3cdd 100644 (file)
@@ -4,7 +4,7 @@
         <div class="clearfix">
           <label for="username">${i18n('username')}</label>
           <div class="input" id="username-div">
-            {{if $data.username}}
+            {{if $data.username.length>0}}
               <span class="uneditable-input">${$data.username}</span>
             {{else}}
               <input type="text" id="username" name="username" size="30" class="required" data-bind="value: username"/>
@@ -55,6 +55,6 @@
         </div>
       </fieldset>
       <button data-bind="click: save" class="btn" id="user-create-form-register-button">${i18n('save')}</button>
-      <button onclick="$('#user-create').hide()" class="btn" id="user-create-form-cancel-button">${i18n('cancel')}</button>
+      <button class="btn" id="user-create-form-cancel-button">${i18n('cancel')}</button>
     </form>
 </script>
index fde561086c54d736aaf9f5f7e449bc3c70e9a3b2..ca6d41cf26ed96e7f662671ade92a231f62e52bd 100644 (file)
@@ -68,6 +68,7 @@
           </tr>
       {{/each}}
   </tbody>
+
 </script>
 
 <script id="ko_usersGrid_pageLinks" type="text/x-jquery-tmpl">
index 43d39b7e0114f52f61d3720a3493468f93a504c1..1fcb8716aafb1ae7dba7faea83de631e6820d186 100644 (file)
@@ -47,6 +47,11 @@ $(function() {
         }
       };
       this.createUser = function() {
+        $.log("user#createUser");
+        var valid = $("#user-create").valid();
+        if (!valid) {
+            return;
+        }
         var currentUser = this;
         $.ajax("restServices/redbackServices/userService/createUser", {
             data: "{\"user\": " +  ko.toJSON(this)+"}",
@@ -158,7 +163,15 @@ $(function() {
       this.save=function(){
         $.log("user.save create:"+window.redbackModel.createUser);
         if (window.redbackModel.createUser==true){
-          return this.create();
+          var valid = $("#main-content #createUserForm #user-create").valid();
+
+          if (valid==false) {
+            $.log("user#save valid:false");
+            return;
+          } else {
+            $.log("user#save valid:true");
+            return this.create();
+          }
         } else {
           return this.update();
         }
index a2bf9bdd264cbd187ebe8dee4cd4bb4d64ab1139..7a8781fdf002b0b41dd539b53bb6627a7b125c90 100644 (file)
@@ -54,12 +54,12 @@ $(function() {
     });
 
     this.addUser=function() {
-      screenChange();
+      clearUserMessages();
       window.redbackModel.createUser=true;
       $("#main-content #user-edit").remove();
       $('#main-content #user-create').show();
       ko.renderTemplate("redback/user-edit-tmpl", new user(), null, $("#createUserForm").get(0),"replaceChildren");
-      $("#user-create").delegate("#user-create-form-cancel-button", "click keydown", function(e) {
+      $("#main-content #createUserForm #user-create").delegate("#user-create-form-cancel-button", "click keydown", function(e) {
         e.preventDefault();
         $('#user-create').hide();
       });
@@ -73,13 +73,8 @@ $(function() {
           customShowError(validator,errorMap,errorMap);
         }
       });
-      $("#createUserForm #user-create").delegate("#user-create-form-save-button", "click keydown", function(e) {
+      $("#main-content #createUserForm #user-create").delegate("#user-create-form-register-button", "click keydown", function(e) {
         e.preventDefault();
-        var valid = $("#user-create").valid();
-        if (!valid) {
-            return;
-        }
-        user.createUser();
       });
     };
 
@@ -110,7 +105,7 @@ $(function() {
 
     this.editUserBox=function(user) {
       window.redbackModel.createUser=false;
-      screenChange();
+      clearUserMessages();
       $("#main-content #user-edit").remove();
       $("#main-content").append("<div id='user-edit'></div>");
       $("#main-content #user-edit").attr("data-bind",'template: {name:"redback/user-edit-tmpl",data: user}');
@@ -120,20 +115,13 @@ $(function() {
       var viewModel = new userViewModel(user);
 
       ko.applyBindings(viewModel,$("#main-content #user-edit").get(0));
-      jQuery("#main-content #user-create").validate({
-        rules: {
-          confirmPassword: {
-            equalTo: "#password"
-          }
-        },
-        showErrors: function(validator, errorMap, errorList) {
-          customShowError(validator,errorMap,errorMap);
-        }
-      });
+
+
       $("#main-content #user-create").delegate("#user-create-form-cancel-button", "click keydown", function(e) {
         e.preventDefault();
         $('#main-content #user-create').remove();
       });
+
       $("#main-content #user-create").validate({
         rules: {
           confirmPassword: {
@@ -152,6 +140,7 @@ $(function() {
         }
         user.update();
       });
+
     }
 
   }