Search in sources :

Example 21 with FormComponent

use of com.qcadoo.view.api.components.FormComponent 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 22 with FormComponent

use of com.qcadoo.view.api.components.FormComponent 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 23 with FormComponent

use of com.qcadoo.view.api.components.FormComponent 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 24 with FormComponent

use of com.qcadoo.view.api.components.FormComponent 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)

Example 25 with FormComponent

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

the class UsedBatchDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity usedBatch = form.getEntity();
    Entity trackingOperationProductInComponent = usedBatch.getBelongsToField(UsedBatchFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENT);
    if (view.isViewAfterRedirect() && Objects.nonNull(trackingOperationProductInComponent)) {
        Entity product = trackingOperationProductInComponent.getBelongsToField(TrackingOperationProductInComponentFields.PRODUCT);
        FieldComponent unitField = (FieldComponent) view.getComponentByReference(L_UNIT);
        unitField.setFieldValue(product.getStringField(ProductFields.UNIT));
        unitField.requestComponentUpdateState();
        LookupComponent batchLookup = (LookupComponent) view.getComponentByReference(UsedBatchFields.BATCH);
        FilterValueHolder batchFilterValueHolder = batchLookup.getFilterValue();
        batchFilterValueHolder.put(L_PRODUCT_ID, product.getId());
        batchLookup.setFilterValue(batchFilterValueHolder);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Aggregations

FormComponent (com.qcadoo.view.api.components.FormComponent)644 Entity (com.qcadoo.model.api.Entity)501 FieldComponent (com.qcadoo.view.api.components.FieldComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)104 GridComponent (com.qcadoo.view.api.components.GridComponent)83 BigDecimal (java.math.BigDecimal)55 WindowComponent (com.qcadoo.view.api.components.WindowComponent)52 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)45 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)42 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)39 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)36 Date (java.util.Date)33 DataDefinition (com.qcadoo.model.api.DataDefinition)29 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)28 JSONObject (org.json.JSONObject)28 ComponentState (com.qcadoo.view.api.ComponentState)27 Transactional (org.springframework.transaction.annotation.Transactional)20 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)17 Optional (com.google.common.base.Optional)16 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)16