]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1575] rewrite repositories group page
authorOlivier Lamy <olamy@apache.org>
Tue, 14 Feb 2012 22:59:47 +0000 (22:59 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 14 Feb 2012 22:59:47 +0000 (22:59 +0000)
fix ordering with drag&drop.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1244259 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/css/archiva.css
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/network-proxies.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js
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/repository-groups.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/proxy-connectors.html
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repository-groups.html

index 9a556f95f354adbd628440a245f587cd48f5b31a..e50a4d7b883c559109e9bfe902e888d023d539ca 100644 (file)
 }
 
 .draggable-item {
-    cursor: move;
+  cursor: move;
+  margin-bottom: 12px;
+  min-height: 2px;
+  padding: 12px;
+  border: 2px dotted #ddd;
+  margin-left: 2em
 }
 
 .network-proxy-remote-item{
index e36225fe16e090cf41729b4c28c5c120954fee0d..800dc1967ea94c89a99fd11921152d84477dad20 100644 (file)
@@ -154,7 +154,7 @@ $(function() {
       var modifiedNetworkProxies = getModifiedNetworkProxies();
 
       openDialogConfirm(function(){
-                          for(i=0;i<modifiedNetworkProxies.length;i++){
+                          for(var i=0;i<modifiedNetworkProxies.length;i++){
                             var viewModel = new NetworkProxyViewModel(modifiedNetworkProxies[i],true,self,false);
                             viewModel.save();
                           }
index 1d78c139eab469eed59c4748b363d36b3081177d..bc3938a6eb2e8a8bbeb8f1c78a532e5f287220a5 100644 (file)
@@ -80,7 +80,7 @@ $(function() {
     //this.modified.subscribe(function(newValue){$.log("ProxyConnector modified:"+newValue)});
 
     this.updatePolicyEntry=function(key,value){
-      for(i=0;i<policiesEntries.length;i++){
+      for(var i=0;i<policiesEntries.length;i++){
         if (policiesEntries[i].key==key){
           policiesEntries[i].value=value;
           self.modified(true);
@@ -145,7 +145,7 @@ $(function() {
 
     getPolicyOptions=function(id){
       var policyInformations=self.proxyConnectorsViewModel.policyInformations();
-      for(i=0;i<policyInformations.length;i++){
+      for(var i=0;i<policyInformations.length;i++){
         if (policyInformations[i].id()==id){
           return policyInformations[i].options();
         }
@@ -227,7 +227,7 @@ $(function() {
     }
 
     this.deleteProperty=function(key){
-      for(i=0;i<self.proxyConnector.propertiesEntries().length;i++){
+      for(var i=0;i<self.proxyConnector.propertiesEntries().length;i++){
         var entry=self.proxyConnector.propertiesEntries()[i];
         if (entry.key()==key()){
           self.proxyConnector.propertiesEntries.remove(entry);
@@ -286,7 +286,7 @@ $(function() {
       var modifiedProxyConnectors = getModifiedProxyConnectors();
 
       openDialogConfirm(function(){
-                          for(i=0;i<modifiedProxyConnectors.length;i++){
+                          for(var i=0;i<modifiedProxyConnectors.length;i++){
                             var viewModel = new ProxyConnectorViewModel(modifiedProxyConnectors[i],true,self,false);
                             viewModel.save();
                           }
@@ -388,7 +388,7 @@ $(function() {
     }
 
     this.findPolicyInformationName=function(id){
-      for(i=0;i<self.policyInformations().length;i++){
+      for(var i=0;i<self.policyInformations().length;i++){
         if (id==self.policyInformations()[i].id()){
           return self.policyInformations()[i].name();
         }
@@ -478,7 +478,7 @@ $(function() {
 
     this.findRemoteRepository=function(id){
       $.log("findRemoteRepository:"+id());
-      for(i=0;i<self.proxyConnectorsViewModel.remoteRepositories().length;i++){
+      for(var i=0;i<self.proxyConnectorsViewModel.remoteRepositories().length;i++){
         if (self.proxyConnectorsViewModel.remoteRepositories()[i].id()==id()){
           return self.proxyConnectorsViewModel.remoteRepositories()[i];
         }
index 29ca8f69bcc258665f6ba2aaa799201539bc61be..b4fa9262bd6131e70cd92701b8ad62792ba79c8d 100644 (file)
@@ -97,7 +97,7 @@ $(function() {
 
 
     this.getTypeLabel=function(){
-      for(i=0;i<window.managedRepositoryTypes.length;i++){
+      for(var i=0;i<window.managedRepositoryTypes.length;i++){
         if (window.managedRepositoryTypes[i].type==self.layout()){
           return window.managedRepositoryTypes[i].label;
         }
@@ -574,7 +574,7 @@ $(function() {
     this.downloadRemoteIndexOnStartup.subscribe(function(newValue){self.modified(true)});
 
     this.getTypeLabel=function(){
-      for(i=0;i<window.managedRepositoryTypes.length;i++){
+      for(var i=0;i<window.managedRepositoryTypes.length;i++){
         if (window.managedRepositoryTypes[i].type==self.layout()){
           return window.managedRepositoryTypes[i].label;
         }
@@ -725,7 +725,7 @@ $(function() {
       var modifiedRemoteRepositories = getModifiedRemoteRepositories();
 
       openDialogConfirm(function(){
-                          for(i=0;i<modifiedRemoteRepositories.length;i++){
+                          for(var i=0;i<modifiedRemoteRepositories.length;i++){
                             updateRemoteRepository(modifiedRemoteRepositories[i]);
                           }
                           closeDialogConfirm();
index 8d1b9195b2abc32d03ca8fbdb464f19d92af7fad..7490f959417bec4fd8378578381c00bb38b77705 100644 (file)
@@ -30,13 +30,29 @@ $(function() {
     this.repositories=ko.observableArray(repositories);
     this.repositories.subscribe(function(newValue){self.modified(true)});
 
+    // to store managedRepositories description not sended to server
+    this.managedRepositories=ko.observableArray([]);
+    this.managedRepositories.subscribe(function(newValue){self.modified(true)});
+
     this.modified=ko.observable(false);
   }
 
   RepositoryGroupViewModel=function(repositoryGroup,update,repositoryGroupsViewModel){
+    var self = this;
     this.repositoryGroup=repositoryGroup;
     this.update=update;
-    this.repositoryGroupsViewModel=null;
+    this.repositoryGroupsViewModel=repositoryGroupsViewModel;
+
+    repositoryMoved=function(arg){
+      $.log("repositoryMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
+      var repositories=[];
+      for(var i=0;i<self.repositoryGroup.managedRepositories().length;i++){
+        repositories.push(self.repositoryGroup.managedRepositories()[i]);
+      }
+      self.repositoryGroup.repositories(repositories);
+      self.repositoryGroup.modified(true);
+    }
+
   }
 
   RepositoryGroupsViewModel=function(){
@@ -53,20 +69,19 @@ $(function() {
     }
 
     this.editRepositoryGroup=function(repositoryGroup){
-      $.log("editRepositoryGroup:"+repositoryGroup.id());
+      $.log("editRepositoryGroup:"+repositoryGroup.id()+",repositories:"+repositoryGroup.repositories().length+",managed:"+repositoryGroup.managedRepositories().length);
       var repositoryGroupViewModel=new RepositoryGroupViewModel(repositoryGroup,true,self);
       activateRepositoryGroupEditTab();
       ko.applyBindings(repositoryGroupViewModel,$("#main-content #repository-groups-edit" ).get(0));
     }
 
-    repositoryMoved=function(){
-      $.log("repositoryMoved");
-    }
+
 
     getManagedRepository=function(id){
       $.log("getManagedRepository:"+id);
       return findManagedRepository(self.managedRepositories());
     }
+
   }
 
   displayRepositoryGroups=function(){
@@ -84,9 +99,13 @@ $(function() {
           dataType: 'json',
           success: function(data) {
             var mappedRepositoryGroups=mapRepositoryGroups(data);
+            for(var i=0;i<mappedRepositoryGroups.length;i++){
+              mappedRepositoryGroups[i]
+                  .managedRepositories(self.mapManagedRepositoriesToRepositoryGroup(mappedRepositoryGroups[i]));
+              mappedRepositoryGroups[i].modified(false);
+            }
             mainContent.html($("#repositoryGroupsMain").tmpl());
             self.repositoryGroupsViewModel.repositoryGroups(mappedRepositoryGroups);
-            //ko.applyBindings(repositoryGroupViewModel,mainContent.find("#repository-groups-table" ).get(0));
             ko.applyBindings(repositoryGroupsViewModel,mainContent.find("#repository-groups-view" ).get(0));
 
           }
@@ -95,9 +114,18 @@ $(function() {
 
     });
 
+    this.mapManagedRepositoriesToRepositoryGroup=function(repositoryGroup){
+      var managedRepositories=[];
+      for(var i=0;i<repositoryGroup.repositories().length;i++){
+        managedRepositories.push(self.repositoryGroupsViewModel.findManagedRepository(repositoryGroup.repositories()[i]));
+      }
+      return managedRepositories;
+    }
 
   }
 
+
+
   activateRepositoryGroupsGridTab=function(){
     var mainContent = $("#main-content");
     mainContent.find("#repository-groups-view-tabs-content div[class*='tab-pane']").removeClass("active");
index b0877f79f4a2582b30a230c437b2ce110379e94b..f61e55d34efab186cec9a617c3f5b7d43a8be1c2 100644 (file)
     </div>
     <div class="span6">
       <blockquote>
-          ${managedRepository.id}
-          <br/>
-          ${managedRepository.name}
+        ${managedRepository.id}
+        <br/>
+        ${managedRepository.name}
       </blockquote>
     </div>
     <div class="span2">
       {{if proxyConnectorsViewModel.bulkSave()}}
         <p>
-           <a data-bind="click: function(){updateModifiedProxyConnectors()}"
-              href="#" class="btn btn-warning">${$.i18n.prop('save.all')}</a></p>
+          <a data-bind="click: function(){updateModifiedProxyConnectors()}"
+             href="#" class="btn btn-warning">${$.i18n.prop('save.all')}</a></p>
       {{/if}}
     </div>
   </div>
index 7b6288fbdd01d80c7ef390163e8ddba7179bd599..e17fa8086fca68fbfe3e78e8276c736df4106207 100644 (file)
@@ -37,7 +37,7 @@
     <div id="repository-groups-edit" class="tab-pane active">
         <div id="repository-groups-edit-div" data-bind='template:{name:"repository-group-edit-tmpl"}'></div>
         <div id="repository-groups-edit-order-div"
-             data-bind="sortable: { template: 'repository-group-edit-order-tmpl',data:repositoryGroup.repositories,afterMove: repositoryMoved}">
+             data-bind="sortable: { template: 'repository-group-edit-order-tmpl',data:repositoryGroup.managedRepositories,afterMove: repositoryMoved}">
         </div>
     </div>
   </div>  
@@ -53,7 +53,7 @@
     </thead>
     <tbody>
     {{each(i, repositoryGroup) repositoryGroups}}
-      <tr>
+      <tr data-bind="css:{ 'modified': repositoryGroup.modified()}">
         <td>${repositoryGroup.id}</td>
         <td>
           <ul>
         <label class="control-label" for="id">${$.i18n.prop('id')}</label>
         <div class="controls">
           {{if update}}
-            <span class="uneditable-input">${repositoryGroup.id}</span>
+            ${repositoryGroup.id}
+            <br/>
+            <a href="${window.archivaRuntimeInfo.baseUrl}/repository/${repositoryGroup.id()}" target="_blank">
+                ${window.archivaRuntimeInfo.baseUrl}/repository/${repositoryGroup.id()}
+            </a>
+
           {{else}}
             <input type="text" class="xlarge required" id="id" name="id" size="50"
                    data-bind="value: repositoryGroup.id,css:{'uneditable-input': update},readonly:update"/>
 </script>
 
 <script id="repository-group-edit-order-tmpl" type="text/html">
-  <div class="well draggable-item">
-    ${$data}-${managedRepository.name()}
+  <div class="well draggable-item span6">
+    <blockquote>
+      ${$data.id()}
+      <br/>
+      ${$data.name()}
+      <br/>
+      ${window.archivaRuntimeInfo.baseUrl}/repository/${$data.id()}
+      <br/>
+    </blockquote>
+
   </div>
 </script>
\ No newline at end of file