Skip to content

Commit

Permalink
Password process parameters shall allow showing the password
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Jun 12, 2017
1 parent 787c9ef commit 8498a3d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ private DocumentFieldDescriptor.Builder createProcessParaDescriptor(final WebuiP

final DocumentFieldWidgetType widgetType = DescriptorsFactoryHelper.extractWidgetType(parameterName, adProcessParam.getAD_Reference_ID(), lookupDescriptor);
final Class<?> valueClass = DescriptorsFactoryHelper.getValueClass(widgetType, lookupDescriptor);
final boolean allowShowPassword = widgetType == DocumentFieldWidgetType.Password ? true : false; // process parameters shall always allow displaying the password


final ILogicExpression readonlyLogic = expressionFactory.compileOrDefault(adProcessParam.getReadOnlyLogic(), ConstantLogicExpression.FALSE, ILogicExpression.class);
final ILogicExpression displayLogic = expressionFactory.compileOrDefault(adProcessParam.getDisplayLogic(), ConstantLogicExpression.TRUE, ILogicExpression.class);
Expand All @@ -225,6 +227,7 @@ private DocumentFieldDescriptor.Builder createProcessParaDescriptor(final WebuiP
//
.setValueClass(valueClass)
.setWidgetType(widgetType)
.setAllowShowPassword(allowShowPassword)
.setLookupDescriptorProvider(lookupDescriptorProvider)
//
.setDefaultValueExpression(defaultValueExpr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public Builder addElement(final DocumentFieldDescriptor processParaDescriptor)
.setCaption(processParaDescriptor.getCaption())
.setDescription(processParaDescriptor.getDescription())
.setWidgetType(processParaDescriptor.getWidgetType())
.setAllowShowPassword(processParaDescriptor.isAllowShowPassword())
.addField(DocumentLayoutElementFieldDescriptor.builder(processParaDescriptor.getFieldName())
.setLookupSource(processParaDescriptor.getLookupSourceType())
.setPublicField(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public static JSONDocumentLayoutElement debuggingField(final String fieldName, f
@JsonProperty("widgetType")
private final JSONLayoutWidgetType widgetType;

@JsonProperty("allowShowPassword")
@JsonInclude(JsonInclude.Include.NON_NULL)
private final Boolean allowShowPassword; // in case widgetType is Password


@JsonProperty("buttonProcessId")
@JsonInclude(JsonInclude.Include.NON_NULL)
private final ProcessId buttonProcessId;
Expand Down Expand Up @@ -127,6 +132,7 @@ private JSONDocumentLayoutElement(final DocumentLayoutElementDescriptor element,
description = element.getDescription(adLanguage);

widgetType = JSONLayoutWidgetType.fromNullable(element.getWidgetType());
allowShowPassword = element.isAllowShowPassword() ? Boolean.TRUE : null;
precision = element.getPrecision().orElse(null);

final ButtonFieldActionDescriptor buttonAction = element.getButtonActionDescriptor();
Expand Down Expand Up @@ -154,6 +160,7 @@ private JSONDocumentLayoutElement(final String fieldName, final DocumentFieldWid
description = null;

this.widgetType = JSONLayoutWidgetType.fromNullable(widgetType);
allowShowPassword = null;
buttonProcessId = null;
precision = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public static final Builder builder(final String fieldName)
private final boolean calculated;

private final DocumentFieldWidgetType widgetType;
private final boolean allowShowPassword; // in case widgetType is Password
private final ButtonFieldActionDescriptor buttonActionDescriptor;

private final Class<?> valueClass;
Expand Down Expand Up @@ -150,6 +151,7 @@ private DocumentFieldDescriptor(final Builder builder)
calculated = builder.isCalculated();

widgetType = builder.getWidgetType();
allowShowPassword = builder.isAllowShowPassword();
buttonActionDescriptor = builder.getButtonActionDescriptor();
valueClass = builder.getValueClass();

Expand Down Expand Up @@ -236,6 +238,11 @@ public DocumentFieldWidgetType getWidgetType()
{
return widgetType;
}

public boolean isAllowShowPassword()
{
return allowShowPassword;
}

public ButtonFieldActionDescriptor getButtonActionDescriptor()
{
Expand Down Expand Up @@ -656,7 +663,9 @@ public static final class Builder
private boolean calculated;

private DocumentFieldWidgetType _widgetType;
public Class<?> _valueClass;
private Class<?> _valueClass;
private boolean _allowShowPassword = false; // in case widgetType is Password


// Lookup
private LookupDescriptorProvider lookupDescriptorProvider = LookupDescriptorProvider.NULL;
Expand Down Expand Up @@ -872,6 +881,17 @@ public DocumentFieldWidgetType getWidgetType()
Preconditions.checkNotNull(_widgetType, "widgetType is null");
return _widgetType;
}

public Builder setAllowShowPassword(boolean allowShowPassword)
{
this._allowShowPassword = allowShowPassword;
return this;
}

private boolean isAllowShowPassword()
{
return _allowShowPassword;
}

public Builder setLookupDescriptorProvider(final LookupDescriptorProvider lookupDescriptorProvider)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static final Builder builder(final DocumentFieldDescriptor... fields)

private final DocumentFieldWidgetType widgetType;
private final Optional<Integer> precision;
private final boolean allowShowPassword; // in case widgetType is Password
private final ButtonFieldActionDescriptor buttonActionDescriptor;

private final LayoutType layoutType;
Expand All @@ -104,6 +105,7 @@ private DocumentLayoutElementDescriptor(final Builder builder)

widgetType = builder.getWidgetType();
precision = Optional.ofNullable(builder.getPrecision());
allowShowPassword = builder.isAllowShowPassword();
buttonActionDescriptor = builder.getButtonActionDescriptor();

layoutType = builder.getLayoutType();
Expand Down Expand Up @@ -161,6 +163,11 @@ public Optional<Integer> getPrecision()
{
return precision;
}

public boolean isAllowShowPassword()
{
return allowShowPassword;
}

public LayoutType getLayoutType()
{
Expand Down Expand Up @@ -204,8 +211,11 @@ public static final class Builder
private String _internalName;
private ITranslatableString _caption = null;
private ITranslatableString _description = null;

private DocumentFieldWidgetType _widgetType;
private boolean _allowShowPassword = false; // in case widgetType is Password
private ButtonFieldActionDescriptor buttonActionDescriptor = null;

private LayoutType _layoutType;
private WidgetSize _widgetSize;
private boolean _gridElement = false;
Expand Down Expand Up @@ -360,6 +370,17 @@ private DocumentFieldWidgetType getWidgetType()
Check.assumeNotNull(_widgetType, DocumentLayoutBuildException.class, "Parameter widgetType is not null for {}", this);
return _widgetType;
}

public Builder setAllowShowPassword(boolean allowShowPassword)
{
this._allowShowPassword = allowShowPassword;
return this;
}

private boolean isAllowShowPassword()
{
return _allowShowPassword;
}

private Integer getPrecision()
{
Expand Down

0 comments on commit 8498a3d

Please sign in to comment.