Search in sources :

Example 16 with FieldComponent

use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.

the class IssueDetailsHooks method fillUnit.

private void fillUnit(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity issue = form.getPersistedEntityWithIncludedFormValues();
    if (issue.getBooleanField(IssueFields.ISSUED)) {
        form.setFormEnabled(false);
        return;
    }
    Entity product = issue.getBelongsToField(IssueFields.PRODUCT);
    FieldComponent issueUnitField = (FieldComponent) view.getComponentByReference("issueQuantityUnit");
    FieldComponent demandUnitField = (FieldComponent) view.getComponentByReference("demandQuantityUnit");
    if (product != null) {
        String unit = product.getStringField(ProductFields.UNIT);
        issueUnitField.setFieldValue(unit);
        demandUnitField.setFieldValue(unit);
    } else {
        issueUnitField.setFieldValue(StringUtils.EMPTY);
        demandUnitField.setFieldValue(StringUtils.EMPTY);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 17 with FieldComponent

use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.

the class ProductToIssueDetailsHooks method fillAdditionalUnit.

private void fillAdditionalUnit(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
    Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
    if (product != null) {
        String additionalUnit = product.getStringField(ProductFields.ADDITIONAL_UNIT);
        FieldComponent conversionField = (FieldComponent) view.getComponentByReference("conversion");
        if (StringUtils.isEmpty(additionalUnit)) {
            conversionField.setFieldValue(BigDecimal.ONE);
            conversionField.setEnabled(false);
            conversionField.requestComponentUpdateState();
            additionalUnit = product.getStringField(ProductFields.UNIT);
        }
        FieldComponent field = (FieldComponent) view.getComponentByReference("additionalDemandQuantityUnit");
        field.setFieldValue(additionalUnit);
        field.requestComponentUpdateState();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 18 with FieldComponent

use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.

the class ProductToIssueDetailsHooks method fillUnit.

private void fillUnit(ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
    Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
    FieldComponent demandUnitField = (FieldComponent) view.getComponentByReference("demandQuantityUnit");
    FieldComponent correctionUnitField = (FieldComponent) view.getComponentByReference("correctionUnit");
    if (product != null) {
        String unit = product.getStringField(ProductFields.UNIT);
        demandUnitField.setFieldValue(unit);
        correctionUnitField.setFieldValue(unit);
    } else {
        demandUnitField.setFieldValue(StringUtils.EMPTY);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 19 with FieldComponent

use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.

the class ProductionCountingServiceImpl method changeDoneQuantityAndAmountOfProducedQuantityFieldState.

@Override
public void changeDoneQuantityAndAmountOfProducedQuantityFieldState(final ViewDefinitionState view) {
    FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent doneQuantityField = (FieldComponent) view.getComponentByReference(OrderFields.DONE_QUANTITY);
    FieldComponent amountOfProductProducedField = (FieldComponent) view.getComponentByReference(OrderFields.AMOUNT_OF_PRODUCT_PRODUCED);
    FieldComponent wastesQuantityField = (FieldComponent) view.getComponentByReference(OrderFields.WASTES_QUANTITY);
    Long orderId = orderForm.getEntityId();
    if (orderId == null) {
        doneQuantityField.setEnabled(false);
        amountOfProductProducedField.setEnabled(false);
        wastesQuantityField.setEnabled(false);
        return;
    }
    Entity order = orderForm.getEntity().getDataDefinition().get(orderId);
    String state = order.getStringField(OrderFields.STATE);
    if (OrderStateStringValues.IN_PROGRESS.equals(state) || OrderStateStringValues.INTERRUPTED.equals(state)) {
        String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
        if (checkIfTypeOfProductionRecordingIsEmptyOrBasic(typeOfProductionRecording)) {
            doneQuantityField.setEnabled(true);
            wastesQuantityField.setEnabled(true);
            amountOfProductProducedField.setEnabled(false);
        } else {
            doneQuantityField.setEnabled(false);
            wastesQuantityField.setEnabled(false);
            amountOfProductProducedField.setEnabled(false);
        }
    } else {
        doneQuantityField.setEnabled(false);
        wastesQuantityField.setEnabled(false);
        amountOfProductProducedField.setEnabled(false);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 20 with FieldComponent

use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.

the class ProductionTrackingServiceImpl method changeProducedQuantityFieldState.

@Override
public void changeProducedQuantityFieldState(final ViewDefinitionState viewDefinitionState) {
    final FormComponent form = (FormComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity order = null;
    if (form.getEntityId() != null) {
        order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(form.getEntityId());
    }
    FieldComponent typeOfProductionRecording = (FieldComponent) viewDefinitionState.getComponentByReference(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
    ComponentState doneQuantity = viewDefinitionState.getComponentByReference(L_DONE_QUANTITY);
    ComponentState amountOfPP = viewDefinitionState.getComponentByReference(L_AMOUNT_OF_PRODUCT_PRODUCED);
    if (order == null || order.getStringField(OrderFields.STATE).equals(OrderState.PENDING.getStringValue()) || order.getStringField(OrderFields.STATE).equals(OrderState.ACCEPTED.getStringValue())) {
        doneQuantity.setEnabled(false);
        amountOfPP.setEnabled(false);
    } else if ("".equals(typeOfProductionRecording.getFieldValue()) || TypeOfProductionRecording.BASIC.getStringValue().equals(typeOfProductionRecording.getFieldValue())) {
        doneQuantity.setEnabled(true);
        amountOfPP.setEnabled(true);
    } else {
        doneQuantity.setEnabled(false);
        amountOfPP.setEnabled(false);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) ComponentState(com.qcadoo.view.api.ComponentState)

Aggregations

FieldComponent (com.qcadoo.view.api.components.FieldComponent)443 Entity (com.qcadoo.model.api.Entity)201 FormComponent (com.qcadoo.view.api.components.FormComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)107 BigDecimal (java.math.BigDecimal)47 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)31 GridComponent (com.qcadoo.view.api.components.GridComponent)31 Date (java.util.Date)30 Optional (com.google.common.base.Optional)18 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)14 ComponentState (com.qcadoo.view.api.ComponentState)13 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)13 WindowComponent (com.qcadoo.view.api.components.WindowComponent)12 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)11 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)9 PossibleUnitConversions (com.qcadoo.model.api.units.PossibleUnitConversions)7 SimpleDateFormat (java.text.SimpleDateFormat)7 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)6 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)6 Collectors (java.util.stream.Collectors)6