Search in sources :

Example 1 with JSONDocumentLayoutOptions

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();
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) DocumentFilterInlineRenderMode(de.metas.ui.web.document.filter.DocumentFilterInlineRenderMode) JSONDocumentLayoutOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions) NonNull(lombok.NonNull) Collection(java.util.Collection) Visibility(com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility) JsonAutoDetect(com.fasterxml.jackson.annotation.JsonAutoDetect) DocumentFilterDescriptor(de.metas.ui.web.document.filter.DocumentFilterDescriptor) Value(lombok.Value) LinkedHashMap(java.util.LinkedHashMap) JsonAnySetter(com.fasterxml.jackson.annotation.JsonAnySetter) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) JsonInclude(com.fasterxml.jackson.annotation.JsonInclude) JsonAnyGetter(com.fasterxml.jackson.annotation.JsonAnyGetter) PanelLayoutType(de.metas.ui.web.window.datatypes.PanelLayoutType) Comparator(java.util.Comparator) BarcodeScannerType(de.metas.process.BarcodeScannerType) Nullable(javax.annotation.Nullable) ImmutableList(com.google.common.collect.ImmutableList) DocumentFilterDescriptor(de.metas.ui.web.document.filter.DocumentFilterDescriptor)

Example 2 with JSONDocumentLayoutOptions

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;
}
Also used : JSONDocumentLayoutOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions)

Example 3 with JSONDocumentLayoutOptions

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();
}
Also used : JSONNewCardsViewLayout(de.metas.ui.web.board.json.JSONNewCardsViewLayout) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) JSONDocumentFilterDescriptor(de.metas.ui.web.document.filter.json.JSONDocumentFilterDescriptor) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) ApiOperation(io.swagger.annotations.ApiOperation) IView(de.metas.ui.web.view.IView) Map(java.util.Map) ViewRowOverridesHelper(de.metas.ui.web.view.ViewRowOverridesHelper) GuavaCollectors(de.metas.util.GuavaCollectors) IViewRowOverrides(de.metas.ui.web.view.IViewRowOverrides) ViewLayout(de.metas.ui.web.view.descriptor.ViewLayout) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) JSONBoardCardOrderBy(de.metas.ui.web.board.json.JSONBoardCardOrderBy) ViewResult(de.metas.ui.web.view.ViewResult) PostMapping(org.springframework.web.bind.annotation.PostMapping) JSONDocumentLayoutOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions) Predicate(java.util.function.Predicate) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) JSONBoardCardAddRequest(de.metas.ui.web.board.json.JSONBoardCardAddRequest) UserSession(de.metas.ui.web.session.UserSession) List(java.util.List) ViewRowsOrderBy(de.metas.ui.web.view.ViewRowsOrderBy) IViewsRepository(de.metas.ui.web.view.IViewsRepository) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) BoardCardChangeRequestBuilder(de.metas.ui.web.board.BoardCardChangeRequest.BoardCardChangeRequestBuilder) WebConfig(de.metas.ui.web.config.WebConfig) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) Multimap(com.google.common.collect.Multimap) PatchMapping(org.springframework.web.bind.annotation.PatchMapping) RequestBody(org.springframework.web.bind.annotation.RequestBody) JSONBoardCard(de.metas.ui.web.board.json.JSONBoardCard) ImmutableList(com.google.common.collect.ImmutableList) JSONBoardBuilder(de.metas.ui.web.board.json.JSONBoard.JSONBoardBuilder) GetMapping(org.springframework.web.bind.annotation.GetMapping) JSONFilterViewRequest(de.metas.ui.web.view.json.JSONFilterViewRequest) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) JSONBoard(de.metas.ui.web.board.json.JSONBoard) WeakHashMap(java.util.WeakHashMap) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) ViewProfileId(de.metas.ui.web.view.ViewProfileId) AdempiereException(org.adempiere.exceptions.AdempiereException) FixedOrderByKeyComparator(org.adempiere.util.comparator.FixedOrderByKeyComparator) JSONViewResult(de.metas.ui.web.view.json.JSONViewResult) JSONBoardLane(de.metas.ui.web.board.json.JSONBoardLane) ViewChangesCollector(de.metas.ui.web.view.event.ViewChangesCollector) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest) Collections(java.util.Collections) ViewId(de.metas.ui.web.view.ViewId) JSONNewCardsViewLayout(de.metas.ui.web.board.json.JSONNewCardsViewLayout) ViewLayout(de.metas.ui.web.view.descriptor.ViewLayout) JSONDocumentLayoutOptions(de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

JSONDocumentLayoutOptions (de.metas.ui.web.window.datatypes.json.JSONDocumentLayoutOptions)3 ImmutableList (com.google.common.collect.ImmutableList)2 List (java.util.List)2 Map (java.util.Map)2 JsonAnyGetter (com.fasterxml.jackson.annotation.JsonAnyGetter)1 JsonAnySetter (com.fasterxml.jackson.annotation.JsonAnySetter)1 JsonAutoDetect (com.fasterxml.jackson.annotation.JsonAutoDetect)1 Visibility (com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility)1 JsonCreator (com.fasterxml.jackson.annotation.JsonCreator)1 JsonInclude (com.fasterxml.jackson.annotation.JsonInclude)1 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 Multimap (com.google.common.collect.Multimap)1 BarcodeScannerType (de.metas.process.BarcodeScannerType)1 BoardCardChangeRequestBuilder (de.metas.ui.web.board.BoardCardChangeRequest.BoardCardChangeRequestBuilder)1 JSONBoard (de.metas.ui.web.board.json.JSONBoard)1 JSONBoardBuilder (de.metas.ui.web.board.json.JSONBoard.JSONBoardBuilder)1 JSONBoardCard (de.metas.ui.web.board.json.JSONBoardCard)1 JSONBoardCardAddRequest (de.metas.ui.web.board.json.JSONBoardCardAddRequest)1 JSONBoardCardOrderBy (de.metas.ui.web.board.json.JSONBoardCardOrderBy)1 JSONBoardLane (de.metas.ui.web.board.json.JSONBoardLane)1