From fd428b30b92de28b13495c7c7d4c5b3c984ecec9 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 26 Mar 2012 09:55:52 +0000 Subject: [PATCH] artifact metadata property add/delete implemented git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1305283 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/js/archiva/search.js | 70 ++++++++++--------- .../webapp/js/archiva/templates/search.html | 20 +++--- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js index ffc5fc191..8c0b9f5fc 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js @@ -261,7 +261,10 @@ $(function() { type: "GET", dataType: 'json', success: function(data) { - self.entries([new MetadataEntry("foo","bar")]); + var entries= $.map(data,function(e,i){ + return new MetadataEntry( e.key, e.value,false); + }); + self.entries(entries); } }); //} @@ -298,48 +301,49 @@ $(function() { } deleteProperty=function(entry){ + var metadatasUrl="restServices/archivaServices/browseService/metadata/"+encodeURIComponent(groupId); + metadatasUrl+="/"+encodeURIComponent(artifactId); + metadatasUrl+="/"+encodeURIComponent(version); + metadatasUrl+="/"+encodeURIComponent(entry.key()); + var selectedRepo=getSelectedBrowsingRepository(); + if (selectedRepo){ + metadatasUrl+="?repositoryId="+encodeURIComponent(selectedRepo); + } + $.ajax(metadatasUrl, { + type: "DELETE", + dataType: 'json', + success: function(data) { + displaySuccessMessage( $.i18n.prop("artifact.metadata.deleted")); + self.entries.remove(entry); + } + }); - self.entries.remove(entry); } saveProperty=function(entry){ - var metadatasContentDiv=mainContent.find("#artifact-details-metadatas-content" ); - //if( $.trim(metadatasContentDiv.html()).length<1){ - //metadatasContentDiv.html(mediumSpinnerImg()); - var metadatasUrl="restServices/archivaServices/browseService/metadatas/"+encodeURIComponent(groupId); - metadatasUrl+="/"+encodeURIComponent(artifactId); - metadatasUrl+="/"+encodeURIComponent(version); - metadatasUrl+="/"+encodeURIComponent(entry.key()); - metadatasUrl+="/"+encodeURIComponent(entry.value()); - var selectedRepo=getSelectedBrowsingRepository(); - if (selectedRepo){ - metadatasUrl+="?repositoryId="+encodeURIComponent(selectedRepo); + var metadatasUrl="restServices/archivaServices/browseService/metadata/"+encodeURIComponent(groupId); + metadatasUrl+="/"+encodeURIComponent(artifactId); + metadatasUrl+="/"+encodeURIComponent(version); + metadatasUrl+="/"+encodeURIComponent(entry.key()); + metadatasUrl+="/"+encodeURIComponent(entry.value()); + var selectedRepo=getSelectedBrowsingRepository(); + if (selectedRepo){ + metadatasUrl+="?repositoryId="+encodeURIComponent(selectedRepo); + } + $.ajax(metadatasUrl, { + type: "PUT", + dataType: 'json', + success: function(data) { + displaySuccessMessage( $.i18n.prop("artifact.metadata.added")); + entry.editable(false); + entry.modified(false); } - $.ajax(metadatasUrl, { - type: "PUT", - dataType: 'json', - success: function(data) { - displaySuccessMessage( $.i18n.prop("artifact.metadata.added")); - entry.modified(false); - } - }); + }); } this.gridMetatadasViewModel = new ko.simpleGrid.viewModel({ data: self.entries, - columns: [ - { - headerText: $.i18n.prop('browse.artifact.metadata.key'), - rowText: "key", - id: "key" - }, - { - headerText: $.i18n.prop('browse.artifact.metadata.value'), - rowText: "value", - id: "value" - } - ], pageSize: 10 }); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html index 35ff4f119..19595d3f6 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html @@ -745,24 +745,22 @@