use of de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions in project metasfresh-webui-api by metasfresh.
the class JSONDocumentFilterDescriptor method ofCollection.
public static List<JSONDocumentFilterDescriptor> ofCollection(@Nullable final Collection<DocumentFilterDescriptor> filters, @NonNull final JSONDocumentLayoutOptions options) {
if (filters == null || filters.isEmpty()) {
return ImmutableList.of();
}
final ImmutableList<DocumentFilterDescriptor> filtersOrdered = filters.stream().sorted(Comparator.comparing(DocumentFilterDescriptor::getSortNo)).collect(ImmutableList.toImmutableList());
final ImmutableList<JSONDocumentFilterDescriptor> defaultFiltersList = filtersOrdered.stream().filter(filter -> !filter.isFrequentUsed()).map(filter -> new JSONDocumentFilterDescriptor(filter, options)).collect(ImmutableList.toImmutableList());
JSONDocumentFilterDescriptor defaultFiltersGroup = !defaultFiltersList.isEmpty() ? new JSONDocumentFilterDescriptor("Filter", defaultFiltersList) : null;
final ImmutableList.Builder<JSONDocumentFilterDescriptor> result = ImmutableList.builder();
for (final DocumentFilterDescriptor filter : filtersOrdered) {
if (filter.isFrequentUsed()) {
result.add(new JSONDocumentFilterDescriptor(filter, options));
} else if (defaultFiltersGroup != null) {
result.add(defaultFiltersGroup);
defaultFiltersGroup = null;
}
}
if (defaultFiltersGroup != null) {
result.add(defaultFiltersGroup);
defaultFiltersGroup = null;
}
return result.build();
}
use of de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions in project metasfresh-webui-api by metasfresh.
the class ETagResponseEntityBuilder method getJSONLayoutOptions.
private JSONDocumentLayoutOptions getJSONLayoutOptions() {
final Supplier<JSONDocumentLayoutOptions> jsonLayoutOptionsSupplier = this._jsonLayoutOptionsSupplier;
if (jsonLayoutOptionsSupplier == null) {
throw new IllegalStateException("jsonLayoutOptions suppliere not configured");
}
final JSONDocumentLayoutOptions jsonLayoutOptions = jsonLayoutOptionsSupplier.get();
if (jsonLayoutOptions == null) {
throw new IllegalStateException("jsonLayoutOptions not configured");
}
return jsonLayoutOptions;
}
use of de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions in project metasfresh-webui-api by metasfresh.
the class BoardRestController method getNewCardsViewLayout.
@GetMapping("/{boardId}/newCardsView/layout")
public JSONNewCardsViewLayout getNewCardsViewLayout(@PathVariable("boardId") final int boardId) {
userSession.assertLoggedIn();
final BoardDescriptor boardDescriptor = boardsRepo.getBoardDescriptor(boardId);
final ViewLayout documentsViewLayout = viewsRepo.getViewLayout(boardDescriptor.getDocumentWindowId(), JSONViewDataType.list, ViewProfileId.NULL);
final JSONDocumentLayoutOptions options = newJSONLayoutOptions();
final String adLanguage = options.getAdLanguage();
return JSONNewCardsViewLayout.builder().caption(documentsViewLayout.getCaption(adLanguage)).description(documentsViewLayout.getDescription(adLanguage)).emptyResultHint(documentsViewLayout.getEmptyResultHint(adLanguage)).emptyResultText(documentsViewLayout.getEmptyResultText(adLanguage)).filters(JSONDocumentFilterDescriptor.ofCollection(documentsViewLayout.getFilters(), options)).orderBys(boardDescriptor.getCardFields().stream().map(cardField -> JSONBoardCardOrderBy.builder().fieldName(cardField.getFieldName()).caption(cardField.getCaption().translate(adLanguage)).build()).collect(ImmutableList.toImmutableList())).build();
}
Aggregations