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;
}
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;
}
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;
}
Aggregations