diff --git a/apps/dnet-is-application/src/main/resources/static/js/vocabularies.js b/apps/dnet-is-application/src/main/resources/static/js/vocabularies.js index 43bc6b50..13d1f8b0 100644 --- a/apps/dnet-is-application/src/main/resources/static/js/vocabularies.js +++ b/apps/dnet-is-application/src/main/resources/static/js/vocabularies.js @@ -1,7 +1,9 @@ var app = angular.module('vocabulariesApp', []); app.controller('vocabulariesController', function($scope, $http) { - $scope.vocabularies = []; + $scope.vocabularies = []; + $scope.tmpVoc = {}; + $scope.mode = ''; $scope.reload = function() { $http.get('./api/vocs/?' + $.now()).then(function successCallback(res) { @@ -10,16 +12,30 @@ app.controller('vocabulariesController', function($scope, $http) { alert('ERROR: ' + res.data.message); }); }; + + $scope.prepareNewVoc = function() { + $scope.mode = 'new'; + $scope.tmpVoc = { + 'id' : '', + 'name' : '', + 'description' : '' + }; + } + + $scope.prepareEditVoc = function(voc) { + $scope.mode = 'edit'; + $scope.tmpVoc = { + 'id' : voc.id, + 'name' : voc.name, + 'description' : voc.description + }; + } - $scope.newVocabulary = function(id, name, desc) { + $scope.saveVocabulary = function(voc) { $http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8"; - $http.post('./api/vocs/?' + $.now(), { - 'id' : id, - 'name' : name, - 'description' : desc - }).then(function successCallback(res) { + $http.post('./api/vocs/?' + $.now(), voc).then(function successCallback(res) { $scope.vocabularies = res.data; - alert("New vocabulary created"); + alert("Vocabulary saved"); }, function errorCallback(res) { alert('ERROR: ' + res.data.message); }); diff --git a/apps/dnet-is-application/src/main/resources/static/vocabularies.html b/apps/dnet-is-application/src/main/resources/static/vocabularies.html index 7ffad9fe..ce5af69d 100644 --- a/apps/dnet-is-application/src/main/resources/static/vocabularies.html +++ b/apps/dnet-is-application/src/main/resources/static/vocabularies.html @@ -20,7 +20,7 @@

Information Service - Vocabularies


- create a new vocabulary + create a new vocabulary

@@ -45,7 +45,10 @@ {{v.id}} {{v.name}} {{v.description}} - + + + + @@ -55,32 +58,34 @@ -