From 9b1dbf351a88a981c4513a7f4feb1cba0b70a262 Mon Sep 17 00:00:00 2001 From: Benjamin Gamard Date: Wed, 15 May 2019 14:15:55 +0200 Subject: [PATCH] #300: custom metadata fields: UI admin --- .../resources/db/update/dbupdate-024-0.sql | 2 + docs-web/src/main/webapp/src/app/docs/app.js | 9 +++ .../controller/settings/SettingsMetadata.js | 31 ++++++++ docs-web/src/main/webapp/src/index.html | 1 + docs-web/src/main/webapp/src/locale/en.json | 7 ++ .../webapp/src/partial/docs/settings.html | 3 +- .../src/partial/docs/settings.inbox.html | 2 +- .../src/partial/docs/settings.metadata.html | 70 +++++++++++++++++ .../src/partial/docs/settings.vocabulary.html | 76 ++++++++++--------- 9 files changed, 163 insertions(+), 38 deletions(-) create mode 100644 docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsMetadata.js create mode 100644 docs-web/src/main/webapp/src/partial/docs/settings.metadata.html diff --git a/docs-core/src/main/resources/db/update/dbupdate-024-0.sql b/docs-core/src/main/resources/db/update/dbupdate-024-0.sql index 7ed6573b..aa649b83 100644 --- a/docs-core/src/main/resources/db/update/dbupdate-024-0.sql +++ b/docs-core/src/main/resources/db/update/dbupdate-024-0.sql @@ -1,3 +1,5 @@ create cached table T_METADATA ( MET_ID_C varchar(36) not null, MET_NAME_C varchar(50) not null, MET_TYPE_C varchar(20) not null, MET_DELETEDATE_D datetime, primary key (MET_ID_C) ); create cached table T_DOCUMENT_METADATA ( DME_ID_C varchar(36) not null, DME_IDDOCUMENT_C varchar(36) not null, DME_IDMETADATA_C varchar(36) not null, DME_VALUE_C varchar(4000) not null, DME_DELETEDATE_D datetime, primary key (DME_ID_C) ); +alter table T_DOCUMENT_METADATA add constraint FK_DME_IDDOCUMENT_C foreign key (DME_IDDOCUMENT_C) references T_DOCUMENT (DOC_ID_C) on delete restrict on update restrict; +alter table T_DOCUMENT_METADATA add constraint FK_DME_IDMETADATA_C foreign key (DME_IDMETADATA_C) references T_METADATA (MET_ID_C) on delete restrict on update restrict; update T_CONFIG set CFG_VALUE_C = '24' where CFG_ID_C = 'DB_VERSION'; 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 8ba0ffc3..fd0e97d1 100644 --- a/docs-web/src/main/webapp/src/app/docs/app.js +++ b/docs-web/src/main/webapp/src/app/docs/app.js @@ -145,6 +145,15 @@ angular.module('docs', } } }) + .state('settings.metadata', { + url: '/metadata', + views: { + 'settings': { + templateUrl: 'partial/docs/settings.metadata.html', + controller: 'SettingsMetadata' + } + } + }) .state('settings.user', { url: '/user', views: { diff --git a/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsMetadata.js b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsMetadata.js new file mode 100644 index 00000000..b8170cfd --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/controller/settings/SettingsMetadata.js @@ -0,0 +1,31 @@ +'use strict'; + +/** + * Settings metadata page controller. + */ +angular.module('docs').controller('SettingsMetadata', function($scope, Restangular) { + // Load metadata + Restangular.one('metadata').get().then(function(data) { + $scope.metadata = data.metadata; + }); + + // Add a metadata + $scope.addMetadata = function() { + Restangular.one('metadata').put($scope.newmetadata).then(function(data) { + $scope.metadata.push(data); + $scope.newmetadata = {}; + }); + }; + + // Delete a metadata + $scope.deleteMetadata = function(meta) { + Restangular.one('metadata', meta.id).remove().then(function() { + $scope.metadata.splice($scope.metadata.indexOf(meta), 1); + }); + }; + + // Update a metadata + $scope.updateMetadata = function(meta) { + Restangular.one('metadata', meta.id).post('', meta); + }; +}); \ 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 959419b9..1684bb2f 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -93,6 +93,7 @@ + diff --git a/docs-web/src/main/webapp/src/locale/en.json b/docs-web/src/main/webapp/src/locale/en.json index af7c70fe..6dd8432f 100644 --- a/docs-web/src/main/webapp/src/locale/en.json +++ b/docs-web/src/main/webapp/src/locale/en.json @@ -278,6 +278,7 @@ "menu_vocabularies": "Vocabularies", "menu_configuration": "Configuration", "menu_inbox": "Inbox scanning", + "menu_metadata": "Custom metadata", "menu_monitoring": "Monitoring", "user": { "title": "Users management", @@ -412,6 +413,12 @@ "webhook_create_date": "Create date", "webhook_add": "Add a webhook" }, + "metadata": { + "title": "Custom metadata configuration", + "message": "Here you can add custom metadata to your documents like an internal identifier or an expiration date. Please note that the metadata type cannot be changed after creation.", + "name": "Metadata name", + "type": "Metadata type" + }, "inbox": { "title": "Inbox scanning", "message": "By enabling this feature, the system will scan the specified inbox every minute for unread emails and automatically import them.
After importing an email, it will be marked as read.
Configuration settings for Gmail, Outlook.com, Yahoo.", 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 cf80bd39..30b531e2 100644 --- a/docs-web/src/main/webapp/src/partial/docs/settings.html +++ b/docs-web/src/main/webapp/src/partial/docs/settings.html @@ -16,9 +16,10 @@ {{ 'settings.menu_workflow' | translate }} {{ 'settings.menu_users' | translate }} {{ 'settings.menu_groups' | translate }} - {{ 'settings.menu_inbox' | translate }} {{ 'settings.menu_vocabularies' | translate }} {{ 'settings.menu_configuration' | translate }} + {{ 'settings.menu_metadata' | translate }} + {{ 'settings.menu_inbox' | translate }} {{ 'settings.menu_monitoring' | translate }} diff --git a/docs-web/src/main/webapp/src/partial/docs/settings.inbox.html b/docs-web/src/main/webapp/src/partial/docs/settings.inbox.html index 4cb4c109..6e27a7c6 100644 --- a/docs-web/src/main/webapp/src/partial/docs/settings.inbox.html +++ b/docs-web/src/main/webapp/src/partial/docs/settings.inbox.html @@ -46,7 +46,7 @@
- +
+
+
+ {{ 'validation.required' | translate }} + {{ 'validation.too_long' | translate }} +
+
+ +
+ +
+ +
+
+ {{ 'validation.required' | translate }} +
+
+ +
+
+ +
+
+ + + +
+
+ + + + + + + + + + + + + + + +
{{ 'settings.metadata.name' | translate }}{{ 'settings.metadata.type' | translate }}
+ + + {{ meta.type }} + + +
+
+
\ No newline at end of file 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 index cc2aa997..bc0194ad 100644 --- a/docs-web/src/main/webapp/src/partial/docs/settings.vocabulary.html +++ b/docs-web/src/main/webapp/src/partial/docs/settings.vocabulary.html @@ -11,41 +11,45 @@ + - - - - - - - - - - - - - - - - - - - - - - - -
{{ 'settings.vocabulary.value' | translate }}{{ 'settings.vocabulary.order' | translate }}
- - - - - -
 
- - - - - -
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
{{ 'settings.vocabulary.value' | translate }}{{ 'settings.vocabulary.order' | translate }}
+ + + + + +
 
+ + + + + +
+
\ No newline at end of file