Skip to content

Commit

Permalink
#268 HU attributes shall always provide the WidgetType along with the…
Browse files Browse the repository at this point in the history
… data/changes
  • Loading branch information
teosarca committed Mar 25, 2017
1 parent 2a1a5bb commit 84da9e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import de.metas.ui.web.window.datatypes.json.JSONDocument;
import de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent;
import de.metas.ui.web.window.datatypes.json.JSONDocumentField;
import de.metas.ui.web.window.datatypes.json.JSONLayoutWidgetType;
import de.metas.ui.web.window.descriptor.DocumentFieldWidgetType;
import de.metas.ui.web.window.exceptions.DocumentFieldReadonlyException;
import de.metas.ui.web.window.model.IDocumentChangesCollector;
Expand Down Expand Up @@ -158,10 +159,13 @@ private final JSONDocumentField toJSONDocumentField(final IAttributeValue attrib
{
final String fieldName = HUDocumentViewAttributesHelper.extractAttributeName(attributeValue);
final Object jsonValue = HUDocumentViewAttributesHelper.extractJSONValue(attributesStorage, attributeValue);
final DocumentFieldWidgetType widgetType = HUDocumentViewAttributesHelper.extractWidgetType(attributeValue);
return JSONDocumentField.ofNameAndValue(fieldName, jsonValue)
.setDisplayed(true)
.setMandatory(false)
.setReadonly(isReadonly(fieldName));
.setReadonly(isReadonly(fieldName))
.setWidgetType(JSONLayoutWidgetType.fromNullable(widgetType))
;
}

private boolean isReadonly(final String attributeName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public static JSONDocumentField ofDocumentFieldChangedEvent(final DocumentFieldC

@JsonProperty("widgetType")
@JsonInclude(JsonInclude.Include.NON_NULL)
private final JSONLayoutWidgetType widgetType;
private JSONLayoutWidgetType widgetType;

@JsonProperty("value")
@JsonInclude(JsonInclude.Include.NON_NULL)
Expand Down Expand Up @@ -233,6 +233,12 @@ public String toString()
valueReason = reason;
return this;
}

public JSONDocumentField setWidgetType(final JSONLayoutWidgetType widgetType)
{
this.widgetType = widgetType;
return this;
}

public JSONDocumentField setReadonly(final boolean readonly, final String reason)
{
Expand Down

0 comments on commit 84da9e3

Please sign in to comment.