You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2023/06/10 09:09:36 UTC
[causeway] branch master updated: CAUSEWAY-3442: wkt-vwr: remove colon that separated label and field
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/master by this push:
new 5c06f87427 CAUSEWAY-3442: wkt-vwr: remove colon that separated label and field
5c06f87427 is described below
commit 5c06f87427f093a39af2cdc9630087cc1f057c4d
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat Jun 10 11:09:30 2023 +0200
CAUSEWAY-3442: wkt-vwr: remove colon that separated label and field
---
.../model/decorators/FormLabelDecorator.java | 11 ++++--
.../ui/components/scalars/ScalarPanelAbstract.java | 44 ++++++++++++++--------
.../scalars/ScalarPanelFormFieldAbstract.java | 2 +-
3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/viewers/commons/model/src/main/java/org/apache/causeway/viewer/commons/model/decorators/FormLabelDecorator.java b/viewers/commons/model/src/main/java/org/apache/causeway/viewer/commons/model/decorators/FormLabelDecorator.java
index b6ea322b5b..8456a39bff 100644
--- a/viewers/commons/model/src/main/java/org/apache/causeway/viewer/commons/model/decorators/FormLabelDecorator.java
+++ b/viewers/commons/model/src/main/java/org/apache/causeway/viewer/commons/model/decorators/FormLabelDecorator.java
@@ -40,14 +40,19 @@ public interface FormLabelDecorator<T> {
private static final long serialVersionUID = 1L;
public static FormLabelDecorationModel mandatory(final boolean mandatory) {
- return of(mandatory, ":");
+ /* used to be suffixed with ':' till 2.0.0-RC1;
+ * however, the question arises what to do in the label RIGHT position
+ * and so we concluded, that perhaps its better to remove the suffix colon
+ * all together */
+ return of(mandatory, "");
}
- public static FormLabelDecorationModel mandatorySuffixed(
+ /* not used
+ public static FormLabelDecorationModel mandatorySuffixed2(
final boolean mandatory,
final @Nullable String suffix) {
return of(mandatory, suffix);
- }
+ } */
final boolean mandatoryMarker;
final @Nullable String suffix;
diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
index 6f8537a6d0..f773cfb160 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/scalars/ScalarPanelAbstract.java
@@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
+import java.util.Optional;
import java.util.function.Supplier;
import org.apache.wicket.Component;
@@ -536,37 +537,48 @@ implements ScalarModelChangeListener {
* <p>
* When label-position NONE, then no label should be rendered.
*/
- protected final void addScalarNameLabel(final MarkupContainer container, final IModel<String> labelCaption) {
+ protected final void scalarNameLabelAddTo(final MarkupContainer container, final IModel<String> labelCaption) {
val scalarModel = scalarModel();
val helper = ScalarNameHelper.from(scalarModel);
- WktComponents.permanentlyHide(container, helper.hiddenLabelId);
+ helper.hideHiddenLabels(container);
- final Label scalarNameLabel = Wkt.labelAdd(container, helper.visibleLabelId, labelCaption);
- if(_Strings.isNullOrEmpty(labelCaption.getObject())) {
- return;
- }
+ helper.visibleLabelId.ifPresent(visibleLabelId->{
+
+ final Label scalarNameLabel = Wkt.labelAdd(container, visibleLabelId, labelCaption);
+ if(_Strings.isNullOrEmpty(labelCaption.getObject())) {
+ return;
+ }
- WktDecorators.getFormLabel()
- .decorate(scalarNameLabel, FormLabelDecorationModel
- .mandatory(scalarModel.isShowMandatoryIndicator()));
+ WktDecorators.getFormLabel()
+ .decorate(scalarNameLabel, FormLabelDecorationModel
+ .mandatory(scalarModel.isShowMandatoryIndicator()));
- scalarModel.getDescribedAs()
- .ifPresent(describedAs->WktTooltips.addTooltip(scalarNameLabel, describedAs));
+ scalarModel.getDescribedAs()
+ .ifPresent(describedAs->WktTooltips.addTooltip(scalarNameLabel, describedAs));
+ });
}
@Value
private static class ScalarNameHelper {
static ScalarNameHelper from(final ScalarModel scalarModel) {
final LabelPosition labelPostion = Facets.labelAt(scalarModel.getMetaModel());
- return labelPostion == LabelPosition.RIGHT
- ? new ScalarNameHelper(ID_SCALAR_NAME_AFTER_VALUE, ID_SCALAR_NAME_BEFORE_VALUE)
- : new ScalarNameHelper(ID_SCALAR_NAME_BEFORE_VALUE, ID_SCALAR_NAME_AFTER_VALUE);
+ return labelPostion == LabelPosition.NONE
+ ? new ScalarNameHelper(Optional.empty(), new String[]{ID_SCALAR_NAME_BEFORE_VALUE, ID_SCALAR_NAME_AFTER_VALUE})
+ : labelPostion == LabelPosition.RIGHT
+ ? new ScalarNameHelper(Optional.of(ID_SCALAR_NAME_AFTER_VALUE), new String[]{ID_SCALAR_NAME_BEFORE_VALUE})
+ : new ScalarNameHelper(Optional.of(ID_SCALAR_NAME_BEFORE_VALUE), new String[]{ID_SCALAR_NAME_AFTER_VALUE});
+ }
+ final Optional<String> visibleLabelId;
+ final String[] hiddenLabelIds;
+
+ void hideHiddenLabels(final MarkupContainer container) {
+ for(final String hiddenLabelId : hiddenLabelIds) {
+ WktComponents.permanentlyHide(container, hiddenLabelId);
+ }
}
- final String visibleLabelId;
- final String hiddenLabelId;
}
// ///////////////////////////////////////////////////////////////////
diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/scalars/ScalarPanelFormFieldAbstract.java b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/scalars/ScalarPanelFormFieldAbstract.java
index f93ee93521..e2df65e2b7 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/scalars/ScalarPanelFormFieldAbstract.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/scalars/ScalarPanelFormFieldAbstract.java
@@ -133,7 +133,7 @@ extends ScalarPanelAbstract2 {
Wkt.cssAppend(formGroup, "mandatory");
}
- addScalarNameLabel(formGroup, friendlyNameModel);
+ scalarNameLabelAddTo(formGroup, friendlyNameModel);
formComponent.add(_Util.createValidatorFor(scalarModel));