]> source.dussan.org Git - archiva.git/commitdiff
add managedRepository form validation rules
authorOlivier Lamy <olamy@apache.org>
Mon, 16 Jan 2012 16:53:26 +0000 (16:53 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 16 Jan 2012 16:53:26 +0000 (16:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1232061 13f79535-47bb-0310-9956-ffa450edef68

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

index 96ed1e95de78d292f886930daf3d51ae8b688a3d..e0472b2903ebf262470f1563a49392044bde25b1 100644 (file)
@@ -72,6 +72,10 @@ $(function() {
     this.update = update;
 
     save=function(){
+      var valid = $("#main-content #managed-repository-edit-form").valid();
+      if (valid==false) {
+          return;
+      }
       $.log("save:"+this.managedRepository().name());
       clearUserMessages();
       $.ajax("restServices/archivaServices/managedRepositoriesService/updateManagedRepository",
@@ -108,6 +112,19 @@ $(function() {
       ko.applyBindings(viewModel,$("#main-content #managed-repository-edit").get(0));
       activateManagedRepositoryEditTab();
       $("#managed-repository-edit-li a").html($.i18n.prop('edit'));
+      $("#main-content #managed-repository-edit-form").validate({
+        rules: {
+          daysOlder : {
+            digits: true
+          },
+          retentionCount : {
+            digits: true
+          }
+        },
+        showErrors: function(validator, errorMap, errorList) {
+          customShowError(validator,errorMap,errorMap);
+        }
+      });
     }
 
   }
index 24dc3a3a3022ef65320fc6f1b88f69757a50fc43..ebd9d1892fab2911edbdb1ec22d0cdf64308ecf5 100644 (file)
             {{if update}}
               <span class="uneditable-input">${$data.managedRepository().id}</span>
             {{else}}
-              <input type="text" class="xlarge" id="id" name="id" size="50" class="required"
+              <input type="text" class="xlarge required" id="id" name="id" size="50"
                      data-bind="value: managedRepository().id,css:{'uneditable-input': update},readonly:update"/>
             {{/if}}
           </div>
         <div class="clearfix">
           <label for="name">${$.i18n.prop('name')}</label>
           <div class="input">
-            <input type="text" class="xlarge" id="name" name="name" size="50" class="required"
+            <input type="text" class="xlarge required" id="name" name="name" size="50"
                    data-bind="value: managedRepository().name"/>
           </div>
         </div>
         <div class="clearfix">
           <label for="location">${$.i18n.prop('directory')}</label>
           <div class="input">
-            <input type="text" class="xlarge" id="location" name="location" size="50" class="required" data-bind="value: managedRepository().location"/>
+            <input type="text" class="xlarge required" id="location" name="location" size="50" data-bind="value: managedRepository().location"/>
           </div>
         </div>
         <div class="clearfix">
         <div class="clearfix">
           <label for="cronExpression">${$.i18n.prop('cronExpression')}</label>
           <div class="input">
-            <input type="text" id="cronExpression" name="daysOlder" size="40" data-bind="value: managedRepository().cronExpression"/>
+            <input type="text" id="cronExpression" class="required" name="cronExpression" size="40" data-bind="value: managedRepository().cronExpression"/>
           </div>
         </div>
         <div class="clearfix">
           <label for="daysOlder">${$.i18n.prop('daysOlder')}</label>
           <div class="input">
-            <input type="text" id="daysOlder" name="daysOlder" size="5" data-bind="value: managedRepository().daysOlder"/>
+            <input type="text" id="daysOlder" class="digits" name="daysOlder" size="5" data-bind="value: managedRepository().daysOlder"/>
           </div>
         </div>
         <div class="clearfix">
index e9633e555538b717de888623fd2eecc9c5ad3e75..55813d8818a58a09c588a353f728f873f931de04 100644 (file)
@@ -569,7 +569,7 @@ $(function() {
    */
   changePassword=function(previousPassword,registration,user){
     var valid = $("#password-change-form").valid();
-    if (!valid) {
+    if (valid==false) {
         return;
     }
     $('#modal-password-change-footer').append(smallSpinnerImg());