Skip to content

Commit

Permalink
Add Java methods to determine whether global or task specific metadat…
Browse files Browse the repository at this point in the history
…a editor layout settings have been loaded or not
  • Loading branch information
solth committed Dec 19, 2024
1 parent 288384d commit 8d74e64
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,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 @@ -405,6 +408,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 @@ -1400,4 +1411,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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
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;">
<h:form id="metadataEditorLayoutForm">
<ul>
Expand All @@ -34,14 +30,14 @@
<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}"
disabled="#{not DataEditorForm.isGlobalLayoutLoaded()}"
styleClass="secondary"
title="#{msgs['dataEditor.layoutMenuDeleteTitle']}" />
</li>
Expand All @@ -56,15 +52,15 @@
<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"
disabled="#{not DataEditorForm.isTaskLayoutLoaded()}"
styleClass="secondary"
title="#{msgs['dataEditor.layoutMenuDeleteTitle']}" />
</li>
</ul>
Expand Down

0 comments on commit 8d74e64

Please sign in to comment.