You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/01/24 16:52:56 UTC

svn commit: r1235310 - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva: repositories.js templates/repositories.html

Author: olamy
Date: Tue Jan 24 15:52:56 2012
New Revision: 1235310

URL: http://svn.apache.org/viewvc?rev=1235310&view=rev
Log:
[MRM-1574] remote repository edit form

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js?rev=1235310&r1=1235309&r2=1235310&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js Tue Jan 24 15:52:56 2012
@@ -200,7 +200,6 @@ $(function() {
             }
           }
         });
-        //addManagedRepository(self.managedRepository);
       }
     }
 
@@ -520,6 +519,23 @@ $(function() {
     return mappedRemoteRepositories;
   }
 
+  RemoteRepositoryViewModel=function(remoteRepository, update, remoteRepositoriesViewModel){
+    this.remoteRepository=remoteRepository;
+    this.remoteRepositoriesViewModel = remoteRepositoriesViewModel;
+    this.update = update;
+
+    var self = this;
+
+    this.availableLayouts = window.managedRepositoryTypes;
+
+    save=function(){
+
+    }
+
+    displayGrid=function(){
+      activateRemoteRepositoriesGridTab();
+    }
+  }
 
   RemoteRepositoriesViewModel=function(){
     this.remoteRepositories=ko.observableArray([]);
@@ -529,6 +545,11 @@ $(function() {
 
     editRemoteRepository=function(remoteRepository){
       $.log("editRemoteRepository");
+      var viewModel = new RemoteRepositoryViewModel(remoteRepository,true,self);
+      ko.applyBindings(viewModel,$("#main-content #remote-repository-edit").get(0));
+      activateRemoteRepositoryEditTab();
+      $("#remote-repository-edit-li a").html($.i18n.prop('edit'));
+      activateRemoteRepositoryFormValidation();
     }
 
     removeRemoteRepository=function(remoteRepository){
@@ -540,6 +561,42 @@ $(function() {
     }
   }
 
+  activateRemoteRepositoryFormValidation=function(){
+    $("#main-content #remote-repository-edit-form").validate({
+      /*rules: {
+        daysOlder : {
+          digits: true,
+          min: 1
+        },
+        retentionCount : {
+          digits: true,
+          min: 1,
+          max: 100
+        }
+      },*/
+      showErrors: function(validator, errorMap, errorList) {
+        customShowError(validator,errorMap,errorMap);
+      }
+    });
+  }
+
+  activateRemoteRepositoriesGridTab=function(){
+    $("#main-content #remote-repository-edit-li").removeClass("active");
+    $("#main-content #remote-repository-edit").removeClass("active");
+    // activate roles grid tab
+    $("#main-content #remote-repositories-view-li").addClass("active");
+    $("#main-content #remote-repositories-view").addClass("active");
+    $("#main-content #remote-repository-edit-li a").html($.i18n.prop("add"));
+  }
+
+  activateRemoteRepositoryEditTab=function(){
+    $("#main-content #remote-repositories-view-li").removeClass("active");
+    $("#main-content #remote-repositories-view").removeClass("active");
+    // activate role edit tab
+    $("#main-content #remote-repository-edit-li").addClass("active");
+    $("#main-content #remote-repository-edit").addClass("active");
+  }
+
   //---------------------------
   // Screen loading
   //---------------------------
@@ -646,6 +703,18 @@ $(function() {
 
     });
 
+    $("#main-content #remote-repositories-pills").bind('change', function (e) {
+      if ($(e.target).attr("href")=="#remote-repository-edit") {
+        var viewModel = new RemoteRepositoryViewModel(new RemoteRepository(),false,remoteRepositoriesViewModel);
+        ko.applyBindings(viewModel,$("#main-content #remote-repository-edit").get(0));
+        activateRemoteRepositoryFormValidation();
+      }
+      if ($(e.target).attr("href")=="#remote-repositories-view") {
+        $("#main-content #remote-repository-edit-li a").html($.i18n.prop("add"));
+      }
+
+    });
+
   }
 
 });
\ No newline at end of file

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html?rev=1235310&r1=1235309&r2=1235310&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html Tue Jan 24 15:52:56 2012
@@ -168,12 +168,12 @@
             <input type="text" class="xlarge" id="indexDirectory" name="indexDirectory" size="50" data-bind="value: managedRepository.indexDirectory"/>
           </div>
         </div>
-          <div class="clearfix">
-            <label for="layout">${$.i18n.prop('type')}</label>
-            <div class="input">
-              <select id="layout" data-bind="options: availableLayouts,optionsText: 'label',optionsValue:'type',value: managedRepository.layout"/>
-            </div>
+        <div class="clearfix">
+          <label for="layout">${$.i18n.prop('type')}</label>
+          <div class="input">
+            <select id="layout" data-bind="options: availableLayouts,optionsText: 'label',optionsValue:'type',value: managedRepository.layout"/>
           </div>
+        </div>
         <div class="clearfix">
           <label for="cronExpression">${$.i18n.prop('cronExpression')}</label>
           <div class="input">
@@ -326,4 +326,108 @@
       {{/each}}
   </tbody>
 
+</script>
+
+
+<script id="remote-repository-edit-tmpl" type='text/x-jquery-tmpl'>
+    <form id="remote-repository-edit-form">
+      <fieldset id="remote-repository-edit-fieldset">
+        <div class="clearfix">
+          <label for="name">${$.i18n.prop('id')}</label>
+          <div class="input">
+            {{if update}}
+              <span class="uneditable-input">${$data.remoteRepository.id}</span>
+            {{else}}
+              <input type="text" class="xlarge required" id="id" name="id" size="50"
+                     data-bind="value: remoteRepository.id,css:{'uneditable-input': update},readonly:update"/>
+            {{/if}}
+          </div>
+        </div>
+        <div class="clearfix">
+          <label for="name">${$.i18n.prop('name')}</label>
+          <div class="input">
+            <input type="text" class="xlarge required" id="name" name="name" size="50"
+                   data-bind="value: remoteRepository.name"/>
+          </div>
+        </div>
+        <div class="clearfix">
+          <label for="url">${$.i18n.prop('url')}</label>
+          <div class="input">
+            <input type="text" class="xlarge required" id="url" name="location" size="50" data-bind="value: remoteRepository.url"/>
+          </div>
+        </div>
+        <div class="clearfix">
+          <label for="userName">${$.i18n.prop('username')}</label>
+          <div class="input">
+            <input type="text" class="xlarge" id="userName" name="userName" size="50" data-bind="value: remoteRepository.indexDirectory"/>
+          </div>
+        </div>
+        <div class="clearfix">
+          <label for="password">${$.i18n.prop('password')}</label>
+           <div class="input">
+             <input type="password" class="xlarge" id="password" name="password" size="50" data-bind="value: remoteRepository.password"/>
+          </div>
+        </div>
+        <div class="clearfix">
+          <label for="timeout">${$.i18n.prop('timeout')}</label>
+          <div class="input">
+            <input type="text" id="timeout" class="digits" name="daysOlder" size="5" data-bind="value: remoteRepository.timeout"/>
+          </div>
+        </div>
+
+        <div class="clearfix">
+          <label for="layout">${$.i18n.prop('type')}</label>
+          <div class="input">
+            <select id="layout" data-bind="options: availableLayouts,optionsText: 'label',optionsValue:'type',value: remoteRepository.layout"/>
+          </div>
+        </div>
+        <div class="clearfix">
+          <label for="downloadRemoteIndex">${$.i18n.prop('downloadRemoteIndex')}</label>
+          <div class="input">
+            <input type="checkbox" id="downloadRemoteIndex" name="downloadRemoteIndex" size="5" data-bind="checked: remoteRepository.downloadRemoteIndex"/>
+          </div>
+        </div>
+
+        <div class="clearfix">
+          <label for="remoteIndexUrl">${$.i18n.prop('remoteIndexUrl')}</label>
+          <div class="input">
+            <input type="text" id="remoteIndexUrl" name="remoteIndexUrl" size="5" data-bind="value: remoteRepository.remoteIndexUrl"/>
+          </div>
+        </div>
+        <div class="clearfix">
+          <label for="cronExpression">${$.i18n.prop('cronExpression')}</label>
+          <div class="input">
+            <input type="text" id="cronExpression" class="required" name="cronExpression" size="40" data-bind="value: remoteRepository.cronExpression"/>
+          </div>
+        </div>
+        <div class="clearfix">
+          <label for="indexDirectory">${$.i18n.prop('index.directory')}</label>
+          <div class="input">
+            <input type="text" class="xlarge" id="indexDirectory" name="indexDirectory" size="50" data-bind="value: remoteRepository.indexDirectory"/>
+          </div>
+        </div>
+        <div class="clearfix">
+          <label for="remoteDownloadTimeout">${$.i18n.prop('remoteDownloadTimeout')}</label>
+          <div class="input">
+            <input type="text" id="remoteDownloadTimeout" class="digits" name="remoteDownloadTimeout" size="5"
+                   data-bind="value: remoteRepository.remoteDownloadTimeout"/>
+          </div>
+        </div>
+
+
+        <!-- proxy id to use -->
+
+
+        <div class="clearfix">
+          <label for="downloadRemoteIndexOnStartup">${$.i18n.prop('downloadRemoteIndexOnStartup')}</label>
+          <div class="input">
+            <input type="checkbox" id="downloadRemoteIndexOnStartup" name="downloadRemoteIndexOnStartup"
+                   data-bind="checked: remoteRepository.downloadRemoteIndexOnStartup"/>
+          </div>
+        </div>
+
+      </fieldset>
+      <button data-bind="click: save" class="btn">${$.i18n.prop('save')}</button>
+      <button data-bind="click: displayGrid" class="btn">${$.i18n.prop('cancel')}</button>
+    </form>
 </script>
\ No newline at end of file