Skip to content

Commit

Permalink
translate select/radio fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rsehr committed Oct 28, 2024
1 parent 3f83cad commit 789a29b
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 23 deletions.
10 changes: 8 additions & 2 deletions module-gui/src/main/webapp/resources/uii/include_journals.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@
fieldType="#{field.displayType}"
propertyValid="#{field.fieldValid}"
errorMessageText="#{field.validationErrorText}"
selectItems="#{field.selectList}"
fieldRequired="#{field.required}"
booleanValue="#{field.booleanValue}"
subValue="#{field.value2}"
Expand All @@ -303,6 +302,10 @@
showHelpBtn="#{field.displayHelpButton}"
helpText="#{field.helpMessage}"
helpTitle="#{field.helpMessageTitle}"
selectItems="#{field.fields}"
var="var"
itemValue="#{var.value}"
itemLabel="#{msgs[var.label]}"
render=":#{cc.clientId}:field_" />

</ui:fragment>
Expand Down Expand Up @@ -560,7 +563,10 @@
fieldRequired="#{field.required}"
propertyValid="#{field.fieldValid}"
errorMessageText="#{field.validationErrorText}"
selectItems="#{field.selectList}"
selectItems="#{field.fields}"
var="var"
itemValue="#{var.value}"
itemLabel="#{msgs[var.label]}"
booleanValue="#{field.booleanValue}"
subValue="#{field.value2}"
displayDuplicateButton="#{field.cardinality == '+' or field.cardinality == '*'}"
Expand Down
15 changes: 12 additions & 3 deletions module-gui/src/main/webapp/resources/uii/include_monographs.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@
propertyValid="#{field.fieldValid}"
fieldRequired="#{field.required}"
errorMessageText="#{field.validationErrorText}"
selectItems="#{field.selectList}"
selectItems="#{field.fields}"
var="var"
itemValue="#{var.value}"
itemLabel="#{msgs[var.label]}"
booleanValue="#{field.booleanValue}"
subValue="#{field.value2}"
displayDuplicateButton="#{field.cardinality == '+' or field.cardinality == '*'}"
Expand Down Expand Up @@ -359,7 +362,10 @@
propertyValid="#{field.fieldValid}"
fieldRequired="#{field.required}"
errorMessageText="#{field.validationErrorText}"
selectItems="#{field.selectList}"
selectItems="#{field.fields}"
var="var"
itemValue="#{var.value}"
itemLabel="#{msgs[var.label]}"
booleanValue="#{field.booleanValue}"
subValue="#{field.value2}"
displayDuplicateButton="#{field.cardinality == '+' or field.cardinality == '*'}"
Expand Down Expand Up @@ -542,7 +548,10 @@
fieldType="#{field.displayType}"
propertyValid="#{field.fieldValid}"
errorMessageText="#{field.validationErrorText}"
selectItems="#{field.selectList}"
selectItems="#{field.fields}"
var="var"
itemValue="#{var.value}"
itemLabel="#{msgs[var.label]}"
booleanValue="#{field.booleanValue}"
subValue="#{field.value2}"
displayDuplicateButton="#{field.cardinality == '+' or field.cardinality == '*'}"
Expand Down
34 changes: 28 additions & 6 deletions module-gui/src/main/webapp/resources/uii/include_userdata.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@
fieldType="#{field.displayType}"
propertyValid="#{field.fieldValid}"
errorMessageText="#{field.validationErrorText}"
selectItems="#{field.selectList}"
selectItems="#{field.fields}"
var="var"
itemValue="#{var.value}"
itemLabel="#{msgs[var.label]}"
booleanValue="#{field.booleanValue}"
fieldRequired="#{field.required}"
subValue="#{field.value2}"
Expand All @@ -243,7 +246,12 @@
render="@form"
showHelpBtn="#{field.displayHelpButton}"
helpText="#{field.helpMessage}"
helpTitle="#{field.helpMessageTitle}" />
helpTitle="#{field.helpMessageTitle}"

var="lang"
itemLabel="#{lang.value}"
itemValue="#{lang.value}"
/>
</h:panelGroup>
</ui:repeat>
</span>
Expand Down Expand Up @@ -416,15 +424,23 @@
fieldRequired="#{field.required}"
propertyValid="#{field.fieldValid}"
errorMessageText="#{field.validationErrorText}"
selectItems="#{field.selectList}"
booleanValue="#{field.booleanValue}"
subValue="#{field.value2}"
displayDuplicateButton="#{field.cardinality == '+' or field.cardinality == '*'}"
displayRemoveButton="#{field.duplicate}"
render="@form"
showHelpBtn="#{field.displayHelpButton}"
helpText="#{field.helpMessage}"
helpTitle="#{field.helpMessageTitle}" />
helpTitle="#{field.helpMessageTitle}"
selectItems="#{field.fields}"
var="var"
itemValue="#{var.value}"
itemLabel="#{msgs[var.label]}"
>



</zlb:field>
</h:panelGroup>
</ui:repeat>
</span>
Expand Down Expand Up @@ -468,7 +484,10 @@
fieldRequired="#{field.required}"
propertyValid="#{field.fieldValid}"
errorMessageText="#{field.validationErrorText}"
selectItems="#{field.selectList}"
selectItems="#{field.fields}"
var="var"
itemValue="#{var.value}"
itemLabel="#{msgs[var.label]}"
booleanValue="#{field.booleanValue}"
subValue="#{field.value2}"
displayDuplicateButton="#{field.cardinality == '+' or field.cardinality == '*'}"
Expand Down Expand Up @@ -528,7 +547,10 @@
fieldRequired="#{field.required}"
propertyValid="#{field.fieldValid}"
errorMessageText="#{field.validationErrorText}"
selectItems="#{field.selectList}"
selectItems="#{field.fields}"
var="var"
itemValue="#{var.value}"
itemLabel="#{msgs[var.label]}"
booleanValue="#{field.booleanValue}"
subValue="#{field.value2}"
displayDuplicateButton="#{field.cardinality == '+' or field.cardinality == '*'}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package de.intranda.goobi.plugins.utils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.validator.routines.checkdigit.EAN13CheckDigit;

import io.goobi.vocabulary.exchange.FieldDefinition;
import io.goobi.vocabulary.exchange.Vocabulary;
import io.goobi.vocabulary.exchange.VocabularySchema;
import io.goobi.workflow.api.vocabulary.VocabularyAPIManager;
import io.goobi.workflow.api.vocabulary.helper.ExtendedVocabularyRecord;
import lombok.Data;
import lombok.extern.java.Log;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.validator.routines.checkdigit.EAN13CheckDigit;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

@Data
@Log
Expand Down Expand Up @@ -113,14 +115,16 @@ public void setVocabulary(String name, String displayField, String importFied) {

Optional<FieldDefinition> displayFieldDefinition = Optional.empty();
if (!StringUtils.isBlank(vocabularyDisplayField)) {
displayFieldDefinition = schema.getDefinitions().stream()
displayFieldDefinition = schema.getDefinitions()
.stream()
.filter(d -> d.getName().equals(vocabularyDisplayField))
.findFirst();
if (displayFieldDefinition.isEmpty()) {
log.warning("Vocabulary display field \"" + vocabularyDisplayField + "\" not present in vocabulary \"" + vocabularyName + "\"");
}
}
Optional<FieldDefinition> importFieldDefinition = schema.getDefinitions().stream()
Optional<FieldDefinition> importFieldDefinition = schema.getDefinitions()
.stream()
.filter(d -> d.getName().equals(vocabularyImportField))
.findFirst();
if (importFieldDefinition.isEmpty()) {
Expand Down Expand Up @@ -384,4 +388,15 @@ public MetadataField cloneField() {
public boolean isDisplayHelpButton() {
return StringUtils.isNotBlank(helpMessage);
}

public List<RadioItem> getFields() {
List<RadioItem> spl = new ArrayList<>();
for (SelectItem si : selectList) {
spl.add(new RadioItem(si.getLabel(), String.valueOf(si.getValue())));

}

return spl;

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package de.intranda.goobi.plugins.utils;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
public class RadioItem {

private String label;
private String value;

}

0 comments on commit 789a29b

Please sign in to comment.