]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1574] add select box for defining repository type.
authorOlivier Lamy <olamy@apache.org>
Wed, 18 Jan 2012 13:43:23 +0000 (13:43 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 18 Jan 2012 13:43:23 +0000 (13:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1232878 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

index 6e2ba43930ae3a61806206cc156fee81fe64af9d..0b90ed946826ac8e896a2ce275042fd457aa621e 100644 (file)
  */
 $(function() {
 
+  // FIXME this must be dynamic if we do a plugin mechanism with dynamic repositories types
+  // FIXME i18n
+
+  ManagedRepositoryType=function(type,label){
+    this.type=type;
+    this.label=label;
+  }
+
+  window.managedRepositoryTypes = [
+            new ManagedRepositoryType("default","Maven 2.x Repository"),
+            new ManagedRepositoryType("legacy", "Maven 1.x Repository")
+            ];
+
   ManagedRepository=function(id,name,layout,indexDirectory,location,snapshots,releases,blockRedeployments,cronExpression,
                              scanned,daysOlder,retentionCount,deleteReleasedSnapshots,stageRepoNeeded){
 
@@ -66,6 +79,16 @@ $(function() {
     //private boolean blockRedeployments = false;
     this.blockRedeployments=ko.observable(blockRedeployments);
 
+    var self=this;
+
+    this.getTypeLabel=function(){
+      for(i=0;i<window.managedRepositoryTypes.length;i++){
+        if (window.managedRepositoryTypes[i].type==self.layout()){
+          return window.managedRepositoryTypes[i].label;
+        }
+      }
+      return "no label";
+    }
 
   }
 
@@ -73,8 +96,20 @@ $(function() {
     this.managedRepository=managedRepository;
     this.managedRepositoriesViewModel = managedRepositoriesViewModel;
     this.update = update;
+
     var self = this;
 
+    this.availableLayouts = window.managedRepositoryTypes;
+
+    /*getAvailableLayouts=function(){
+      var layouts = new Array(window.managedRepositoryTypes.length);
+      for(var i=0;i<window.managedRepositoryTypes.length;i++){
+        layouts[i]=window.managedRepositoryTypes[i].label;
+      }
+      $.log("layouts.length:"+layouts.length)
+      return layouts;
+    }*/
+
     save=function(){
       var valid = $("#main-content #managed-repository-edit-form").valid();
       if (valid==false) {
@@ -258,10 +293,10 @@ $(function() {
                 rowText: "name"
               },
               {
-                headerText: $.i18n.prop('type'),
-                rowText: "layout",
-                // FIXME i18n
-                title: "Repository type (default is Maven 2)"
+              headerText: $.i18n.prop('type'),
+              rowText: "getTypeLabel",
+              // FIXME i18n
+              title: "Repository type (default is Maven 2)"
               }
             ],
             pageSize: 5
index 9d4e88e98dc2565baac5e86a7080e8c921d040fe..2eef3caff46835a17c1fc8d223cb051493857fb2 100644 (file)
             <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>
         <div class="clearfix">
           <label for="cronExpression">${$.i18n.prop('cronExpression')}</label>
           <div class="input">