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 a4b3c02e4bf..eb5f31108b5 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -788,6 +788,7 @@ body .content-header > .ui-panel-content { .content-header .ui-panel-content > form, .content-header .ui-panel-content > button, +#massImportButtonForm > button, .ui-menubutton, .ui-selectbooleanbutton { white-space: nowrap; @@ -1921,134 +1922,177 @@ body .functional-metadata-wrapper .help-button .ui-button-text { float: unset; } -#fileUploadForm .ui-fileupload .ui-fileupload-content, -#fileUploadForm .ui-fileupload .ui-fileupload-content .ui-fileupload-files { +#fileUploadForm\:uploadWrapper { + margin: 0; +} + +#fileUploadForm\:uploadWrapper_content { + padding: 0; +} + +#fileUploadForm .ui-fileupload .ui-fileupload-content { border: none; } +#fileUploadForm .ui-fileupload .ui-fileupload-content .ui-fileupload-files .ui-fileupload-row { + border: 0 1px solid var(--focused-blue); +} + +#fileUploadForm .ui-fileupload .ui-fileupload-content .ui-fileupload-files .ui-fileupload-row:first-child { + border-top: 1px solid var(--focused-blue); + border-top-radius: var(--default-border-radius); +} + +#fileUploadForm .ui-fileupload .ui-fileupload-content .ui-fileupload-files .ui-fileupload-row:last-child { + border-bottom: 1px solid var(--focused-blue); + border-bottom-radius: var(--default-border-radius); +} + /*---------------------------------------------------------------------- Mass import ----------------------------------------------------------------------*/ -#editForm\:fileUploadButtonWrapper { +#massImportTab, +#recordsForm\:recordsTableWrapper { + height: 100%; +} + +#massImportTab #fileUploadForm { + height: 160px; + overflow-y: auto; +} + +#massImportTab #recordsForm { + height: calc(100% - 160px); + overflow-y: hidden; +} + +#massImportTab #recordsForm\:recordsTable { + height: calc(100% - 80px); +} + +#massImportTab .ui-datatable-scrollable-body { + height: calc(100% - 50px); +} + +#fileUploadForm\:fileUploadButtonWrapper { padding: 0; } -#editForm\:recordsTable th span.metadata-record-id::after, -#editForm\:recordsTable th span.metadata-doctype::after { +#recordsForm\:recordsTable th span.metadata-record-id::after, +#recordsForm\:recordsTable th span.metadata-doctype::after { color: var(--medium-gray); font-family: FontAwesome; margin-left: var(--default-half-size); } -#editForm\:recordsTable th span.metadata-record-id::after { +#recordsForm\:recordsTable th span.metadata-record-id::after { content: "\f2c2"; } -#editForm\:recordsTable th span.metadata-doctype::after { +#recordsForm\:recordsTable th span.metadata-doctype::after { content: "\f02d"; } -#editForm\:recordsTable .ui-datatable-scrollable-theadclone { +#recordsForm\:recordsTable .ui-datatable-scrollable-theadclone { display: none; } -#editForm\:recordsTable_scrollableThead > tr > th:last-child span { +#recordsForm\:recordsTable_scrollableThead > tr > th:last-child span { float: right; } -#editForm\:recordsTable th.ui-state-default, -#editForm\:recordsTable td.ui-editable-column, -#editForm\:recordsTable td.remove-column, -#editForm\:recordsTable tr.ui-datatable-empty-message { +#recordsForm\:recordsTable th.ui-state-default, +#recordsForm\:recordsTable td.ui-editable-column, +#recordsForm\:recordsTable td.remove-column, +#recordsForm\:recordsTable tr.ui-datatable-empty-message { border: 1px solid var(--carbon-blue); } -#editForm\:addCsvRecord, -#editForm\:catalogSelectionWrapper { +#recordsForm\:addCsvRecord, +#fileUploadForm\:catalogSelectionWrapper { margin-top: var(--default-half-size); } -#editForm\:recordsTable th:has(> span.ui-column-title > span.invalid-configuration) { +#recordsForm\:recordsTable th:has(> span.ui-column-title > span.invalid-configuration) { background-color: var(--orange); } -#editForm\:recordsTable th:has(> span.ui-column-title > span.unknown-metadata) { +#recordsForm\:recordsTable th:has(> span.ui-column-title > span.unknown-metadata) { background-color: var(--light-orange); } -#editForm\:recordsTable td.ui-editable-column { +#recordsForm\:recordsTable td.ui-editable-column { overflow-x: hidden; text-overflow: ellipsis; white-space: nowrap; } -#editForm .ui-panelgrid-cell { +#fileUploadForm .ui-panelgrid-cell { padding-left: var(--default-full-size); } -#editForm .ui-fileupload-buttonbar { +#fileUploadForm .ui-fileupload-buttonbar { padding: 0; } -#editForm .ui-fileupload-buttonbar .ui-button { +#fileUploadForm .ui-fileupload-buttonbar .ui-button { margin-right: var(--default-full-size); } -#editForm\:fileUploadButtonWrapper .ui-fileupload-files:not(:has(div.ui-fileupload-row)) { +#fileUploadForm\:fileUploadButtonWrapper .ui-fileupload-files:not(:has(div.ui-fileupload-row)) { border: none; } -#editForm\:recordsTableWrapper { +#recordsForm\:recordsTableWrapper { padding: 0 var(--default-full-size); } -#editForm\:recordsTable tr { +#recordsForm\:recordsTable tr { height: var(--input-height); overflow-y: hidden; } -#editForm\:recordsTable .remove-column { +#recordsForm\:recordsTable .remove-column { width: 50px; } -#editForm\:recordsTable .remove-column button.secondary, -#editForm\:recordsTable .remove-metadata-column { +#recordsForm\:recordsTable .remove-column button.secondary, +#recordsForm\:recordsTable .remove-metadata-column { border: none; } -#editForm\:addCsvRecord, -#editForm\:recordsTable .remove-column button.secondary { +#recordsForm\:addCsvRecord, +#recordsForm\:recordsTable .remove-column button.secondary { float: right; } -#editForm\:recordsTable input.ui-inputtext { +#recordsForm\:recordsTable input.ui-inputtext { width: 100%; } -#editForm\:csvSeparator { +#fileUploadForm\:csvSeparator { display: block; width: 60px; } -#editForm\:separatorCharacterWrapper .separator-selection { +#fileUploadForm\:separatorCharacterWrapper .separator-selection { display: inline-block; margin-right: var(--default-double-size); - width: 45%; } -#editForm\:skipEmptyColumnsWrapper { +#fileUploadForm\:skipEmptyColumnsWrapper { display: inline-block; vertical-align: top; } -#editForm\:csvFileUpload { +#fileUploadForm\:csvFileUpload { overflow-x: hidden; white-space: nowrap; } -#editForm\:csvFileUpload .ui-fileupload-buttonbar { +#fileUploadForm\:csvFileUpload .ui-fileupload-buttonbar { background: transparent; border: none; } @@ -2062,18 +2106,18 @@ Mass import padding: 0; } -#editForm\:recordsTable\:addMetadataColumn, -#editForm\:recordsTable button.remove-metadata-column { +#recordsForm\:recordsTable\:addMetadataColumn, +#recordsForm\:recordsTable button.remove-metadata-column { background: transparent; overflow: hidden; height: inherit; } -#editForm\:recordsTable span.ui-column-title { +#recordsForm\:recordsTable span.ui-column-title { white-space: nowrap; } -#editForm\:recordsTable span.ui-column-title span { +#recordsForm\:recordsTable span.ui-column-title span { display: inline-block; overflow: hidden; text-overflow: ellipsis; @@ -2081,7 +2125,7 @@ Mass import width: calc(100% - 20px); } -#editForm\:recordsTable_data tr td { +#recordsForm\:recordsTable_data tr td { box-sizing: content-box; } @@ -2093,10 +2137,14 @@ Mass import padding-right: var(--default-half-size); } -#fileUploadForm, #searchEditForm { +#searchEditForm { padding: 0 var(--default-double-size); } +#fileUploadForm\:csvParserOptions_content { + padding: 0; +} + #catalogSearchForm div.ui-panelgrid-cell { padding-right: var(--default-half-size); } diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/dialogs/addMetadata.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/dialogs/addMetadata.xhtml index 14a2ea62ab4..e87508f0d6a 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/dialogs/addMetadata.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/dialogs/addMetadata.xhtml @@ -124,7 +124,7 @@ styleClass="dialogButtonWrapper"> diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/dialogs/massImportResults.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/dialogs/massImportResults.xhtml index 27ac47c26af..15bdb437098 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/dialogs/massImportResults.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/dialogs/massImportResults.xhtml @@ -85,14 +85,16 @@
- - + + + +
diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/massImportTab.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/massImportTab.xhtml index a08d0265173..062df18c1c0 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/massImportTab.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/massImportTab.xhtml @@ -17,181 +17,202 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:p="http://primefaces.org/ui"> - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + + + + + + + + + + + - - - - - - - + + +
+ - - -
- -
- - - - - - - - - - + update="recordsForm:recordsTableWrapper massImportButtonForm:importButton fileUploadForm:skipEmptyColumns"/> +
+ + + + + + + + + + +
- + diff --git a/Kitodo/src/main/webapp/pages/massImport.xhtml b/Kitodo/src/main/webapp/pages/massImport.xhtml index f52f60e8b13..1ab921dc59b 100644 --- a/Kitodo/src/main/webapp/pages/massImport.xhtml +++ b/Kitodo/src/main/webapp/pages/massImport.xhtml @@ -12,7 +12,7 @@ --> - - - - + + + + + + diff --git a/Kitodo/src/test/java/org/kitodo/selenium/MassImportST.java b/Kitodo/src/test/java/org/kitodo/selenium/MassImportST.java index 569395eeff6..21781a3ed46 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/MassImportST.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/MassImportST.java @@ -13,6 +13,8 @@ import static org.awaitility.Awaitility.await; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.FileWriter; @@ -25,6 +27,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.kitodo.MockDatabase; import org.kitodo.constants.StringConstants; @@ -34,6 +37,7 @@ import org.kitodo.selenium.testframework.Pages; import org.kitodo.selenium.testframework.pages.MassImportPage; import org.openqa.selenium.By; +import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; public class MassImportST extends BaseTestSelenium { @@ -46,9 +50,9 @@ public class MassImportST extends BaseTestSelenium { private static MassImportPage massImportPage; private static final String CSV_UPLOAD_FILENAME = "test_import"; private static final String CSV_UPLOAD_FILE_EXTENSION = ".csv"; - private static final String CSV_CELL_SELECTOR = "#editForm\\:recordsTable_data tr .ui-cell-editor-output"; - private static final String RECORDS_TABLE = "editForm:recordsTable"; - private static final String CSV_SEPARATOR = "editForm:csvSeparator"; + private static final String CSV_CELL_SELECTOR = "#recordsForm\\:recordsTable_data tr .ui-cell-editor-output"; + private static final String RECORDS_TABLE = "recordsForm:recordsTable"; + private static final String CSV_SEPARATOR = "fileUploadForm:csvSeparator"; @BeforeAll public static void setup() throws Exception { @@ -88,7 +92,7 @@ public void handleCsvFileUpload() throws InterruptedException { Thread.sleep(Browser.getDelayAfterLogout()); massImportPage.selectCatalogueGbv(); Thread.sleep(Browser.getDelayAfterLogout()); - List csvRows = Browser.getDriver().findElement(By.id("editForm:recordsTable_data")) + List csvRows = Browser.getDriver().findElement(By.id("recordsForm:recordsTable_data")) .findElements(By.tagName("tr")); assertEquals(3, csvRows.size(), "CSV file not parsed correctly"); List updatedCsvCells = Browser.getDriver().findElements(By.cssSelector(CSV_CELL_SELECTOR)); @@ -100,6 +104,67 @@ public void handleCsvFileUpload() throws InterruptedException { + "separator"); } + /** + * Tests whether adding a new record to the table correctly increases the number of rows. + * @throws InterruptedException when thread is interrupted during sleep + */ + @Test + public void addRowTest() throws InterruptedException { + massImportPage.uploadTestCsvFile(csvUploadFile.getAbsolutePath()); + Thread.sleep(Browser.getDelayAfterLogout()); + List csvRows = Browser.getDriver().findElement(By.id("recordsForm:recordsTable_data")) + .findElements(By.tagName("tr")); + assertEquals(3, csvRows.size(), "Incorrect number of rows"); + Browser.getDriver().findElement(By.id("recordsForm:addCsvRecord")).click(); + Thread.sleep(Browser.getDelayAfterLogout()); + csvRows = Browser.getDriver().findElement(By.id("recordsForm:recordsTable_data")) + .findElements(By.tagName("tr")); + assertEquals(4, csvRows.size(), "Row not added correctly"); + } + + /** + * Tests whether removing a record from the table correctly decreases the number of rows. + * @throws InterruptedException when thread is interrupted during sleep + */ + @Test + public void removeRowTest() throws InterruptedException { + massImportPage.uploadTestCsvFile(csvUploadFile.getAbsolutePath()); + Thread.sleep(Browser.getDelayAfterLogout()); + List csvRows = Browser.getDriver().findElement(By.id("recordsForm:recordsTable_data")) + .findElements(By.tagName("tr")); + assertEquals(3, csvRows.size(), "Incorrect number of rows"); + Browser.getDriver().findElement(By.cssSelector("td.remove-column button.ui-button")).click(); + Thread.sleep(Browser.getDelayAfterLogout()); + csvRows = Browser.getDriver().findElement(By.id("recordsForm:recordsTable_data")) + .findElements(By.tagName("tr")); + assertEquals(2, csvRows.size(), "Row not removed correctly"); + } + + /** + * Tests whether editing cell content in the mass import table works correctly. + * @throws InterruptedException when thread is interrupted during sleep + */ + @Disabled("Editing the content of datatable after CSV file upload is currently bugged and needs to be fixed") + @Test + public void changeMetadataValue() throws InterruptedException { + massImportPage.uploadTestCsvFile(csvUploadFile.getAbsolutePath()); + Thread.sleep(Browser.getDelayAfterLogout()); + WebElement cell = Browser.getDriver().findElement(By.className("ui-editable-column")); + assertNotNull(cell, "No editable cell found before editing"); + assertEquals("123", cell.getText(), "Incorrect cell value before editing"); + cell.click(); + WebElement input = Browser.getDriver().findElement(By.cssSelector(".ui-cell-editor-input > input")); + assertTrue(input.isDisplayed(), "Cell editor not displayed"); + input.clear(); + input.sendKeys("456"); + Thread.sleep(Browser.getDelayAfterLogout()); + input.sendKeys(Keys.TAB); + Thread.sleep(Browser.getDelayAfterLogout()); + cell = Browser.getDriver().findElement(By.className("ui-editable-column")); + assertNotNull(cell, "No editable cell found after editing"); + assertEquals("456", cell.getText(), "Incorrect cell value after editing"); + } + private static File createCsvFile() throws IOException { File csvFile = File.createTempFile(CSV_UPLOAD_FILENAME, CSV_UPLOAD_FILE_EXTENSION); try (FileWriter writer = new FileWriter(csvFile)) { diff --git a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MassImportPage.java b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MassImportPage.java index a2a0554a8a7..42ab46c6266 100644 --- a/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MassImportPage.java +++ b/Kitodo/src/test/java/org/kitodo/selenium/testframework/pages/MassImportPage.java @@ -19,9 +19,9 @@ import static org.awaitility.Awaitility.await; public class MassImportPage extends Page { - private static final String CATALOG_SELECTION = "editForm:catalogueSelect"; + private static final String CATALOG_SELECTION = "recordsForm:catalogueSelect"; private static final String SELECT_FILE_BUTTON_BAR = ".ui-fileupload-buttonbar .ui-button"; - private static final String UPLOAD_FILE_INPUT = "editForm:csvFileUpload_input"; + private static final String UPLOAD_FILE_INPUT = "fileUploadForm:csvFileUpload_input"; private static final String GBV = "GBV"; private static final String OK_BUTTON_ID = "buttonForm:okButton";