From 075c26bf739368f8d347f7eb3954348f1b79f511 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 13 Feb 2012 13:54:39 +0000 Subject: [PATCH] [MRM-1576] rewrite proxies connector page order with drag&drop git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1243511 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/index.html | 1 + .../webapp/js/archiva/proxy-connectors.js | 59 +++++++++++++++++-- .../archiva/templates/proxy-connectors.html | 26 +++++++- 3 files changed, 81 insertions(+), 5 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html index e3766a62e..ae5e8d7b1 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html @@ -89,6 +89,7 @@ $.ajax( .script(buildLoadJsUrl("redback/redback-tmpl.js")).wait() .script(buildLoadJsUrl("bootstrap.js")) .script(buildLoadJsUrl("knockout.simpleGrid.js")) + .script(buildLoadJsUrl("knockout-sortable.js")) //.script("knockout.mapping-latest.debug.js") .script(buildLoadJsUrl("redback/user.js")).wait() .script(buildLoadJsUrl("redback/users.js")).wait() diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js index d1c2d312a..92422f32f 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors.js @@ -269,6 +269,7 @@ $(function() { this.remoteRepositories=ko.observableArray([]); this.networkProxies=ko.observableArray([]); + this.bulkSave=function(){ return getModifiedProxyConnectors().length>0; } @@ -389,6 +390,25 @@ $(function() { return null; } + orderChangeAware=function(proxyConnector){ + return findProxyConnectorsWithSourceId(proxyConnector).length>1; + } + + findProxyConnectorsWithSourceId=function(proxyConnector){ + return $.grep(self.proxyConnectors(),function(curProxyConnector,idx){ + return curProxyConnector.sourceRepoId()==proxyConnector.sourceRepoId(); + } + ); + } + + displayOrderEdit=function(proxyConnector){ + var proxyConnectors=findProxyConnectorsWithSourceId(proxyConnector); + $.log("displayOrderEdit:"+proxyConnector.sourceRepoId()+",number:"+proxyConnectors.length); + + var proxyConnectorEditOrderViewModel=new ProxyConnectorEditOrderViewModel(proxyConnectors); + ko.applyBindings(proxyConnectorEditOrderViewModel,$("#main-content #proxy-connector-edit-order").get(0)); + activateProxyConnectorsEditOrderTab(); + } this.displayGrid=function(){ this.gridViewModel = new ko.simpleGrid.viewModel({ @@ -428,6 +448,26 @@ $(function() { } + ProxyConnectorEditOrderViewModel=function(proxyConnectors,proxyConnectorsViewModel){ + var self=this; + this.proxyConnectors=ko.observableArray(proxyConnectors); + this.proxyConnectorsViewModel=proxyConnectorsViewModel; + + proxyConnectorMoved=function(arg){ + $.log("proxyConnectorMoved:"+arg.sourceIndex+" to " + arg.targetIndex); + // if only 1 move just update two whereas update all with the new order + if (arg.targetIndex-arg.sourceIndex==1){ + self.proxyConnectors()[arg.targetIndex].order(arg.targetIndex+1); + self.proxyConnectors()[arg.sourceIndex].order(arg.sourceIndex+1); + } else { + for (i=0;i ${$.i18n.prop('add')} +
  • + ${$.i18n.prop('proxy-connectors.grid.tab.edit.order')} +
  • @@ -38,6 +41,11 @@
    +
    +
      +
    +
    @@ -55,13 +63,14 @@ ${$.i18n.prop('edit')} ${$.i18n.prop('delete')} ${$.i18n.prop('save')} + ${$.i18n.prop('proxy-connectors.grid.header.order')} {{each(i, row) itemsOnCurrentPage()}} ${row.sourceRepoId()} - ${row.targetRepoId()}-${row.order()} + ${row.targetRepoId()} @@ -84,6 +93,13 @@ {{/if}} + + {{if orderChangeAware(row)}} + + ${$.i18n.prop('proxy-connectors.order.edit')} + + {{/if}} + {{/each}} @@ -228,3 +244,11 @@ ${$.i18n.prop('save.all')} {{/if}} + + \ No newline at end of file -- 2.39.5