Search in sources :

Example 1 with TableOperationPresentation

use of com.developmentontheedge.be5.model.TableOperationPresentation in project be5 by DevelopmentOnTheEdge.

the class DocumentGeneratorImpl method presentOperation.

private TableOperationPresentation presentOperation(Query query, Operation operation) {
    String visibleWhen = Operations.determineWhenVisible(operation);
    String title = userAwareMeta.getLocalizedOperationTitle(query.getEntity().getName(), operation.getName());
    // boolean requiresConfirmation = operation.isConfirm();
    boolean isClientSide = Operations.isClientSide(operation);
    Action action = null;
    if (isClientSide) {
        action = Action.call(Operations.asClientSide(operation).toHashUrl());
    }
    return new TableOperationPresentation(operation.getName(), title, visibleWhen, false, isClientSide, action);
}
Also used : Action(com.developmentontheedge.be5.model.Action) TableOperationPresentation(com.developmentontheedge.be5.model.TableOperationPresentation)

Example 2 with TableOperationPresentation

use of com.developmentontheedge.be5.model.TableOperationPresentation in project be5 by DevelopmentOnTheEdge.

the class DocumentGeneratorImpl method collectOperations.

private List<TableOperationPresentation> collectOperations(Query query) {
    List<TableOperationPresentation> operations = new ArrayList<>();
    List<String> userRoles = UserInfoHolder.getCurrentRoles();
    for (Operation operation : getQueryOperations(query)) {
        if (Operations.isAllowed(operation, userRoles)) {
            operations.add(presentOperation(query, operation));
        }
    }
    operations.sort(Comparator.comparing(TableOperationPresentation::getTitle));
    return operations;
}
Also used : TableOperationPresentation(com.developmentontheedge.be5.model.TableOperationPresentation) ArrayList(java.util.ArrayList) Operation(com.developmentontheedge.be5.metadata.model.Operation)

Example 3 with TableOperationPresentation

use of com.developmentontheedge.be5.model.TableOperationPresentation in project be5 by DevelopmentOnTheEdge.

the class DocumentGeneratorImpl method getTable.

public TablePresentation getTable(Query query, Map<String, String> parameters, int sortColumn, boolean sortDesc) {
    List<TableOperationPresentation> operations = collectOperations(query);
    final boolean selectable = !operations.isEmpty() && query.getType() == QueryType.D1;
    int limit = userAwareMeta.getQuerySettings(query).getMaxRecordsPerPage();
    if (limit == 0) {
        // todo delete defaultPageLimit, use getQuerySettings(query).getMaxRecordsPerPage()
        limit = Integer.parseInt(getLayoutObject(query).getOrDefault("defaultPageLimit", coreUtils.getSystemSetting("be5_defaultPageLimit", "10")).toString());
    }
    TableModel table = TableModel.from(query, parameters, selectable, injector).sortOrder(sortColumn, sortDesc).limit(limit).build();
    return getTable(query, parameters, table);
}
Also used : TableOperationPresentation(com.developmentontheedge.be5.model.TableOperationPresentation) TableModel(com.developmentontheedge.be5.query.impl.model.TableModel)

Aggregations

TableOperationPresentation (com.developmentontheedge.be5.model.TableOperationPresentation)3 Operation (com.developmentontheedge.be5.metadata.model.Operation)1 Action (com.developmentontheedge.be5.model.Action)1 TableModel (com.developmentontheedge.be5.query.impl.model.TableModel)1 ArrayList (java.util.ArrayList)1