Search in sources :

Example 1 with JSONDocumentField

use of de.metas.ui.web.window.datatypes.json.JSONDocumentField in project metasfresh-webui-api by metasfresh.

the class ASIViewRowAttributes method toJson.

@Override
public JSONViewRowAttributes toJson(final JSONOptions jsonOpts) {
    final DocumentPath documentPath = getDocumentPath();
    final JSONViewRowAttributes jsonDocument = new JSONViewRowAttributes(documentPath);
    final List<JSONDocumentField> jsonFields = asiDoc.getFieldViews().stream().map(field -> toJSONDocumentField(field, jsonOpts)).collect(Collectors.toList());
    jsonDocument.setFields(jsonFields);
    return jsonDocument;
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONLayoutWidgetType(de.metas.ui.web.window.datatypes.json.JSONLayoutWidgetType) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) ASILayout(de.metas.ui.web.pattribute.ASILayout) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Collectors(java.util.stream.Collectors) JSONViewRowAttributes(de.metas.ui.web.view.json.JSONViewRowAttributes) List(java.util.List) ViewRowAttributesLayout(de.metas.ui.web.view.descriptor.ViewRowAttributesLayout) IDocumentFieldView(de.metas.ui.web.window.model.IDocumentFieldView) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) ASIDocument(de.metas.ui.web.pattribute.ASIDocument) DocumentType(de.metas.ui.web.window.datatypes.DocumentType) JSONViewRowAttributes(de.metas.ui.web.view.json.JSONViewRowAttributes) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField)

Example 2 with JSONDocumentField

use of de.metas.ui.web.window.datatypes.json.JSONDocumentField in project metasfresh-webui-api by metasfresh.

the class JSONViewRow method ofRow.

public static JSONViewRow ofRow(final IViewRow row, final IViewRowOverrides rowOverrides, final String adLanguage) {
    // 
    // Document view record
    final JSONViewRow jsonRow = new JSONViewRow(row.getId());
    if (row.isProcessed()) {
        jsonRow.processed = true;
    }
    if (row.getType() != null) {
        // NOTE: mainly used by frontend to decide which Icon to show for this line
        jsonRow.type = row.getType().getIconName();
    }
    // 
    // Fields
    {
        final Map<String, JSONDocumentField> jsonFields = new LinkedHashMap<>();
        // Add pseudo "ID" field first
        {
            final Object id = row.getId().toJson();
            final JSONDocumentField jsonIDField = JSONDocumentField.idField(id);
            jsonFields.put(jsonIDField.getField(), jsonIDField);
        }
        // Append the other fields
        row.getFieldNames().stream().map(createJSONDocumentField(row)).forEach(jsonField -> jsonFields.put(jsonField.getField(), jsonField));
        jsonRow.setFields(jsonFields);
    }
    // 
    // Included documents if any
    {
        final List<? extends IViewRow> includedDocuments = row.getIncludedRows();
        if (!includedDocuments.isEmpty()) {
            jsonRow.includedDocuments = includedDocuments.stream().map(includedRow -> ofRow(includedRow, rowOverrides, adLanguage)).collect(GuavaCollectors.toImmutableList());
        }
    }
    // 
    // Attributes
    jsonRow.supportAttributes = row.hasAttributes();
    // Included views
    if (ViewRowOverridesHelper.extractSupportIncludedViews(row, rowOverrides)) {
        jsonRow.supportIncludedViews = true;
        final ViewId includedViewId = ViewRowOverridesHelper.extractIncludedViewId(row, rowOverrides);
        if (includedViewId != null) {
            jsonRow.includedView = new JSONIncludedViewId(includedViewId.getWindowId(), includedViewId.getViewId());
        }
    }
    // Single column row
    if (row.isSingleColumn()) {
        jsonRow.colspan = true;
        jsonRow.caption = row.getSingleColumnCaption().translate(adLanguage);
    }
    return jsonRow;
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) JSONLayoutWidgetType(de.metas.ui.web.window.datatypes.json.JSONLayoutWidgetType) GuavaCollectors(org.adempiere.util.GuavaCollectors) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) ViewEditorRenderMode(de.metas.ui.web.window.descriptor.ViewEditorRenderMode) Visibility(com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility) WindowId(de.metas.ui.web.window.datatypes.WindowId) JsonAutoDetect(com.fasterxml.jackson.annotation.JsonAutoDetect) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Value(lombok.Value) LinkedHashMap(java.util.LinkedHashMap) JSONDocumentBase(de.metas.ui.web.window.datatypes.json.JSONDocumentBase) List(java.util.List) IViewRow(de.metas.ui.web.view.IViewRow) Map(java.util.Map) ViewRowOverridesHelper(de.metas.ui.web.view.ViewRowOverridesHelper) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) IViewRowOverrides(de.metas.ui.web.view.IViewRowOverrides) JsonInclude(com.fasterxml.jackson.annotation.JsonInclude) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField) ViewId(de.metas.ui.web.view.ViewId) ViewId(de.metas.ui.web.view.ViewId) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) IViewRow(de.metas.ui.web.view.IViewRow) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField)

Example 3 with JSONDocumentField

use of de.metas.ui.web.window.datatypes.json.JSONDocumentField in project metasfresh-webui-api by metasfresh.

the class HUEditorRowAttributes method toJson.

@Override
public JSONViewRowAttributes toJson(final JSONOptions jsonOpts_NOTUSED) {
    final JSONViewRowAttributes jsonDocument = new JSONViewRowAttributes(documentPath);
    final List<JSONDocumentField> jsonFields = attributesStorage.getAttributeValues().stream().map(this::toJSONDocumentField).collect(Collectors.toList());
    jsonDocument.setFields(jsonFields);
    return jsonDocument;
}
Also used : JSONViewRowAttributes(de.metas.ui.web.view.json.JSONViewRowAttributes) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField)

Aggregations

JSONDocumentField (de.metas.ui.web.window.datatypes.json.JSONDocumentField)3 JSONViewRowAttributes (de.metas.ui.web.view.json.JSONViewRowAttributes)2 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)2 JSONLayoutWidgetType (de.metas.ui.web.window.datatypes.json.JSONLayoutWidgetType)2 DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 JsonAutoDetect (com.fasterxml.jackson.annotation.JsonAutoDetect)1 Visibility (com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility)1 JsonInclude (com.fasterxml.jackson.annotation.JsonInclude)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 ASIDocument (de.metas.ui.web.pattribute.ASIDocument)1 ASILayout (de.metas.ui.web.pattribute.ASILayout)1 IViewRow (de.metas.ui.web.view.IViewRow)1 IViewRowOverrides (de.metas.ui.web.view.IViewRowOverrides)1 ViewId (de.metas.ui.web.view.ViewId)1 ViewRowOverridesHelper (de.metas.ui.web.view.ViewRowOverridesHelper)1 ViewRowAttributesLayout (de.metas.ui.web.view.descriptor.ViewRowAttributesLayout)1 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)1 DocumentType (de.metas.ui.web.window.datatypes.DocumentType)1