From 85207bb946cc31b69a5a491568abef48b462fe50 Mon Sep 17 00:00:00 2001 From: Thomas Low Date: Tue, 5 Nov 2024 17:19:56 +0000 Subject: [PATCH 1/7] Add navigation buttons to detail view of the metadata editor. --- .../webapp/WEB-INF/resources/css/kitodo.css | 24 +++++++++++++++++++ .../partials/media-detail.xhtml | 11 +++++++++ 2 files changed, 35 insertions(+) diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index 301f0e545be..fd770364871 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -3265,6 +3265,7 @@ Column content width: calc(100% - 100px); align-items: center; justify-content: left; + position: relative; } #imagePreviewForm\:mediaDetailMediaContainer { @@ -3426,6 +3427,29 @@ Column content background-color: var(--blue); } +#imagePreviewForm .mediaDetailNavigationPanel { + position: absolute; + width: 100%; + bottom: 0; + text-align: center; + pointer-events: none; +} + +#imagePreviewForm .mediaDetailNavigationPanel button { + margin: var(--default-full-size); + pointer-events: all; + opacity: 0.0; + transition: opacity 0.1s linear; +} + +#imagePreviewForm:hover .mediaDetailNavigationPanel button { + opacity: 1.0; +} + +#imagePreviewForm .mediaDetailNavigationPanel button:hover { + background: var(--blue); +} + #galleryWrapperPanel, #galleryWrapperPanel_content { height: 100%; diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml index d3f619b955f..425acde0df7 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml @@ -91,6 +91,17 @@ + + + + + From 8e440edd2e143f4c09cfebf6aeab61e2104e8f80 Mon Sep 17 00:00:00 2001 From: Thomas Low Date: Tue, 5 Nov 2024 18:22:39 +0000 Subject: [PATCH 2/7] Disable detail view navigation buttons if first or last media is selected. Add title to buttons. --- .../forms/dataeditor/GalleryPanel.java | 56 +++++++++++++++++++ .../resources/messages/messages_de.properties | 2 + .../resources/messages/messages_en.properties | 2 + .../resources/messages/messages_es.properties | 4 ++ .../webapp/WEB-INF/resources/css/kitodo.css | 2 +- .../partials/media-detail.xhtml | 6 +- 6 files changed, 69 insertions(+), 3 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java index ada4f3655ee..8c9541c9306 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java @@ -1048,4 +1048,60 @@ public boolean hasMediaViewMimeTypePrefix(String mimeTypePrefix) { public MediaPartialsPanel getMediaPartialsPanel() { return mediaPartialsPanel; } + + /** + * Return true if the currently selected media (that is shown in the detail view) is the verify + * first media of all available media. + * @return boolean true if selected media is first media + */ + public boolean isSelectedMediaFirst() { + Pair lastSelection = getLastSelection(); + if (Objects.isNull(lastSelection)) { + return false; + } + + List medias = getMedias(); + if (medias.isEmpty()) { + return false; + } + + PhysicalDivision firstPhysicalDivision = medias.get(0).getView().getPhysicalDivision(); + if (Objects.isNull(firstPhysicalDivision)) { + return false; + } + + if (firstPhysicalDivision.equals(lastSelection.getKey())) { + return true; + } + + return false; + } + + /** + * Return true if the currently selected media (that is shown in the detail view) is the verify + * last media of all available media. + * @return boolean true if selected media is last media + */ + public boolean isSelectedMediaLast() { + Pair lastSelection = getLastSelection(); + if (Objects.isNull(lastSelection)) { + return false; + } + + List medias = getMedias(); + if (medias.isEmpty()) { + return false; + } + + PhysicalDivision firstPhysicalDivision = medias.get(medias.size() - 1).getView().getPhysicalDivision(); + if (Objects.isNull(firstPhysicalDivision)) { + return false; + } + + if (firstPhysicalDivision.equals(lastSelection.getKey())) { + return true; + } + + return false; + } } diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 5cb752b8328..a4f21062fc7 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -333,6 +333,8 @@ dataEditor.layoutMenuSaveForTaskText=Spaltenaufteilung für Aufgabentyp speicher dataEditor.layoutSavedSuccessfullyTitle=Aktuelle Spaltenaufteilung erfolgreich gespeichert dataEditor.layoutSavedSuccessfullyDefaultText=Ihre Einstellungen wurden erfolgreich als Standard-Einstellungen gespeichert! Beim n\u00E4chsten \u00D6ffnen des Matadaten-Editors wird die Breite der drei Spalten (Strukturdaten, Metadaten und Galerie) entsprechend ihrer aktuellen Einstellung geladen. dataEditor.layoutSavedSuccessfullyForTaskText=Ihre Einstellungen wurden erfolgreich f\u00FCr alle zuk\u00FCnftigen Aufgaben des Typs "{0}" gespeichert! Beim n\u00E4chsten \u00D6ffnen des Matadaten-Editors f\u00FCr eine Aufgabe des gleichen Typs wird die Breite der drei Spalten (Strukturdaten, Metadaten und Galerie) entsprechend ihrer aktuellen Einstellung geladen. +dataEditor.navigateToPreviousElement=zum vorherigen Element +dataEditor.navigateToNextElement=zum n\uu00E4chstes Element dataEditor.renamingMediaComplete=Das Umbenennen der Medien ist abgeschlossen dataEditor.renamingMediaError=Beim Umbenennen der Medien ist ein Fehler aufgetreten dataEditor.renamingMediaText={0} Mediendateien in {1} Ordnern wurden umbenannt. Bitte speichern Sie den Vorgang. Andernfalls werden die Dateiumbennungen beim Schlie\u00DFen des Metadateneditors verworfen. diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index 426bc1b48ec..146e7ae5313 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -333,6 +333,8 @@ dataEditor.layoutMenuSaveForTaskText=Save task-specific layout dataEditor.layoutSavedSuccessfullyTitle=Current layout successfully saved dataEditor.layoutSavedSuccessfullyDefaultText=Your current editor column configuration has been successfully saved as default configuration. The next time you open the editor, the width of all three columns (structure data, metadata, gallery) will be loaded according to your current configuration. dataEditor.layoutSavedSuccessfullyForTaskText=Your current editor column configuration has been successfully saved as default configuration for the task type "{0}". The next time you open the editor for the same task type, the width of all three columns (structure data, metadata, gallery) will be loaded according to your current configuration. +dataEditor.navigateToPreviousElement=show previous element +dataEditor.navigateToNextElement=show next element dataEditor.renamingMediaComplete=Finished renaming media dataEditor.renamingMediaError=An error occurred while renaming media files dataEditor.renamingMediaText={0} media files in {1} folders have been renamed. Please click the 'Save' button to persist changes to the filenames. Otherwise the renaming will be reverted upon closing the editor. diff --git a/Kitodo/src/main/resources/messages/messages_es.properties b/Kitodo/src/main/resources/messages/messages_es.properties index 3ae2d9de152..8e372c3b05d 100644 --- a/Kitodo/src/main/resources/messages/messages_es.properties +++ b/Kitodo/src/main/resources/messages/messages_es.properties @@ -343,6 +343,10 @@ dataEditor.layoutSavedSuccessfullyTitle=La plantilla actual se guardó correctam dataEditor.layoutSavedSuccessfullyDefaultText=La configuración actual de la columna del editor se ha guardado correctamente como predeterminada. La próxima vez que abra el editor, el ancho de las tres columnas (datos de estructura, metadatos, galería) se cargará de acuerdo con su configuración actual. # please check google translation below and remove comment if translation is acceptable dataEditor.layoutSavedSuccessfullyForTaskText=La configuración actual de la columna del editor se ha guardado correctamente como predeterminada para el tipo de tarea "{0}". La próxima vez que abra el editor para el mismo tipo de tarea, el ancho de las tres columnas (datos de estructura, metadatos, galería) se cargará de acuerdo con su configuración actual. +# please check google translation below and remove comment if translation is acceptable +dataEditor.navigateToPreviousElement=mostrar elemento anterior +# please check google translation below and remove comment if translation is acceptable +dataEditor.navigateToNextElement=mostrar el siguiente elemento dataEditor.renamingMediaComplete=El cambio de nombre de los medios ha finalizado dataEditor.renamingMediaError=Se produjo un error al cambiar el nombre de los archivos multimedia dataEditor.renamingMediaText=Se ha cambiado el nombre de {0} archivos de medios en {1} carpeta. Por favor, haga clic en el botón 'Guardar' para mantener los cambios en los nombres de archivo. De lo contrario, el cambio de nombre se revertirá al cerrar el editor. diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index fd770364871..6abc4bd4c96 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -3446,7 +3446,7 @@ Column content opacity: 1.0; } -#imagePreviewForm .mediaDetailNavigationPanel button:hover { +#imagePreviewForm .mediaDetailNavigationPanel button:enabled:hover { background: var(--blue); } diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml index 425acde0df7..260db4f9089 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml @@ -93,11 +93,13 @@ From 0b03285ddf6afd6ab079a8479c55cc40a209c1b1 Mon Sep 17 00:00:00 2001 From: Thomas Low Date: Tue, 5 Nov 2024 19:38:53 +0000 Subject: [PATCH 3/7] Fix encoding mistake in german messages properties. --- Kitodo/src/main/resources/messages/messages_de.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index a4f21062fc7..b53ee0d464c 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -334,7 +334,7 @@ dataEditor.layoutSavedSuccessfullyTitle=Aktuelle Spaltenaufteilung erfolgreich g dataEditor.layoutSavedSuccessfullyDefaultText=Ihre Einstellungen wurden erfolgreich als Standard-Einstellungen gespeichert! Beim n\u00E4chsten \u00D6ffnen des Matadaten-Editors wird die Breite der drei Spalten (Strukturdaten, Metadaten und Galerie) entsprechend ihrer aktuellen Einstellung geladen. dataEditor.layoutSavedSuccessfullyForTaskText=Ihre Einstellungen wurden erfolgreich f\u00FCr alle zuk\u00FCnftigen Aufgaben des Typs "{0}" gespeichert! Beim n\u00E4chsten \u00D6ffnen des Matadaten-Editors f\u00FCr eine Aufgabe des gleichen Typs wird die Breite der drei Spalten (Strukturdaten, Metadaten und Galerie) entsprechend ihrer aktuellen Einstellung geladen. dataEditor.navigateToPreviousElement=zum vorherigen Element -dataEditor.navigateToNextElement=zum n\uu00E4chstes Element +dataEditor.navigateToNextElement=zum nächsten Element dataEditor.renamingMediaComplete=Das Umbenennen der Medien ist abgeschlossen dataEditor.renamingMediaError=Beim Umbenennen der Medien ist ein Fehler aufgetreten dataEditor.renamingMediaText={0} Mediendateien in {1} Ordnern wurden umbenannt. Bitte speichern Sie den Vorgang. Andernfalls werden die Dateiumbennungen beim Schlie\u00DFen des Metadateneditors verworfen. From 3fe8132706226fb53b2d022a155bf4a3390aea9f Mon Sep 17 00:00:00 2001 From: Thomas Low Date: Thu, 7 Nov 2024 12:55:40 +0000 Subject: [PATCH 4/7] Fix detail view navigation if no thumbnail is selected. Add fast forward and backward buttons to skip many media. --- .../forms/dataeditor/GalleryPanel.java | 4 +-- .../webapp/WEB-INF/resources/css/kitodo.css | 2 +- .../WEB-INF/resources/js/metadata_editor.js | 30 ++++++++++++++++++ .../partials/media-detail.xhtml | 31 ++++++++++++------- 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java index 8c9541c9306..82c462a5b74 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java @@ -1050,7 +1050,7 @@ public MediaPartialsPanel getMediaPartialsPanel() { } /** - * Return true if the currently selected media (that is shown in the detail view) is the verify + * Return true if the currently selected media (that is shown in the detail view) is the * first media of all available media. * @return boolean true if selected media is first media */ @@ -1078,7 +1078,7 @@ public boolean isSelectedMediaFirst() { } /** - * Return true if the currently selected media (that is shown in the detail view) is the verify + * Return true if the currently selected media (that is shown in the detail view) is the * last media of all available media. * @return boolean true if selected media is last media */ diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index 6abc4bd4c96..857eba319eb 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -3436,7 +3436,7 @@ Column content } #imagePreviewForm .mediaDetailNavigationPanel button { - margin: var(--default-full-size); + margin: var(--default-full-size) var(--default-half-size); pointer-events: all; opacity: 0.0; transition: opacity 0.1s linear; diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js b/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js index 4cd4f57e078..e35659a75ad 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js +++ b/Kitodo/src/main/webapp/WEB-INF/resources/js/metadata_editor.js @@ -937,6 +937,36 @@ metadataEditor.pagination = { } }; +metadataEditor.detailView = { + + /** + * Select the previous or following media when clicking on the navigation buttons of the detail view. + * @param {int} delta position delta with respect to currently selected media + */ + navigate(delta) { + // find media currently shown in detail view + let currentTreeNodeId = $("#imagePreviewForm\\:mediaDetail").data("logicaltreenodeid"); + if (!currentTreeNodeId) { + return; + } + // find current media in list of thumbnails + let thumbnails = $("#imagePreviewForm .thumbnail-container"); + let currentThumbnail = $("#imagePreviewForm .thumbnail-container[data-logicaltreenodeid='" + currentTreeNodeId + "']"); + let index = thumbnails.index(currentThumbnail); + if (index < 0) { + return; + } + // add delta to find previous or next thumbnail + index = Math.min(thumbnails.length - 1, Math.max(0, index + delta)); + let nextThumbnail = thumbnails.eq(index); + let nextTreeNodeId = nextThumbnail.data("logicaltreenodeid"); + // update selection and trigger reload of detail view + metadataEditor.gallery.pages.handleSingleSelect(null, nextThumbnail, nextTreeNodeId); + metadataEditor.gallery.pages.handleSelectionUpdates(nextTreeNodeId); + scrollToPreviewThumbnail(nextThumbnail, $("#thumbnailStripeScrollableContent")); + } +}; + metadataEditor.contextMenu = { listen() { document.oncontextmenu = function(event) { diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml index 260db4f9089..0c4fa6c760f 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml @@ -19,9 +19,12 @@ xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:a="http://xmlns.jcp.org/jsf/passthrough"> - - + + + @@ -92,16 +95,22 @@ - - + + + + icon="fa fa-angle-double-right fa-lg" + onclick="metadataEditor.detailView.navigate(+20);" /> From 46579cb35f85e0d7727bf6dab07825a938b6307c Mon Sep 17 00:00:00 2001 From: Thomas Low Date: Sun, 17 Nov 2024 15:06:21 +0000 Subject: [PATCH 5/7] Add selenium test for detail view navigation buttons of metadata editor. --- .../webapp/WEB-INF/resources/css/kitodo.css | 8 +- .../partials/media-detail.xhtml | 14 ++-- .../selenium/MetadataImagePreviewST.java | 73 +++++++++++++++++++ 3 files changed, 86 insertions(+), 9 deletions(-) diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index 1b45bdc3bd1..92d4fc6ef47 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -3426,7 +3426,7 @@ Column content background-color: var(--blue); } -#imagePreviewForm .mediaDetailNavigationPanel { +#imagePreviewForm\:mediaDetailNavigationPanel { position: absolute; width: 100%; bottom: 0; @@ -3434,18 +3434,18 @@ Column content pointer-events: none; } -#imagePreviewForm .mediaDetailNavigationPanel button { +#imagePreviewForm\:mediaDetailNavigationPanel button { margin: var(--default-full-size) var(--default-half-size); pointer-events: all; opacity: 0.0; transition: opacity 0.1s linear; } -#imagePreviewForm:hover .mediaDetailNavigationPanel button { +#imagePreviewForm:hover #imagePreviewForm\:mediaDetailNavigationPanel button { opacity: 1.0; } -#imagePreviewForm .mediaDetailNavigationPanel button:enabled:hover { +#imagePreviewForm\:mediaDetailNavigationPanel button:enabled:hover { background: var(--blue); } diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml index 0c4fa6c760f..ef71dd1bb3a 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml @@ -94,20 +94,24 @@ - - + - - - diff --git a/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java b/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java index 23874081a00..e7d71b44e04 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java @@ -13,6 +13,7 @@ import static org.awaitility.Awaitility.await; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; @@ -37,6 +38,7 @@ import org.kitodo.test.utils.ProcessTestUtils; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; /** * Tests the image preview panel (OpenLayers map) in the metadata editor. @@ -209,6 +211,77 @@ public void viewPersistsImageChange() throws Exception { assertTrue(Math.abs(getOpenLayersRotation() - changedRotation) < EPSILON); } + /** + * Test that navigation buttons select previous or following image, are disabled in case there is + * no previous or next image, and are hidden if the mouse is not inside the image preview panel. + */ + @Test + public void navigationButtonTest() throws Exception { + login("kowal"); + + // open metadata editor and detail view + Pages.getProcessesPage().goTo().editMetadata(PROCESS_TITLE); + Pages.getMetadataEditorPage().openDetailView(); + pollAssertTrue(() -> findElementsByCSS(OPEN_LAYERS_CANVAS_SELECTOR).get(0).isDisplayed()); + + // image is thumbnail 2, which is the very first image, such that left buttons are disabled + assertEquals("Bild 2, Seite -", findElementsByCSS(GALLERY_HEADING_WRAPPER_SELECTOR).get(0).getText().strip()); + WebElement leftFast = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementFast").get(0); + WebElement rightFast = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementFast").get(0); + + // check left buttons are disabled and right buttons are enabled + assertFalse(leftFast.isEnabled()); + assertTrue(rightFast.isEnabled()); + + // click on right fast button, which selects last image + rightFast.click(); + + // wait for image 3 to be shown + pollAssertTrue( + () -> "Bild 3, Seite -".equals( + findElementsByCSS(GALLERY_HEADING_WRAPPER_SELECTOR).get(0).getText().strip() + ) + ); + + // find buttons again because image preview is re-rendered + WebElement leftSlow = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementSlow").get(0); + WebElement rightSlow = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementSlow").get(0); + + // check left buttons are enalbed and right buttons are disabled + assertTrue(leftSlow.isEnabled()); + assertFalse(rightSlow.isEnabled()); + + // click on left slow button, selecting image 1 (middle image of all 3 images) + leftSlow.click(); + + // wait for image 1 to be shown + pollAssertTrue( + () -> "Bild 1, Seite -".equals( + findElementsByCSS(GALLERY_HEADING_WRAPPER_SELECTOR).get(0).getText().strip() + ) + ); + + // find buttons again because image preview is re-rendered + leftSlow = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementSlow").get(0); + rightSlow = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementSlow").get(0); + + // both left and right buttons are enabled + assertTrue(leftSlow.isEnabled()); + assertTrue(rightSlow.isEnabled()); + + // check that buttons are displayed (since mouse in hovering buttons due to prior click) + assertTrue(leftSlow.isDisplayed()); + assertTrue(rightSlow.isDisplayed()); + + // move mouse to main header menu + new Actions(Browser.getDriver()).moveToElement(findElementsByCSS("#menu").get(0)).perform(); + + // check buttons are hidden now + pollAssertTrue( + () -> !findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementSlow").get(0).isDisplayed() + ); + } + /** * Close metadata editor and logout after every test. * @throws Exception when page navigation fails From bcf0f648148d96c3d3ce1375dcb26a897a9e134f Mon Sep 17 00:00:00 2001 From: Thomas Low Date: Sun, 17 Nov 2024 17:48:01 +0000 Subject: [PATCH 6/7] Improve detail view navigation button title translations and update identifiers. --- .../resources/messages/messages_de.properties | 6 ++++-- .../resources/messages/messages_en.properties | 6 ++++-- .../resources/messages/messages_es.properties | 8 ++++++-- .../metadataEditor/partials/media-detail.xhtml | 16 ++++++++-------- .../selenium/MetadataImagePreviewST.java | 18 +++++++++--------- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 6acc9c10880..6afffbfdf87 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -334,8 +334,10 @@ dataEditor.layoutMenuSaveForTaskText=Spaltenaufteilung für Aufgabentyp speicher dataEditor.layoutSavedSuccessfullyTitle=Aktuelle Spaltenaufteilung erfolgreich gespeichert dataEditor.layoutSavedSuccessfullyDefaultText=Ihre Einstellungen wurden erfolgreich als Standard-Einstellungen gespeichert! Beim n\u00E4chsten \u00D6ffnen des Matadaten-Editors wird die Breite der drei Spalten (Strukturdaten, Metadaten und Galerie) entsprechend ihrer aktuellen Einstellung geladen. dataEditor.layoutSavedSuccessfullyForTaskText=Ihre Einstellungen wurden erfolgreich f\u00FCr alle zuk\u00FCnftigen Aufgaben des Typs "{0}" gespeichert! Beim n\u00E4chsten \u00D6ffnen des Matadaten-Editors f\u00FCr eine Aufgabe des gleichen Typs wird die Breite der drei Spalten (Strukturdaten, Metadaten und Galerie) entsprechend ihrer aktuellen Einstellung geladen. -dataEditor.navigateToPreviousElement=zum vorherigen Element -dataEditor.navigateToNextElement=zum nächsten Element +dataEditor.navigateToPreviousElementMany=mehrere Elemente zurück springen +dataEditor.navigateToPreviousElementOne=zum vorherigen Element +dataEditor.navigateToNextElementMany=mehrere Elemente weiter springen +dataEditor.navigateToNextElementOne=zum nächsten Element dataEditor.renamingMediaComplete=Das Umbenennen der Medien ist abgeschlossen dataEditor.renamingMediaError=Beim Umbenennen der Medien ist ein Fehler aufgetreten dataEditor.renamingMediaText={0} Mediendateien in {1} Ordnern wurden umbenannt. Bitte speichern Sie den Vorgang. Andernfalls werden die Dateiumbennungen beim Schlie\u00DFen des Metadateneditors verworfen. diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index 78c0a237a18..9adcedc3b9b 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -334,8 +334,10 @@ dataEditor.layoutMenuSaveForTaskText=Save task-specific layout dataEditor.layoutSavedSuccessfullyTitle=Current layout successfully saved dataEditor.layoutSavedSuccessfullyDefaultText=Your current editor column configuration has been successfully saved as default configuration. The next time you open the editor, the width of all three columns (structure data, metadata, gallery) will be loaded according to your current configuration. dataEditor.layoutSavedSuccessfullyForTaskText=Your current editor column configuration has been successfully saved as default configuration for the task type "{0}". The next time you open the editor for the same task type, the width of all three columns (structure data, metadata, gallery) will be loaded according to your current configuration. -dataEditor.navigateToPreviousElement=show previous element -dataEditor.navigateToNextElement=show next element +dataEditor.navigateToPreviousElementMany=jump multiple elements back +dataEditor.navigateToPreviousElementOne=show previous element +dataEditor.navigateToNextElementMany=jump multiple elements forward +dataEditor.navigateToNextElementOne=show next element dataEditor.renamingMediaComplete=Finished renaming media dataEditor.renamingMediaError=An error occurred while renaming media files dataEditor.renamingMediaText={0} media files in {1} folders have been renamed. Please click the 'Save' button to persist changes to the filenames. Otherwise the renaming will be reverted upon closing the editor. diff --git a/Kitodo/src/main/resources/messages/messages_es.properties b/Kitodo/src/main/resources/messages/messages_es.properties index ea3f9cb73a6..c23d3b7d5bf 100644 --- a/Kitodo/src/main/resources/messages/messages_es.properties +++ b/Kitodo/src/main/resources/messages/messages_es.properties @@ -346,9 +346,13 @@ dataEditor.layoutSavedSuccessfullyDefaultText=La configuración actual de la col # please check google translation below and remove comment if translation is acceptable dataEditor.layoutSavedSuccessfullyForTaskText=La configuración actual de la columna del editor se ha guardado correctamente como predeterminada para el tipo de tarea "{0}". La próxima vez que abra el editor para el mismo tipo de tarea, el ancho de las tres columnas (datos de estructura, metadatos, galería) se cargará de acuerdo con su configuración actual. # please check google translation below and remove comment if translation is acceptable -dataEditor.navigateToPreviousElement=mostrar elemento anterior +dataEditor.navigateToPreviousElementMany=saltar múltiples elementos hacia atrás # please check google translation below and remove comment if translation is acceptable -dataEditor.navigateToNextElement=mostrar el siguiente elemento +dataEditor.navigateToPreviousElementOne=mostrar elemento anterior +# please check google translation below and remove comment if translation is acceptable +dataEditor.navigateToNextElementMany=saltar múltiples elementos hacia adelante +# please check google translation below and remove comment if translation is acceptable +dataEditor.navigateToNextElementOne=mostrar el siguiente elemento dataEditor.renamingMediaComplete=El cambio de nombre de los archivos multimedia ha finalizado dataEditor.renamingMediaError=Se produjo un error al cambiar el nombre de los archivos multimedia dataEditor.renamingMediaText=Se ha cambiado el nombre de {0} archivos multimedia en {1} carpeta. Por favor, haga clic en el botón 'Guardar' para mantener los cambios en los nombres de archivo. De lo contrario, el cambio de nombre se revertirá al cerrar el editor. diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml index ef71dd1bb3a..7a9ffb20edb 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/metadataEditor/partials/media-detail.xhtml @@ -95,23 +95,23 @@ - - - - diff --git a/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java b/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java index e7d71b44e04..0805fdf5dcf 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java @@ -226,14 +226,14 @@ public void navigationButtonTest() throws Exception { // image is thumbnail 2, which is the very first image, such that left buttons are disabled assertEquals("Bild 2, Seite -", findElementsByCSS(GALLERY_HEADING_WRAPPER_SELECTOR).get(0).getText().strip()); - WebElement leftFast = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementFast").get(0); - WebElement rightFast = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementFast").get(0); + WebElement leftFast = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementMany").get(0); + WebElement rightFast = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementMany").get(0); // check left buttons are disabled and right buttons are enabled assertFalse(leftFast.isEnabled()); assertTrue(rightFast.isEnabled()); - // click on right fast button, which selects last image + // click on right-many button, which selects last image rightFast.click(); // wait for image 3 to be shown @@ -244,14 +244,14 @@ public void navigationButtonTest() throws Exception { ); // find buttons again because image preview is re-rendered - WebElement leftSlow = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementSlow").get(0); - WebElement rightSlow = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementSlow").get(0); + WebElement leftSlow = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementOne").get(0); + WebElement rightSlow = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementOne").get(0); // check left buttons are enalbed and right buttons are disabled assertTrue(leftSlow.isEnabled()); assertFalse(rightSlow.isEnabled()); - // click on left slow button, selecting image 1 (middle image of all 3 images) + // click on left-one button, selecting image 1 (middle image of all 3 images) leftSlow.click(); // wait for image 1 to be shown @@ -262,8 +262,8 @@ public void navigationButtonTest() throws Exception { ); // find buttons again because image preview is re-rendered - leftSlow = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementSlow").get(0); - rightSlow = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementSlow").get(0); + leftSlow = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementOne").get(0); + rightSlow = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementOne").get(0); // both left and right buttons are enabled assertTrue(leftSlow.isEnabled()); @@ -278,7 +278,7 @@ public void navigationButtonTest() throws Exception { // check buttons are hidden now pollAssertTrue( - () -> !findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementSlow").get(0).isDisplayed() + () -> !findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementOne").get(0).isDisplayed() ); } From 4d96c98050c1808fdfb0fdd1539b818b03861131 Mon Sep 17 00:00:00 2001 From: Thomas Low Date: Fri, 22 Nov 2024 09:06:04 +0000 Subject: [PATCH 7/7] Fix code style and message file umlauts based on pull request feedback. --- .../forms/dataeditor/GalleryPanel.java | 16 +++------ .../resources/messages/messages_de.properties | 6 ++-- .../selenium/MetadataImagePreviewST.java | 34 +++++++++---------- 3 files changed, 24 insertions(+), 32 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java index 82c462a5b74..f4280c0d7f2 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/GalleryPanel.java @@ -1070,11 +1070,7 @@ public boolean isSelectedMediaFirst() { return false; } - if (firstPhysicalDivision.equals(lastSelection.getKey())) { - return true; - } - - return false; + return firstPhysicalDivision.equals(lastSelection.getKey()); } /** @@ -1093,15 +1089,11 @@ public boolean isSelectedMediaLast() { return false; } - PhysicalDivision firstPhysicalDivision = medias.get(medias.size() - 1).getView().getPhysicalDivision(); - if (Objects.isNull(firstPhysicalDivision)) { + PhysicalDivision lastPhysicalDivision = medias.get(medias.size() - 1).getView().getPhysicalDivision(); + if (Objects.isNull(lastPhysicalDivision)) { return false; } - if (firstPhysicalDivision.equals(lastSelection.getKey())) { - return true; - } - - return false; + return lastPhysicalDivision.equals(lastSelection.getKey()); } } diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 8f7b5afa3a8..58f410606f9 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -334,10 +334,10 @@ dataEditor.layoutMenuSaveForTaskText=Spaltenaufteilung für Aufgabentyp speicher dataEditor.layoutSavedSuccessfullyTitle=Aktuelle Spaltenaufteilung erfolgreich gespeichert dataEditor.layoutSavedSuccessfullyDefaultText=Ihre Einstellungen wurden erfolgreich als Standard-Einstellungen gespeichert! Beim n\u00E4chsten \u00D6ffnen des Matadaten-Editors wird die Breite der drei Spalten (Strukturdaten, Metadaten und Galerie) entsprechend ihrer aktuellen Einstellung geladen. dataEditor.layoutSavedSuccessfullyForTaskText=Ihre Einstellungen wurden erfolgreich f\u00FCr alle zuk\u00FCnftigen Aufgaben des Typs "{0}" gespeichert! Beim n\u00E4chsten \u00D6ffnen des Matadaten-Editors f\u00FCr eine Aufgabe des gleichen Typs wird die Breite der drei Spalten (Strukturdaten, Metadaten und Galerie) entsprechend ihrer aktuellen Einstellung geladen. -dataEditor.navigateToPreviousElementMany=mehrere Elemente zurück springen +dataEditor.navigateToPreviousElementMany=mehrere Elemente zur\u00FCckspringen dataEditor.navigateToPreviousElementOne=zum vorherigen Element -dataEditor.navigateToNextElementMany=mehrere Elemente weiter springen -dataEditor.navigateToNextElementOne=zum nächsten Element +dataEditor.navigateToNextElementMany=mehrere Elemente vorspringen +dataEditor.navigateToNextElementOne=zum n\u00E4chsten Element dataEditor.renamingMediaComplete=Das Umbenennen der Medien ist abgeschlossen dataEditor.renamingMediaError=Beim Umbenennen der Medien ist ein Fehler aufgetreten dataEditor.renamingMediaText={0} Mediendateien in {1} Ordnern wurden umbenannt. Bitte speichern Sie den Vorgang. Andernfalls werden die Dateiumbennungen beim Schlie\u00DFen des Metadateneditors verworfen. diff --git a/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java b/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java index 0805fdf5dcf..d6e37eb9cd2 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/MetadataImagePreviewST.java @@ -226,15 +226,15 @@ public void navigationButtonTest() throws Exception { // image is thumbnail 2, which is the very first image, such that left buttons are disabled assertEquals("Bild 2, Seite -", findElementsByCSS(GALLERY_HEADING_WRAPPER_SELECTOR).get(0).getText().strip()); - WebElement leftFast = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementMany").get(0); - WebElement rightFast = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementMany").get(0); + WebElement leftMany = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementMany").get(0); + WebElement rightMany = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementMany").get(0); // check left buttons are disabled and right buttons are enabled - assertFalse(leftFast.isEnabled()); - assertTrue(rightFast.isEnabled()); + assertFalse(leftMany.isEnabled()); + assertTrue(rightMany.isEnabled()); // click on right-many button, which selects last image - rightFast.click(); + rightMany.click(); // wait for image 3 to be shown pollAssertTrue( @@ -244,15 +244,15 @@ public void navigationButtonTest() throws Exception { ); // find buttons again because image preview is re-rendered - WebElement leftSlow = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementOne").get(0); - WebElement rightSlow = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementOne").get(0); + WebElement leftOne = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementOne").get(0); + WebElement rightOne = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementOne").get(0); - // check left buttons are enalbed and right buttons are disabled - assertTrue(leftSlow.isEnabled()); - assertFalse(rightSlow.isEnabled()); + // check left buttons are enabled and right buttons are disabled + assertTrue(leftOne.isEnabled()); + assertFalse(rightOne.isEnabled()); // click on left-one button, selecting image 1 (middle image of all 3 images) - leftSlow.click(); + leftOne.click(); // wait for image 1 to be shown pollAssertTrue( @@ -262,16 +262,16 @@ public void navigationButtonTest() throws Exception { ); // find buttons again because image preview is re-rendered - leftSlow = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementOne").get(0); - rightSlow = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementOne").get(0); + leftOne = findElementsByCSS("#imagePreviewForm\\:navigateToPreviousElementOne").get(0); + rightOne = findElementsByCSS("#imagePreviewForm\\:navigateToNextElementOne").get(0); // both left and right buttons are enabled - assertTrue(leftSlow.isEnabled()); - assertTrue(rightSlow.isEnabled()); + assertTrue(leftOne.isEnabled()); + assertTrue(rightOne.isEnabled()); // check that buttons are displayed (since mouse in hovering buttons due to prior click) - assertTrue(leftSlow.isDisplayed()); - assertTrue(rightSlow.isDisplayed()); + assertTrue(leftOne.isDisplayed()); + assertTrue(rightOne.isDisplayed()); // move mouse to main header menu new Actions(Browser.getDriver()).moveToElement(findElementsByCSS("#menu").get(0)).perform();