Search in sources :

Example 1 with DocumentFieldWidgetType

use of de.metas.ui.web.window.descriptor.DocumentFieldWidgetType in project metasfresh-webui-api by metasfresh.

the class ASIViewRowAttributes method toJSONDocumentField.

private final JSONDocumentField toJSONDocumentField(final IDocumentFieldView field, final JSONOptions jsonOpts) {
    final String fieldName = field.getFieldName();
    final Object jsonValue = field.getValueAsJsonObject(jsonOpts.getAD_Language());
    final DocumentFieldWidgetType widgetType = field.getWidgetType();
    return JSONDocumentField.ofNameAndValue(fieldName, jsonValue).setDisplayed(true).setMandatory(false).setReadonly(true).setWidgetType(JSONLayoutWidgetType.fromNullable(widgetType));
}
Also used : DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)

Example 2 with DocumentFieldWidgetType

use of de.metas.ui.web.window.descriptor.DocumentFieldWidgetType in project metasfresh-webui-api by metasfresh.

the class DocumentChanges method collectEvent.

/* package */
void collectEvent(final IDocumentFieldChangedEvent event) {
    final boolean init_isKey = false;
    final boolean init_publicField = true;
    final boolean init_advancedField = false;
    final DocumentFieldWidgetType init_widgetType = event.getWidgetType();
    fieldChangesOf(event.getFieldName(), init_isKey, init_publicField, init_advancedField, init_widgetType).mergeFrom(event);
}
Also used : DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)

Example 3 with DocumentFieldWidgetType

use of de.metas.ui.web.window.descriptor.DocumentFieldWidgetType in project metasfresh-webui-api by metasfresh.

the class DescriptorsFactoryHelper method extractWidgetType.

public static DocumentFieldWidgetType extractWidgetType(final String columnName, final int displayType, final LookupDescriptor lookupDescriptor) {
    final DocumentFieldWidgetType widgetType = extractWidgetType(columnName, displayType);
    if (lookupDescriptor != null && (widgetType == DocumentFieldWidgetType.List || widgetType == DocumentFieldWidgetType.Lookup)) {
        final LookupSource lookupSourceType = lookupDescriptor.getLookupSourceType();
        final DocumentFieldWidgetType lookupWidgetType = extractWidgetType(lookupSourceType);
        if (lookupWidgetType != widgetType) {
            // 
            logger.warn(// 
            "Inconsistent '{}/{}'({}) vs '{}'({}). Considering the widgetType provided by lookupSourceType.", // 
            columnName, // 
            displayType, // 
            widgetType, lookupSourceType, lookupWidgetType);
        }
        return lookupWidgetType;
    }
    return widgetType;
}
Also used : LookupSource(de.metas.ui.web.window.descriptor.DocumentLayoutElementFieldDescriptor.LookupSource) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)

Example 4 with DocumentFieldWidgetType

use of de.metas.ui.web.window.descriptor.DocumentFieldWidgetType in project metasfresh-webui-api by metasfresh.

the class GridTabVOBasedDocumentEntityDescriptorFactory method createAndAddDocumentField.

private final void createAndAddDocumentField(final DocumentEntityDescriptor.Builder entityDescriptor, final GridFieldVO gridFieldVO, final boolean keyColumn) {
    // From entry data-binding:
    final SqlDocumentEntityDataBindingDescriptor.Builder entityBindings = entityDescriptor.getDataBindingBuilder(SqlDocumentEntityDataBindingDescriptor.Builder.class);
    // From GridFieldVO:
    final String fieldName = gridFieldVO.getColumnName();
    final String sqlColumnName = fieldName;
    // 
    final boolean isParentLinkColumn = sqlColumnName.equals(entityBindings.getSqlParentLinkColumnName());
    // 
    // 
    DocumentFieldWidgetType widgetType;
    final Class<?> valueClass;
    final Optional<IExpression<?>> defaultValueExpression;
    final boolean alwaysUpdateable;
    final LookupDescriptorProvider lookupDescriptorProvider;
    final LookupDescriptor lookupDescriptor;
    ILogicExpression readonlyLogic;
    if (isParentLinkColumn) {
        widgetType = DocumentFieldWidgetType.Integer;
        valueClass = widgetType.getValueClass();
        alwaysUpdateable = false;
        lookupDescriptorProvider = LookupDescriptorProvider.NULL;
        lookupDescriptor = null;
        defaultValueExpression = Optional.empty();
        readonlyLogic = ConstantLogicExpression.TRUE;
    } else {
        final int displayType = gridFieldVO.getDisplayType();
        widgetType = DescriptorsFactoryHelper.extractWidgetType(sqlColumnName, displayType);
        alwaysUpdateable = extractAlwaysUpdateable(gridFieldVO);
        final String ctxTableName = Services.get(IADTableDAO.class).retrieveTableName(gridFieldVO.getAD_Table_ID());
        lookupDescriptorProvider = SqlLookupDescriptor.builder().setCtxTableName(ctxTableName).setCtxColumnName(sqlColumnName).setWidgetType(widgetType).setDisplayType(displayType).setAD_Reference_Value_ID(gridFieldVO.getAD_Reference_Value_ID()).setAD_Val_Rule_ID(gridFieldVO.getAD_Val_Rule_ID()).buildProvider();
        lookupDescriptor = lookupDescriptorProvider.provideForScope(LookupDescriptorProvider.LookupScope.DocumentField);
        valueClass = DescriptorsFactoryHelper.getValueClass(widgetType, lookupDescriptor);
        defaultValueExpression = defaultValueExpressionsFactory.extractDefaultValueExpression(gridFieldVO.getDefaultValue(), fieldName, widgetType, valueClass, gridFieldVO.isMandatory(), gridFieldVO.isUseDocSequence());
        if (keyColumn) {
            readonlyLogic = ConstantLogicExpression.TRUE;
        } else if (gridFieldVO.isReadOnly()) {
            readonlyLogic = ConstantLogicExpression.TRUE;
        } else // and we want to allow the user setting it.
        if (!gridFieldVO.isUpdateable() && !gridFieldVO.isParentLink()) {
            readonlyLogic = ConstantLogicExpression.FALSE;
        } else {
            readonlyLogic = gridFieldVO.getReadOnlyLogic();
        }
    }
    // 
    // Button action
    final ButtonFieldActionDescriptor buttonAction;
    if (!isParentLinkColumn && widgetType.isButton()) {
        buttonAction = extractButtonFieldActionDescriptor(entityDescriptor.getTableNameOrNull(), fieldName, gridFieldVO.AD_Process_ID);
        if (buttonAction != null) {
            final ButtonFieldActionType actionType = buttonAction.getActionType();
            if (actionType == ButtonFieldActionType.processCall) {
                widgetType = DocumentFieldWidgetType.ProcessButton;
            } else if (actionType == ButtonFieldActionType.genericZoomInto) {
                widgetType = DocumentFieldWidgetType.ZoomIntoButton;
                // allow pressing the button
                readonlyLogic = ConstantLogicExpression.FALSE;
            }
        }
    } else {
        buttonAction = null;
    }
    // 
    // ORDER BY SortNo
    int orderBySortNo = gridFieldVO.getSortNo();
    if (orderBySortNo == 0 && keyColumn) {
        orderBySortNo = Integer.MAX_VALUE;
    }
    final String sqlColumnSql = gridFieldVO.getColumnSQL(false);
    final SqlDocumentFieldDataBindingDescriptor fieldBinding = SqlDocumentFieldDataBindingDescriptor.builder().setFieldName(sqlColumnName).setTableName(entityBindings.getTableName()).setTableAlias(entityBindings.getTableAlias()).setColumnName(sqlColumnName).setColumnSql(sqlColumnSql).setVirtualColumn(gridFieldVO.isVirtualColumn()).setMandatory(gridFieldVO.isMandatoryDB()).setWidgetType(widgetType).setValueClass(valueClass).setSqlValueClass(entityBindings.getPOInfo().getColumnClass(sqlColumnName)).setLookupDescriptor(lookupDescriptor).setKeyColumn(keyColumn).setEncrypted(gridFieldVO.isEncryptedColumn()).setDefaultOrderBy(orderBySortNo).build();
    final DocumentFieldDescriptor.Builder fieldBuilder = DocumentFieldDescriptor.builder(sqlColumnName).setCaption(gridFieldVO.getHeaderTrls(), gridFieldVO.getHeader()).setDescription(gridFieldVO.getDescriptionTrls(), gridFieldVO.getDescription()).setKey(keyColumn).setParentLink(isParentLinkColumn).setWidgetType(widgetType).setButtonActionDescriptor(buttonAction).setLookupDescriptorProvider(lookupDescriptorProvider).setValueClass(fieldBinding.getValueClass()).setVirtualField(fieldBinding.isVirtualColumn()).setCalculated(gridFieldVO.isCalculated()).setDefaultValueExpression(defaultValueExpression).addCharacteristicIfTrue(keyColumn, Characteristic.SideListField).addCharacteristicIfTrue(keyColumn, Characteristic.GridViewField).setReadonlyLogic(readonlyLogic).setAlwaysUpdateable(alwaysUpdateable).setMandatoryLogic(extractMandatoryLogic(gridFieldVO)).setDisplayLogic(gridFieldVO.getDisplayLogic()).setDefaultFilterInfo(createDefaultFilterDescriptor(gridFieldVO.getDefaultFilterDescriptor(), sqlColumnName, widgetType)).setDataBinding(fieldBinding);
    // 
    // Add Field builder to document entity
    entityDescriptor.addField(fieldBuilder);
    // 
    // Add Field's data binding to entity data binding
    entityBindings.addField(fieldBinding);
    // 
    // Collect special field
    collectSpecialField(fieldBuilder);
}
Also used : SqlDocumentEntityDataBindingDescriptor(de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor) IExpression(org.adempiere.ad.expression.api.IExpression) LookupDescriptorProvider(de.metas.ui.web.window.descriptor.LookupDescriptorProvider) ButtonFieldActionDescriptor(de.metas.ui.web.window.descriptor.ButtonFieldActionDescriptor) SqlDocumentFieldDataBindingDescriptor(de.metas.ui.web.window.descriptor.sql.SqlDocumentFieldDataBindingDescriptor) DocumentFieldDescriptor(de.metas.ui.web.window.descriptor.DocumentFieldDescriptor) ILogicExpression(org.adempiere.ad.expression.api.ILogicExpression) ButtonFieldActionType(de.metas.ui.web.window.descriptor.ButtonFieldActionDescriptor.ButtonFieldActionType) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) LookupDescriptor(de.metas.ui.web.window.descriptor.LookupDescriptor)

Example 5 with DocumentFieldWidgetType

use of de.metas.ui.web.window.descriptor.DocumentFieldWidgetType in project metasfresh-webui-api by metasfresh.

the class Document method executeAllFieldCallouts.

private void executeAllFieldCallouts() {
    fieldCalloutExecutor.executeAll((fieldName) -> {
        final IDocumentField documentField = getFieldOrNull(fieldName);
        if (documentField == null) {
            return null;
        }
        // Skip button callouts because it's expected to execute those callouts ONLY when the button is pressed
        final DocumentFieldWidgetType widgetType = documentField.getWidgetType();
        if (widgetType.isButton()) {
            return null;
        }
        return documentField.asCalloutField();
    });
}
Also used : DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)

Aggregations

DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)20 DocumentFieldDescriptor (de.metas.ui.web.window.descriptor.DocumentFieldDescriptor)6 LookupDescriptor (de.metas.ui.web.window.descriptor.LookupDescriptor)6 ITranslatableString (de.metas.i18n.ITranslatableString)4 Operator (de.metas.ui.web.document.filter.DocumentFilterParam.Operator)3 LookupDescriptorProvider (de.metas.ui.web.window.descriptor.LookupDescriptorProvider)3 SqlDocumentFieldDataBindingDescriptor (de.metas.ui.web.window.descriptor.sql.SqlDocumentFieldDataBindingDescriptor)3 SqlLookupDescriptor (de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor)3 List (java.util.List)3 MoreObjects (com.google.common.base.MoreObjects)2 IModelTranslationMap (de.metas.i18n.IModelTranslationMap)2 Check (de.metas.printing.esb.base.util.Check)2 DocumentFilter (de.metas.ui.web.document.filter.DocumentFilter)2 DocumentFilterParamDescriptor (de.metas.ui.web.document.filter.DocumentFilterParamDescriptor)2 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)2 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)2 SqlDocumentEntityDataBindingDescriptor (de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor)2 SqlEntityFieldBinding (de.metas.ui.web.window.descriptor.sql.SqlEntityFieldBinding)2 BigDecimal (java.math.BigDecimal)2 IExpression (org.adempiere.ad.expression.api.IExpression)2