Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve info about active metadata editor settings #6356

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
Expand Down Expand Up @@ -231,6 +230,9 @@ public class DataEditorForm implements MetadataTreeTableInterface, RulesetSetupI
static final String GROWL_MESSAGE =
"PF('notifications').renderMessage({'summary':'SUMMARY','detail':'DETAIL','severity':'SEVERITY'});";

private boolean globalLayoutLoaded = false;
private boolean taskLayoutLoaded = false;

/**
* Public constructor.
*/
Expand Down Expand Up @@ -315,32 +317,13 @@ public void open(String processID, String referringView, String taskId) {
} else {
PrimeFaces.current().executeScript("PF('metadataLockedDialog').show();");
}
if (Objects.nonNull(this.dataEditorSetting) && Objects.nonNull(dataEditorSetting.getId())) {
showDataEditorSettingsLoadedMessage();
}
} catch (FileNotFoundException e) {
metadataFileLoadingError = e.getLocalizedMessage();
} catch (IOException | DAOException | InvalidImagesException | NoSuchElementException e) {
Helper.setErrorMessage(e.getLocalizedMessage(), logger, e);
}
}

private void showDataEditorSettingsLoadedMessage() throws DAOException {
Locale locale = LocaleHelper.getCurrentLocale();
String title = Helper.getString(locale, "dataEditor.layoutLoadedSuccessfullyTitle");
String text = Helper.getString(locale, "dataEditor.layoutLoadedSuccessfullyDefaultText");
if (Objects.nonNull(this.templateTask) && Objects.nonNull(dataEditorSetting)
&& templateTask.getId().equals(dataEditorSetting.getTaskId())) {
text = MessageFormat.format(
Helper.getString(locale, "dataEditor.layoutLoadedSuccessfullyForTaskText"), this.templateTask.getTitle()
);
}
String script = GROWL_MESSAGE.replace("SUMMARY", title).replace("DETAIL", text)
.replace("SEVERITY", "info");
PrimeFaces.current().executeScript("PF('notifications').removeAll();");
PrimeFaces.current().executeScript(script);
}

private void checkProjectFolderConfiguration() {
if (Objects.nonNull(this.process)) {
Project project = this.process.getProject();
Expand Down Expand Up @@ -405,6 +388,14 @@ private void loadDataEditorSettings() {
dataEditorSetting.setUserId(userId);
dataEditorSetting.setTaskId(taskId);
}

// initialize flags to signal whether global or task specific settings have been loaded or not
boolean layoutLoaded = (dataEditorSetting.getStructureWidth() > 0
|| dataEditorSetting.getMetadataWidth() > 0
|| dataEditorSetting.getGalleryWidth() > 0);

globalLayoutLoaded = Objects.isNull(dataEditorSetting.getTaskId()) && layoutLoaded;
taskLayoutLoaded = Objects.nonNull(dataEditorSetting.getTaskId()) && layoutLoaded;
}

/**
Expand Down Expand Up @@ -1163,6 +1154,7 @@ public void saveDataEditorSetting() {
}
try {
ServiceManager.getDataEditorSettingService().saveToDatabase(dataEditorSetting);
loadDataEditorSettings();
PrimeFaces.current().executeScript("PF('dataEditorSavingResultDialog').show();");
} catch (DAOException e) {
Helper.setErrorMessage("errorSaving", new Object[] {ObjectType.DATAEDITORSETTING.getTranslationSingular() }, logger, e);
Expand Down Expand Up @@ -1400,4 +1392,22 @@ public String getGroupDisplayLabel(MetadataGroup metadataGroup) {
return "";
}
}

/**
* Get value of 'globalLayoutLoaded'.
*
* @return value of 'globalLayoutLoaded'
*/
public boolean isGlobalLayoutLoaded() {
return globalLayoutLoaded;
}

/**
* Get value of 'taskLayoutLoaded'.
*
* @return value of 'taskLayoutLoaded'
*/
public boolean isTaskLayoutLoaded() {
return taskLayoutLoaded;
}
}
3 changes: 0 additions & 3 deletions Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ dataEditor.removeElement.noConsecutivePagesSelected=Strukturelemente k\u00F6nnen
dataEditor.selectMetadataTask=Aufgabe w\u00E4hlen
dataEditor.layoutDeletedSuccessfullyTitle=Metadaten-Editor-Layout gelöscht
dataEditor.layoutDeletedSuccessfullyText=Die Standard-Spalteneinstellungen wurden erfolgreich gelöscht
dataEditor.layoutLoadedSuccessfullyTitle=Metadaten-Editor-Layout geladen
dataEditor.layoutLoadedSuccessfullyDefaultText=Standard-Spalteneinstellungen erfolgreich geladen
dataEditor.layoutLoadedSuccessfullyForTaskText=Standard-Spalteneinstellungen f\u00FCr Aufgabe "{0}" erfolgreich geladen
dataEditor.layoutMenuActiveText=aktiv
dataEditor.layoutMenuButtonTitle=Menu zum Speichern des Layout (Spaltenaufteilung) öffnen
dataEditor.layoutMenuDeleteTitle=Gespeicherte Spaltenaufteilung löschen
Expand Down
3 changes: 0 additions & 3 deletions Kitodo/src/main/resources/messages/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ dataEditor.removeElement.noConsecutivePagesSelected=Select consecutive pages to
dataEditor.selectMetadataTask=Select task
dataEditor.layoutDeletedSuccessfullyTitle=Custom layout deleted
dataEditor.layoutDeletedSuccessfullyText=Default column configuration deleted successfully
dataEditor.layoutLoadedSuccessfullyTitle=Custom layout loaded
dataEditor.layoutLoadedSuccessfullyDefaultText=Default column configuration loaded successfully
dataEditor.layoutLoadedSuccessfullyForTaskText=Default column configuration for task "{0}" loaded successfully
dataEditor.layoutMenuActiveText=active
dataEditor.layoutMenuButtonTitle=Open menu to save default layout (column configuration)
dataEditor.layoutMenuDeleteTitle=Delete default layout
Expand Down
3 changes: 0 additions & 3 deletions Kitodo/src/main/resources/messages/messages_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ dataEditor.removeElement.noConsecutivePagesSelected=Los elementos estructurales
dataEditor.selectMetadataTask=Seleccionar la tarea
dataEditor.layoutDeletedSuccessfullyTitle=El diseño personalizado fue eliminado
dataEditor.layoutDeletedSuccessfullyText=La configuración de columna predeterminada se eliminó correctamente
dataEditor.layoutLoadedSuccessfullyTitle=El diseño personalizado está cargado
dataEditor.layoutLoadedSuccessfullyDefaultText=La configuración de columna personalizada se cargó correctamente
dataEditor.layoutLoadedSuccessfullyForTaskText=La configuración de la columna personalizada para la tarea "{0}" se ha cargado correctamente.
dataEditor.layoutMenuActiveText=activa
dataEditor.layoutMenuButtonTitle=Abrir menú para guardar el diseño predeterminado (configuración de columna)
dataEditor.layoutMenuDeleteTitle=Eliminar diseño predeterminado
Expand Down
20 changes: 20 additions & 0 deletions Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css
Original file line number Diff line number Diff line change
Expand Up @@ -2908,6 +2908,26 @@ Column content
padding: 0.5em 0.25em;
}

button.settings-loaded::after,
button.settings-loaded-task::after {
background: white;
color: var(--green);
font-family: FontAwesome;
font-size: large;
font-weight: normal;
position: absolute;
right: -6px;
top: -6px;
}

button.settings-loaded::after {
content: "\f05d";
}

button.settings-loaded-task::after {
content: "\f058";
}

#metadataEditorLayoutForm ul {
list-style: none;
margin: 0.25em 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,30 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:param name="layoutWasLoaded" value="#{
DataEditorForm.dataEditorSetting.structureWidth gt 0 or
DataEditorForm.dataEditorSetting.metadataWidth gt 0 or
DataEditorForm.dataEditorSetting.galleryWidth gt 0}"/>
<p:overlayPanel for="metadataEditorLayoutButtonForm:open" style="display: none;">
<p:overlayPanel id="metadataEditorLayoutOverlayPanel"
for="metadataEditorLayoutButtonForm:open"
style="display: none;">
<h:form id="metadataEditorLayoutForm">
<ul>
<li>
<p:commandLink
id="saveDefault"
onclick="saveLayout()"
action="#{DataEditorForm.saveDataEditorSetting()}"
update="metadataEditorLayoutForm dataEditorSavingResultForm"
update="metadataEditorLayoutOverlayPanel dataEditorSavingResultForm metadataEditorLayoutButtonForm:open"
disabled="#{DataEditorForm.templateTask ne null}">
<i class="fa fa-floppy-o"></i>
<h:outputText value="#{msgs['dataEditor.layoutMenuSaveDefaultText']}" />
<h:outputText
value=" (#{msgs['dataEditor.layoutMenuActiveText']})"
rendered="#{DataEditorForm.dataEditorSetting.taskId eq null and layoutWasLoaded}" />
rendered="#{DataEditorForm.isGlobalLayoutLoaded()}" />
</p:commandLink>
<p:commandButton
id="removeDefault"
icon="fa fa-trash"
action="#{DataEditorForm.deleteDataEditorSetting()}"
update="metadataEditorLayoutForm dataEditorSavingResultForm"
disabled="#{DataEditorForm.templateTask ne null or not layoutWasLoaded}"
update="metadataEditorLayoutOverlayPanel dataEditorSavingResultForm metadataEditorLayoutButtonForm:open"
disabled="#{not DataEditorForm.isGlobalLayoutLoaded()}"
styleClass="secondary"
title="#{msgs['dataEditor.layoutMenuDeleteTitle']}" />
</li>
Expand All @@ -50,21 +48,21 @@
id="saveForTask"
onclick="saveLayout()"
action="#{DataEditorForm.saveDataEditorSetting()}"
update="metadataEditorLayoutForm dataEditorSavingResultForm"
update="metadataEditorLayoutOverlayPanel dataEditorSavingResultForm metadataEditorLayoutButtonForm:open"
disabled="#{DataEditorForm.templateTask eq null}">
<i class="fa fa-floppy-o"></i>
<h:outputText value="#{msgs['dataEditor.layoutMenuSaveForTaskText']}" />
<h:outputText
value=" (#{msgs['dataEditor.layoutMenuActiveText']})"
rendered="#{DataEditorForm.dataEditorSetting.taskId ne null and layoutWasLoaded}" />
rendered="#{DataEditorForm.isTaskLayoutLoaded()}" />
</p:commandLink>
<p:commandButton
id="removeForTask"
icon="fa fa-trash"
action="#{DataEditorForm.deleteDataEditorSetting()}"
update="metadataEditorLayoutForm dataEditorSavingResultForm"
disabled="#{DataEditorForm.dataEditorSetting.taskId eq null or not layoutWasLoaded}"
styleClass="secondary"
update="metadataEditorLayoutOverlayPanel dataEditorSavingResultForm metadataEditorLayoutButtonForm:open"
disabled="#{not DataEditorForm.isTaskLayoutLoaded()}"
styleClass="secondary"
title="#{msgs['dataEditor.layoutMenuDeleteTitle']}" />
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@

<h:form id="metadataEditorLayoutButtonForm">
<p:commandButton id="open"
title="#{msgs['dataEditor.layoutMenuButtonTitle']}"
icon="fa fa-wrench"
styleClass="secondary"/>
title="#{msgs['dataEditor.layoutMenuButtonTitle']}"
icon="fa fa-wrench"
styleClass="secondary #{DataEditorForm.isGlobalLayoutLoaded() ? 'settings-loaded' : DataEditorForm.isTaskLayoutLoaded() ? 'settings-loaded-task' : ''}"/>
</h:form>

<h:form id="buttonForm">
Expand Down
Loading