Search in sources :

Example 16 with AwesomeDynamicListComponent

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

the class MaterialRequirementCoverageDetailsHooks method updateFormState.

public void updateFormState(final ViewDefinitionState view) {
    FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    AwesomeDynamicListComponent adlc = (AwesomeDynamicListComponent) view.getComponentByReference(MaterialRequirementCoverageFields.COVERAGE_LOCATIONS);
    materialRequirementCoverageForm.setFormEnabled(false);
    List<FormComponent> formComponents = adlc.getFormComponents();
    for (FormComponent formComponent : formComponents) {
        formComponent.setFormEnabled(false);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 17 with AwesomeDynamicListComponent

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

the class DivideOrderTechnologicalProcessListeners method onDeleteRow.

public void onDeleteRow(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    AwesomeDynamicListComponent orderTechnologicalProcessPartsADL = (AwesomeDynamicListComponent) view.getComponentByReference(OrderTechnologicalProcessFields.ORDER_TECHNOLOGICAL_PROCESS_PARTS);
    List<FormComponent> orderTechnologicalProcessPartForms = orderTechnologicalProcessPartsADL.getFormComponents();
    if (orderTechnologicalProcessPartForms.size() < 2) {
        view.addMessage("orders.divideOrderTechnologicalProcess.divide.notEnough", ComponentState.MessageType.INFO);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 18 with AwesomeDynamicListComponent

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

the class DivideOrderTechnologicalProcessListeners method saveDivision.

public void saveDivision(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent orderTechnologicalProcessForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    AwesomeDynamicListComponent orderTechnologicalProcessPartsADL = (AwesomeDynamicListComponent) view.getComponentByReference(OrderTechnologicalProcessFields.ORDER_TECHNOLOGICAL_PROCESS_PARTS);
    CheckBoxComponent isValidCheckBox = (CheckBoxComponent) view.getComponentByReference(OrderTechnologicalProcessFields.IS_VALID);
    Entity orderTechnologicalProcess = orderTechnologicalProcessForm.getEntity();
    Long orderTechnologicalProcessId = orderTechnologicalProcess.getId();
    orderTechnologicalProcess = orderTechnologicalProcess.getDataDefinition().get(orderTechnologicalProcessId);
    List<FormComponent> orderTechnologicalProcessPartForms = orderTechnologicalProcessPartsADL.getFormComponents();
    boolean isValid = validateDivision(orderTechnologicalProcessForm, orderTechnologicalProcessPartForms, orderTechnologicalProcess);
    if (isValid) {
        for (FormComponent orderTechnologicalProcessPartForm : orderTechnologicalProcessPartForms) {
            FieldComponent numberField = orderTechnologicalProcessPartForm.findFieldComponentByName(OrderTechnologicalProcessPartFields.NUMBER);
            FieldComponent quantityField = orderTechnologicalProcessPartForm.findFieldComponentByName(OrderTechnologicalProcessPartFields.QUANTITY);
            String number = (String) numberField.getFieldValue();
            Either<Exception, Optional<BigDecimal>> eitherQuantity = BigDecimalUtils.tryParse(quantityField.getFieldValue().toString(), LocaleContextHolder.getLocale());
            Optional<BigDecimal> mayBeQuantity = eitherQuantity.getRight();
            if ("1".equals(number)) {
                if (mayBeQuantity.isPresent()) {
                    orderTechnologicalProcess.setField(OrderTechnologicalProcessFields.QUANTITY, mayBeQuantity.get());
                }
                orderTechnologicalProcess.getDataDefinition().save(orderTechnologicalProcess);
            } else {
                Entity orderPack = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.ORDER_PACK);
                Entity order = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.ORDER);
                Entity product = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.PRODUCT);
                Entity operation = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.OPERATION);
                Entity technologyOperationComponent = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.TECHNOLOGY_OPERATION_COMPONENT);
                Entity technologicalProcess = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.TECHNOLOGICAL_PROCESS);
                if (mayBeQuantity.isPresent()) {
                    createOrderTechnologicalProcess(orderPack, order, product, technologyOperationComponent, operation, technologicalProcess, mayBeQuantity.get());
                }
            }
        }
        view.addMessage("orders.divideOrderTechnologicalProcess.divide.success", ComponentState.MessageType.SUCCESS);
    } else {
        view.addMessage("orders.divideOrderTechnologicalProcess.divide.failure", ComponentState.MessageType.FAILURE);
    }
    isValidCheckBox.setChecked(isValid);
    isValidCheckBox.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) Optional(com.google.common.base.Optional) FieldComponent(com.qcadoo.view.api.components.FieldComponent) BigDecimal(java.math.BigDecimal) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 19 with AwesomeDynamicListComponent

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

the class DeliveredProductAddMultiHooks method beforeRender.

public void beforeRender(final ViewDefinitionState view) {
    AwesomeDynamicListComponent deliveredProductMultiPositions = (AwesomeDynamicListComponent) view.getComponentByReference(DeliveredProductMultiFields.DELIVERED_PRODUCT_MULTI_POSITIONS);
    List<FormComponent> formComponents = deliveredProductMultiPositions.getFormComponents();
    BigInteger ordinal = BigInteger.ONE;
    for (FormComponent formComponent : formComponents) {
        FieldComponent conversionField = formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.CONVERSION);
        LookupComponent productLookup = (LookupComponent) formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.PRODUCT);
        FieldComponent unitField = formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.UNIT);
        FieldComponent additionalUnitField = formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.ADDITIONAL_UNIT);
        LookupComponent additionalCodeLookup = (LookupComponent) formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.ADDITIONAL_CODE);
        FieldComponent ordinalField = formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.ORDINAL);
        LookupComponent batchLookup = (LookupComponent) formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.BATCH);
        ordinalField.setFieldValue(ordinal);
        ordinalField.requestComponentUpdateState();
        ordinal = ordinal.add(BigInteger.ONE);
        Entity product = productLookup.getEntity();
        filterAdditionalCode(additionalCodeLookup, product);
        filterBatch(batchLookup, product);
        String unit = (String) unitField.getFieldValue();
        String additionalUnit = (String) additionalUnitField.getFieldValue();
        if (unit.equals(additionalUnit)) {
            conversionField.setEnabled(false);
            conversionField.requestComponentUpdateState();
        }
        boldRequired(formComponent);
    }
    FieldComponent palletNumber = (FieldComponent) view.getComponentByReference(DeliveredProductMultiFields.PALLET_NUMBER);
    palletNumber.setRequired(true);
    FieldComponent storageLocation = (FieldComponent) view.getComponentByReference(DeliveredProductMultiFields.STORAGE_LOCATION);
    storageLocation.setRequired(true);
    setStorageLocationFilter(view);
}
Also used : 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) BigInteger(java.math.BigInteger) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 20 with AwesomeDynamicListComponent

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

the class PalletResourcesTransferHelperHooks method setStorageLocationFilters.

@Override
protected void setStorageLocationFilters(final ViewDefinitionState view) {
    AwesomeDynamicListComponent adl = (AwesomeDynamicListComponent) view.getComponentByReference(L_PALLET_STORAGE_STATE_DTOS);
    for (FormComponent form : adl.getFormComponents()) {
        LookupComponent newPalletNumber = (LookupComponent) form.findFieldComponentByName("newPalletNumber");
        FilterValueHolder filter = newPalletNumber.getFilterValue();
        Entity persistedEntity = form.getPersistedEntityWithIncludedFormValues();
        filter.put(LOCATION_NUMBER, persistedEntity.getStringField(LOCATION_NUMBER));
        filter.put(PALLET_NUMBER, persistedEntity.getStringField(PALLET_NUMBER));
        newPalletNumber.setFilterValue(filter);
    }
}
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) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

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