From ed51b77b0ec7c3f0acc57e920d019bdc2281ac1a Mon Sep 17 00:00:00 2001 From: jendib Date: Sun, 14 Feb 2016 21:51:46 +0100 Subject: [PATCH] #65: Vocabulary admin UI --- docs-web/src/main/webapp/src/app/docs/app.js | 9 ++++ .../app/docs/controller/SettingsVocabulary.js | 42 +++++++++++++++ docs-web/src/main/webapp/src/index.html | 1 + .../webapp/src/partial/docs/settings.html | 1 + .../src/partial/docs/settings.vocabulary.html | 51 +++++++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 docs-web/src/main/webapp/src/app/docs/controller/SettingsVocabulary.js create mode 100644 docs-web/src/main/webapp/src/partial/docs/settings.vocabulary.html diff --git a/docs-web/src/main/webapp/src/app/docs/app.js b/docs-web/src/main/webapp/src/app/docs/app.js index 9e1891fa..4a1f981e 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -106,6 +106,15 @@ angular.module('docs', } } }) + .state('settings.vocabulary', { + url: '/vocabulary', + views: { + 'settings': { + templateUrl: 'partial/docs/settings.vocabulary.html', + controller: 'SettingsVocabulary' + } + } + }) .state('document', { url: '/document', abstract: true, diff --git a/docs-web/src/main/webapp/src/app/docs/controller/SettingsVocabulary.js b/docs-web/src/main/webapp/src/app/docs/controller/SettingsVocabulary.js new file mode 100644 index 00000000..e23cf437 --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/SettingsVocabulary.js @@ -0,0 +1,42 @@ +'use strict'; + +/** + * Settings vocabulary page controller. + */ +angular.module('docs').controller('SettingsVocabulary', function($scope, Restangular) { + $scope.entries = []; + + // Watch for vocabulary selection change + $scope.$watch('vocabulary', function(name) { + if (_.isUndefined(name) || name == '') { + $scope.entries = []; + return; + } + + // Load entries + Restangular.one('vocabulary', name).get().then(function(result) { + $scope.entries = result.entries; + }); + }); + + // Delete an entry + $scope.deleteEntry = function(entry) { + Restangular.one('vocabulary', entry.id).remove().then(function() { + $scope.entries.splice($scope.entries.indexOf(entry), 1); + }); + }; + + // Update an entry + $scope.updateEntry = function(entry) { + Restangular.one('vocabulary', entry.id).post('', entry); + }; + + // Add an entry + $scope.addEntry = function(entry) { + entry.name = $scope.vocabulary; + Restangular.one('vocabulary').put(entry).then(function() { + $scope.entries.push(entry); + $scope.entry = {}; + }); + }; +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index e17c2c29..a49b177c 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -60,6 +60,7 @@ + diff --git a/docs-web/src/main/webapp/src/partial/docs/settings.html b/docs-web/src/main/webapp/src/partial/docs/settings.html index d3246e12..4bc1a5d0 100644 --- a/docs-web/src/main/webapp/src/partial/docs/settings.html +++ b/docs-web/src/main/webapp/src/partial/docs/settings.html @@ -12,6 +12,7 @@
General settings
diff --git a/docs-web/src/main/webapp/src/partial/docs/settings.vocabulary.html b/docs-web/src/main/webapp/src/partial/docs/settings.vocabulary.html new file mode 100644 index 00000000..0ec5abd9 --- /dev/null +++ b/docs-web/src/main/webapp/src/partial/docs/settings.vocabulary.html @@ -0,0 +1,51 @@ +

Vocabulary entries

+ +
+
+
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
ValueOrder
+ + + + + +
 
+ + + + + +
+
\ No newline at end of file