]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1575] rewrite repositories group page
authorOlivier Lamy <olamy@apache.org>
Tue, 14 Feb 2012 23:00:02 +0000 (23:00 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 14 Feb 2012 23:00:02 +0000 (23:00 +0000)
add save button in grid.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1244261 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/repository-groups.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repository-groups.html

index e50a4d7b883c559109e9bfe902e888d023d539ca..1bcb049eb747c599a54cdf019be61467d32cf092 100644 (file)
@@ -53,6 +53,7 @@
 .draggable-item {
   cursor: move;
   margin-bottom: 12px;
+  margin-left: 4px;
   min-height: 2px;
   padding: 12px;
   border: 2px dotted #ddd;
   padding: 12px;
   border: 2px dotted #ddd;
   margin-left: 2em
+}
+
+.dotted{
+  margin-bottom: 12px;
+  min-height: 2px;
+  padding: 12px;
+  border: 2px dotted #ddd;
+  margin-left: 2em
 }
\ No newline at end of file
index 7490f959417bec4fd8378578381c00bb38b77705..00d1c6fa5a32359b0162803db4cacd50c6a34aea 100644 (file)
@@ -47,7 +47,7 @@ $(function() {
       $.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]);
+        repositories.push(self.repositoryGroup.managedRepositories()[i].id());
       }
       self.repositoryGroup.repositories(repositories);
       self.repositoryGroup.modified(true);
@@ -75,7 +75,31 @@ $(function() {
       ko.applyBindings(repositoryGroupViewModel,$("#main-content #repository-groups-edit" ).get(0));
     }
 
+    this.saveRepositoryGroup=function(repositoryGroup){
+        repositoryGroup.managedRepositories([]);
+        $.ajax("restServices/archivaServices/repositoryGroupService/updateRepositoryGroup",
+          {
+            type: "POST",
+            contentType: 'application/json',
+            data: "{\"repositoryGroup\": " + ko.toJSON(repositoryGroup)+"}",
+            dataType: 'json',
+            success: function(data) {
+              $.log("update repositoryGroup id:"+repositoryGroup.id());
+              var message=$.i18n.prop('repository.group.updated',repositoryGroup.id());
+              displaySuccessMessage(message);
+              repositoryGroup.modified(false);
+              if (!this.bulkMode){
+                //activateNetworkProxiesGridTab();
+              }
+            },
+            error: function(data) {
+              var res = $.parseJSON(data.responseText);
+              displayRestError(res);
+            }
+          }
+        );
 
+    }
 
     getManagedRepository=function(id){
       $.log("getManagedRepository:"+id);
index e17fa8086fca68fbfe3e78e8276c736df4106207..51e29a2866f0299f769b26e2d8a8b8d46ddd7330 100644 (file)
@@ -50,6 +50,7 @@
       <th>${$.i18n.prop('repository.groups.repositories.grid.header')}</th>
       <th>${$.i18n.prop('edit')}</th>
       <th>${$.i18n.prop('delete')}</th>
+      <th>${$.i18n.prop('save')}</th>
     </thead>
     <tbody>
     {{each(i, repositoryGroup) repositoryGroups}}
             <img src="images/edit-cut-22-22.png" title="${$.i18n.prop('delete')}"/>
           </a>
         </td>
+        <td>
+          {{if repositoryGroup.modified()}}
+            <a href="#" class="btn btn-warning" data-bind="click: function(){saveRepositoryGroup(repositoryGroup)}">
+              ${$.i18n.prop('save')}
+            </a>
+          {{/if}}
+        </td>
       </tr>
     {{/each}}
     </tbody>
 </script>
 
 <script id="repository-group-edit-tmpl" type="text/html">
+  {{if update}}
+    <div class="dotted span7">
+      <blockquote>
+        ${repositoryGroup.id}
+        <br/>
+        <a href="${window.archivaRuntimeInfo.baseUrl}/repository/${repositoryGroup.id()}" target="_blank">
+          ${window.archivaRuntimeInfo.baseUrl}/repository/${repositoryGroup.id()}
+        </a>
+      </blockquote>
+    </div>
+  {{else}}
   <form id="repository-group-edit-form" class="form-horizontal">
     <fieldset id="repository-group-edit-fieldset">
       <div class="control-group">
         <label class="control-label" for="id">${$.i18n.prop('id')}</label>
         <div class="controls">
-          {{if update}}
-            ${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"/>
-          {{/if}}
         </div>
       </div>
     </fieldset>
   </form>
+  {{/if}}
 </script>
 
 <script id="repository-group-edit-order-tmpl" type="text/html">