Search in sources :

Example 26 with AwesomeDynamicListComponent

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

the class GenerateMRCForOrderHooks method setLocations.

private void setLocations(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity mRCForOrder = form.getEntity();
    Entity order = null;
    Set<Entity> locations = Sets.newHashSet();
    order = mRCForOrder.getBelongsToField("order");
    locations = productFlowThruDivisionService.getProductsLocations(order.getBelongsToField(OrderFields.TECHNOLOGY).getId());
    List<Entity> parameterCoverageLocations = parameterService.getParameter().getHasManyField(ParameterFieldsOS.COVERAGE_LOCATIONS);
    for (Entity parameterCoverageLocation : parameterCoverageLocations) {
        Entity location = parameterCoverageLocation.getBelongsToField(com.qcadoo.mes.orderSupplies.constants.CoverageLocationFields.LOCATION);
        locations.add(location);
    }
    AwesomeDynamicListComponent locationADL = (AwesomeDynamicListComponent) view.getComponentByReference("coverageLocations");
    if (locationADL.getFormComponents().isEmpty()) {
        List<Entity> locationsList = Lists.newArrayList();
        for (Entity location : locations) {
            Entity coverageLocation = mRCForOrderService.getCoverageLocationDD().create();
            coverageLocation.setField(CoverageLocationFields.LOCATION, location);
            locationsList.add(coverageLocation);
        }
        locationADL.setFieldValue(locationsList);
        locationADL.requestComponentUpdateState();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 27 with AwesomeDynamicListComponent

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

the class GenerateMRCForOrderHooks method updateFormState.

public void updateFormState(final ViewDefinitionState view) {
    FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long materialRequirementCoverageId = materialRequirementCoverageForm.getEntityId();
    AwesomeDynamicListComponent adlc = (AwesomeDynamicListComponent) view.getComponentByReference(CoverageForOrderFields.COVERAGE_LOCATIONS);
    boolean saved = checkIfMaterialRequirementCoverageIsSaved(materialRequirementCoverageId);
    materialRequirementCoverageForm.setFormEnabled(!saved);
    List<FormComponent> formComponents = adlc.getFormComponents();
    for (FormComponent formComponent : formComponents) {
        formComponent.setFormEnabled(!saved);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 28 with AwesomeDynamicListComponent

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

the class MRCForOrderDetailsHooks method updateFormState.

public void updateFormState(final ViewDefinitionState view) {
    FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    AwesomeDynamicListComponent adlc = (AwesomeDynamicListComponent) view.getComponentByReference(CoverageForOrderFields.COVERAGE_LOCATIONS);
    Long materialRequirementCoverageId = materialRequirementCoverageForm.getEntityId();
    boolean saved = checkIfMaterialRequirementCoverageIsSaved(materialRequirementCoverageId);
    materialRequirementCoverageForm.setFormEnabled(!saved);
    List<FormComponent> formComponents = adlc.getFormComponents();
    for (FormComponent formComponent : formComponents) {
        formComponent.setFormEnabled(!saved);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 29 with AwesomeDynamicListComponent

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

the class ProfileHooksMF method setupUserLocationsSection.

public void setupUserLocationsSection(final ViewDefinitionState view) {
    view.getComponentByReference(L_USER_LOCATIONS_BORDER_LAYOUT).setVisible(true);
    if (!securityService.hasCurrentUserRole("ROLE_ADMIN")) {
        view.getComponentByReference(L_USER_LOCATIONS).setEnabled(false);
        AwesomeDynamicListComponent userLocations = (AwesomeDynamicListComponent) view.getComponentByReference(L_USER_LOCATIONS);
        userLocations.getFormComponents().forEach(fc -> fc.findFieldComponentByName(L_LOCATION).setEnabled(false));
    }
}
Also used : AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 30 with AwesomeDynamicListComponent

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

the class DivideOrderTechnologicalProcessHooks method updateAwesomeDynamicList.

private void updateAwesomeDynamicList(final ViewDefinitionState view) {
    FormComponent orderTechnologicalProcessForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    AwesomeDynamicListComponent orderTechnologicalProcessPartsADL = (AwesomeDynamicListComponent) view.getComponentByReference(OrderTechnologicalProcessFields.ORDER_TECHNOLOGICAL_PROCESS_PARTS);
    if (view.isViewAfterRedirect()) {
        Entity orderTechnologicalProcess = orderTechnologicalProcessForm.getEntity();
        Long orderTechnologicalProcessId = orderTechnologicalProcess.getId();
        orderTechnologicalProcess = orderTechnologicalProcess.getDataDefinition().get(orderTechnologicalProcessId);
        Entity product = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.PRODUCT);
        BigDecimal quantity = orderTechnologicalProcess.getDecimalField(OrderTechnologicalProcessFields.QUANTITY);
        String productUnit = product.getStringField(ProductFields.UNIT);
        List<Entity> orderTechnologicalProcessParts = Lists.newArrayList();
        BigDecimal half = new BigDecimal(2);
        BigDecimal quantity1;
        BigDecimal quantity2;
        BigDecimal quantitySum = BigDecimal.ZERO;
        if (dictionaryService.checkIfUnitIsInteger(productUnit)) {
            if (isInteger(quantity)) {
                BigDecimal quotient = quantity.divide(half, numberService.getMathContext()).setScale(0, RoundingMode.FLOOR);
                if (BigDecimal.ZERO.compareTo(quantity.remainder(half, numberService.getMathContext())) == 0) {
                    quantity1 = quotient;
                    quantity2 = quotient;
                } else {
                    BigDecimal difference = quantity.subtract(quotient, numberService.getMathContext());
                    quantity1 = quotient;
                    quantity2 = difference;
                }
                quantitySum = quantity1.add(quantity2, numberService.getMathContext());
            } else {
                quantity1 = null;
                quantity2 = null;
            }
        } else {
            BigDecimal quotient = quantity.divide(half, numberService.getMathContext()).setScale(5, RoundingMode.FLOOR);
            quantity1 = quotient;
            quantity2 = quotient;
            quantitySum = quantity1.add(quantity2, numberService.getMathContext());
        }
        if (quantity.compareTo(quantitySum) != 0) {
            quantity1 = null;
            quantity2 = null;
        }
        orderTechnologicalProcessParts.add(createOrderTechnologicalProcessPart("1", quantity1, productUnit));
        orderTechnologicalProcessParts.add(createOrderTechnologicalProcessPart("2", quantity2, productUnit));
        orderTechnologicalProcessPartsADL.setFieldValue(orderTechnologicalProcessParts);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) BigDecimal(java.math.BigDecimal)

Aggregations

AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)36 FormComponent (com.qcadoo.view.api.components.FormComponent)26 Entity (com.qcadoo.model.api.Entity)24 FieldComponent (com.qcadoo.view.api.components.FieldComponent)12 BigDecimal (java.math.BigDecimal)6 ProgressType (com.qcadoo.mes.productionPerShift.constants.ProgressType)4 LookupComponent (com.qcadoo.view.api.components.LookupComponent)4 Optional (com.google.common.base.Optional)2 OrderState (com.qcadoo.mes.orders.states.constants.OrderState)2 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)2 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)2 Function (com.google.common.base.Function)1 DataDefinition (com.qcadoo.model.api.DataDefinition)1 EntityRuntimeException (com.qcadoo.model.api.exception.EntityRuntimeException)1 ErrorMessage (com.qcadoo.model.api.validators.ErrorMessage)1 BigInteger (java.math.BigInteger)1 Around (org.aspectj.lang.annotation.Around)1 JSONException (org.json.JSONException)1 Transactional (org.springframework.transaction.annotation.Transactional)1