Search in sources :

Example 6 with AwesomeDynamicListComponent

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

the class ProductionPerShiftDetailsHooks method disableReasonOfCorrection.

void disableReasonOfCorrection(final ViewDefinitionState view, final ProgressType progressType, final OrderState orderState) {
    boolean enabled = progressType != ProgressType.PLANNED && !UNSUPPORTED_ORDER_STATES.contains(orderState);
    AwesomeDynamicListComponent plannedProgressCorrectionTypes = (AwesomeDynamicListComponent) view.getComponentByReference(CORRECTION_CAUSE_TYPES_ADL_REF);
    plannedProgressCorrectionTypes.setEnabled(enabled);
    for (FormComponent plannedProgressCorrectionTypeForm : plannedProgressCorrectionTypes.getFormComponents()) {
        plannedProgressCorrectionTypeForm.setFormEnabled(enabled);
    }
    view.getComponentByReference(CORRECTION_COMMENT_TEXT_AREA_REF).setEnabled(enabled);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 7 with AwesomeDynamicListComponent

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

the class ProductionPerShiftDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get();
    OrderState orderState = OrderState.of(order);
    ProgressType progressType = resolveProgressType(view);
    AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view.getComponentByReference(PROGRESS_ADL_REF);
    if (!isViewAlreadyInitialized(view)) {
        fillOrderDateComponents(view, order);
        setupProgressTypeComboBox(view, orderState, progressType);
        setProductAndFillProgressForDays(view, progressForDaysADL, orderState, progressType);
    }
    disableReasonOfCorrection(view, progressType, orderState);
    disableComponents(progressForDaysADL, progressType, orderState);
    changeButtonState(view, progressType, orderState);
    updateAutoFillButtonState(view);
    setupHasBeenCorrectedCheckbox(view);
    checkOrderDates(view, order);
    markViewAsInitialized(view);
    deviationNotify(view);
}
Also used : Entity(com.qcadoo.model.api.Entity) ProgressType(com.qcadoo.mes.productionPerShift.constants.ProgressType) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) OrderState(com.qcadoo.mes.orders.states.constants.OrderState)

Example 8 with AwesomeDynamicListComponent

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

the class ProductionPerShiftDetailsHooks method fillProgressesUnitFields.

private void fillProgressesUnitFields(final AwesomeDynamicListComponent progressForDaysADL, final Optional<Entity> maybeMainOperationProduct) {
    String unit = FluentOptional.wrap(maybeMainOperationProduct).flatMap(EntityUtils.<String>getSafeFieldExtractor(ProductFields.UNIT)).toOpt().orNull();
    for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) {
        AwesomeDynamicListComponent dailyProgressADL = (AwesomeDynamicListComponent) progressForDayForm.findFieldComponentByName(DAILY_PROGRESS_ADL_REF);
        for (FormComponent dailyProgressForm : dailyProgressADL.getFormComponents()) {
            FieldComponent unitField = dailyProgressForm.findFieldComponentByName(UNIT_COMPONENT_NAME);
            unitField.setFieldValue(unit);
            unitField.requestComponentUpdateState();
        }
        dailyProgressADL.requestComponentUpdateState();
    }
    progressForDaysADL.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 9 with AwesomeDynamicListComponent

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

the class ModifyTechnologyDetailsHooks method configureAddPart.

private void configureAddPart(ViewDefinitionState view) {
    CheckBoxComponent addNewCheckBox = (CheckBoxComponent) view.getComponentByReference(ModifyTechnologyHelperFields.ADD_NEW);
    AwesomeDynamicListComponent addProductAdl = (AwesomeDynamicListComponent) view.getComponentByReference(L_MODIFY_TECHNOLOGY_ADD_PRODUCTS);
    if (addNewCheckBox.isChecked()) {
        addProductAdl.setEnabled(true);
        addProductAdl.getFormComponents().forEach(fc -> {
            fc.setFormEnabled(true);
            Entity addEntity = fc.getPersistedEntityWithIncludedFormValues();
            Entity product = addEntity.getBelongsToField(PRODUCT);
            if (Objects.nonNull(product)) {
                addEntity.setField(L_UNIT, product.getStringField(ProductFields.UNIT));
                fc.setEntity(addEntity);
            }
        });
    } else {
        addProductAdl.setEnabled(false);
        addProductAdl.getFormComponents().forEach(fc -> fc.setFormEnabled(false));
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 10 with AwesomeDynamicListComponent

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

the class ProductDetailsHooks method disableUnitFromWhenFormIsSaved.

public void disableUnitFromWhenFormIsSaved(final ViewDefinitionState view) {
    FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    AwesomeDynamicListComponent conversionItemsAdl = (AwesomeDynamicListComponent) view.getComponentByReference(CONVERSION_ITEMS);
    conversionItemsAdl.setEnabled(Objects.nonNull(productForm.getEntityId()));
    for (FormComponent formComponent : conversionItemsAdl.getFormComponents()) {
        formComponent.findFieldComponentByName(UNIT_FROM).setEnabled(Objects.isNull(formComponent.getEntityId()));
    }
    FieldComponent additionalUnit = (FieldComponent) view.getComponentByReference(ProductFields.ADDITIONAL_UNIT);
    additionalUnit.setEnabled(Objects.nonNull(productForm.getEntityId()));
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) 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