Settings dialog

Jens Pelzetter 2020-11-04 21:05:51 +01:00
parent be07d07c98
commit 6078535716
5 changed files with 74 additions and 41 deletions

View File

@ -109,7 +109,20 @@ public class SettingsController {
.sorted() .sorted()
.collect(Collectors.toList()); .collect(Collectors.toList());
models.put("configurationClass", configurationClass);
models.put("settings", settings); models.put("settings", settings);
models.put("BigDecimalClassName", BigDecimal.class.getName());
models.put("BooleanClassName", Boolean.class.getName());
models.put("DoubleClassName", Double.class.getName());
models.put("FloatClassName", Float.class.getName());
models.put("IntegerClassName", Integer.class.getName());
models.put("ListClassName", List.class.getName());
models.put("LongClassName", Long.class.getName());
models.put("LocalizedStringClassName", LocalizedString.class.getName());
models.put("SetClassName", Set.class.getName());
models.put("StringClassName", String.class.getName());
return "org/libreccm/ui/admin/configuration/settings.xhtml"; return "org/libreccm/ui/admin/configuration/settings.xhtml";
} }

View File

@ -6,7 +6,7 @@
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml"> <ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="configuration" /> <ui:param name="activePage" value="configuration" />
<ui:param name="title" <ui:param name="title"
value="#{AdminMessages('configuration.setting.not_found.title')}" /> value="#{AdminMessages['configuration.setting.not_found.title']}" />
<ui:define name="breadcrumb"> <ui:define name="breadcrumb">
<ui:define name="breadcrumb"> <ui:define name="breadcrumb">

View File

@ -132,7 +132,9 @@
id="setting-#{setting.name}-edit-dialog" id="setting-#{setting.name}-edit-dialog"
tabindex="-1"> tabindex="-1">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <form action="#{mvc.uri('SettingsController#updateSettingValue', {'configurationClass': configurationClass, 'settingName': setting.name})}"
class="modal-content"
method="post">
<div class="modal-header"> <div class="modal-header">
<h2 class="model-title" <h2 class="model-title"
id="setting-#{setting.name}-edit-dialog"> id="setting-#{setting.name}-edit-dialog">
@ -144,42 +146,59 @@
type="button"><span aria-hidden="true">&times;</span></button> type="button"><span aria-hidden="true">&times;</span></button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form action="#"> <c:choose>
<c:choose> <c:when test="#{setting.valueType.equals(BigDecimalClassName)}">
<c:when test="#{setting.valueType == BigDecimal.class.getName()}"> <pre>BigDecimal</pre>
<pre>BigDecimal</pre> </c:when>
</c:when> <c:when test="#{setting.valueType.equals(BooleanClassName)}">
<c:when test="#{setting.valueType == Boolean.class.getName()}"> <div class="form-group form-check">
<pre>Boolean</pre> <input aria-describedby="#{setting.name}-setting-value-help"
</c:when> class="form-check-input"
<c:when test="#{setting.valueType == Double.class.getName()}"> id="#{setting.name}-setting-value"
<pre>Double</pre> name="settingValue"
</c:when> type="checkbox" />
<c:when test="#{setting.valueType == Integer.class.getName()}"> <label class="form-check-label"
<pre>Integer</pre> for="#{setting.name}-setting-value">
</c:when> #{AdminMessages['configuration.settings.setting.dialog.value.label']}
<c:when test="#{setting.valueType == "int"}"> </label>
<pre>int</pre> <small class="form-text text-muted"
</c:when> id="#{setting.name}-setting-value-help">
<c:when test="#{setting.valueType == List.class.getName()}"> #{setting.description}
<pre>List</pre> </small>
</c:when> </div>
<c:when test="#{setting.valueType == org.libreccm.l10n.LocalizedString.class.getName()}"> </c:when>
<pre>LocalizedString</pre> <c:when test="#{setting.valueType.equals(DoubleClassName)}">
</c:when> <pre>Double</pre>
<c:when test="#{setting.valueType == Set.class.getName()}"> </c:when>
<pre>Set</pre> <c:when test="#{setting.valueType.equals(IntegerClassName)}">
</c:when> <pre>Integer</pre>
<c:when test="#{setting.valueType == String.class.getName()}"> </c:when>
<pre>String</pre> <c:when test="#{setting.valueType.equals('int')}">
</c:when> <pre>int</pre>
<c:otherwise> </c:when>
<p> <c:when test="#{setting.valueType.equals(ListClassName)}">
#{AdminMessages.getMessage('configuration.settings.setting.dialog.unsupported_type', [setting.valueType])} <pre>List</pre>
</p> </c:when>
</c:otherwise> <c:when test="#{setting.valueType.equals(LocalizedStringClassName)}">
</c:choose> <pre>LocalizedString</pre>
</form> </c:when>
<c:when test="#{setting.valueType.equals(SetClassName)}">
<pre>Set</pre>
</c:when>
<c:when test="#{setting.valueType.equals(StringClassName)}">
<pre>String</pre>
</c:when>
<c:otherwise>
<p>
#{AdminMessages.getMessage('configuration.settings.setting.dialog.unsupported_type', [setting.valueType])}
</p>
<pre>
setting.valueType: #{setting.valueType}
Boolean: #{BooleanClassName}
LocalizedString: #{LocalizedStringClassName}
</pre>
</c:otherwise>
</c:choose>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-danger" <button class="btn btn-danger"
@ -188,12 +207,11 @@
#{AdminMessages['configuration.settings.setting.dialog.close']} #{AdminMessages['configuration.settings.setting.dialog.close']}
</button> </button>
<button class="btn btn-success" <button class="btn btn-success"
data-dismiss="modal" type="submit">
type="button">
#{AdminMessages['configuration.settings.setting.dialog.save']} #{AdminMessages['configuration.settings.setting.dialog.save']}
</button> </button>
</div> </div>
</div> </form>
</div> </div>
</div> </div>
</td> </td>

View File

@ -233,3 +233,4 @@ configuration.setting.invalid_type.title=Invalid type of value
configuration.setting.invalid_type.message=Setting {1} of configuration class {0} is of type {2} but the value {3} can be converted into this type configuration.setting.invalid_type.message=Setting {1} of configuration class {0} is of type {2} but the value {3} can be converted into this type
configuration.setting.not_found.title=Setting not found configuration.setting.not_found.title=Setting not found
configuration.setting.not_found.message=Setting {1} of type {2} not found in configuration class {0} configuration.setting.not_found.message=Setting {1} of type {2} not found in configuration class {0}
configuration.settings.setting.dialog.value.label=Value

View File

@ -233,3 +233,4 @@ configuration.setting.invalid_type.title=Invalid type of value
configuration.setting.invalid_type.message=Einstellung {1} der Konfigurations-Klasse {0} ist vom Typ {2}, der angegebene Wert {3} kann aber nicht in diesen Typ konvertiert werden configuration.setting.invalid_type.message=Einstellung {1} der Konfigurations-Klasse {0} ist vom Typ {2}, der angegebene Wert {3} kann aber nicht in diesen Typ konvertiert werden
configuration.setting.not_found.title=Einstellung nicht gefunden configuration.setting.not_found.title=Einstellung nicht gefunden
configuration.setting.not_found.message=Keine Einstellung {1} vom Typ {3} in Konfiguration {0} gefunden configuration.setting.not_found.message=Keine Einstellung {1} vom Typ {3} in Konfiguration {0} gefunden
configuration.settings.setting.dialog.value.label=Wert