From dd7f8aa778ebe9408028fd194201eace376db488 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 24 Jan 2012 15:52:56 +0000 Subject: [PATCH] [MRM-1574] remote repository edit form git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1235310 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/webapp/js/archiva/repositories.js | 71 ++++++++++- .../js/archiva/templates/repositories.html | 114 +++++++++++++++++- 2 files changed, 179 insertions(+), 6 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js index c4675944b..ff95ca72d 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js @@ -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 diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html index 61bd47802..59412cc75 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html @@ -168,12 +168,12 @@ -
- -
-
+
@@ -326,4 +326,108 @@ {{/each}} + + + + \ No newline at end of file -- 2.39.5