From 72067e2e2acee9b7d39b9900cb24123b779826f7 Mon Sep 17 00:00:00 2001 From: Arved Solth Date: Mon, 20 Sep 2021 14:17:24 +0200 Subject: [PATCH] Hide 'upload media' menu option if project folder configuration is incomplete --- .../forms/dataeditor/UploadFileDialog.java | 16 ++++++++++++++++ .../includes/metadataEditor/gallery.xhtml | 4 ++-- .../metadataEditor/logicalStructure.xhtml | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/UploadFileDialog.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/UploadFileDialog.java index 80ae17a53d0..44675a33ede 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/UploadFileDialog.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/UploadFileDialog.java @@ -228,6 +228,10 @@ private boolean setUpFolders() { Folder mediaView = dataEditor.getProcess().getProject().getMediaView(); Folder preview = dataEditor.getProcess().getProject().getPreview(); + if (Objects.isNull(sourceFolder) || Objects.isNull(mediaView) || Objects.isNull(preview)) { + return false; + } + sourceFolder.setPath(variableReplacer.replace(sourceFolder.getRelativePath())); mediaView.setPath(variableReplacer.replace(mediaView.getRelativePath())); preview.setPath(variableReplacer.replace(preview.getRelativePath())); @@ -440,5 +444,17 @@ public void refresh() throws NoSuchMetadataFieldException { } } + /** + * Check and return whether folder configuration of current process' project is + * complete, e.g. allows upload and conversion of media files. This means folders for thumbnails, + * detail views and generator source have to be configured in the project configuration. + * + * @return whether project folder configuration is complete or not + */ + public boolean isFolderConfigurationComplete() { + return Objects.nonNull(dataEditor.getProcess().getProject().getGeneratorSource()) + && Objects.nonNull(dataEditor.getProcess().getProject().getMediaView()) + && Objects.nonNull(dataEditor.getProcess().getProject().getPreview()); + } } diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/gallery.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/gallery.xhtml index 77e9f886c39..9bb135a55c1 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/gallery.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/gallery.xhtml @@ -390,7 +390,7 @@ imagePreviewForm:mediaContextMenu"/>