Search in sources :

Example 11 with AwesomeDynamicListComponent

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

the class GeneralParametersListeners method costsSourceChanged.

public void costsSourceChanged(final ViewDefinitionState state, final ComponentState componentState, final String[] args) {
    AwesomeDynamicListComponent warehousesADL = (AwesomeDynamicListComponent) state.getComponentByReference(ParameterFieldsMFR.WAREHOUSES);
    String costsSource = (String) componentState.getFieldValue();
    if ("01mes".equals(costsSource)) {
        warehousesADL.setEnabled(true);
    } else {
        warehousesADL.setFieldValue(null);
        warehousesADL.setEnabled(false);
    }
}
Also used : AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 12 with AwesomeDynamicListComponent

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

the class GeneralParametersHooksMFR method setCostsSourceAndWarehousesEnabled.

public void setCostsSourceAndWarehousesEnabled(final ViewDefinitionState view) {
    FormComponent parameterForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent costsSourceField = (FieldComponent) view.getComponentByReference(ParameterFieldsMFR.COSTS_SOURCE);
    AwesomeDynamicListComponent warehousesADL = (AwesomeDynamicListComponent) view.getComponentByReference(ParameterFieldsMFR.WAREHOUSES);
    Entity parameter = parameterForm.getPersistedEntityWithIncludedFormValues();
    String costsSource = parameter.getStringField(ParameterFieldsMFR.COSTS_SOURCE);
    boolean automaticUpdateCostNorms = parameter.getBooleanField(ParameterFieldsMFR.AUTOMATIC_UPDATE_COST_NORMS);
    boolean costsSourceIsMes = "01mes".equals(costsSource);
    if (automaticUpdateCostNorms) {
        costsSourceField.setEnabled(true);
        warehousesADL.setEnabled(costsSourceIsMes);
        warehousesADL.getFormComponents().forEach(formComponent -> formComponent.setFormEnabled(costsSourceIsMes));
    } else {
        costsSourceField.setFieldValue(null);
        costsSourceField.setEnabled(false);
        warehousesADL.setFieldValue(null);
        warehousesADL.setEnabled(false);
    }
    costsSourceField.requestComponentUpdateState();
    warehousesADL.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 13 with AwesomeDynamicListComponent

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

the class PalletMoveToStorageLocationHelperHooks method setStorageLocationFilters.

@Override
protected void setStorageLocationFilters(final ViewDefinitionState view) {
    DataDefinition locationDD = dataDefinitionService.get(MaterialFlowConstants.PLUGIN_IDENTIFIER, MaterialFlowConstants.MODEL_LOCATION);
    AwesomeDynamicListComponent adl = (AwesomeDynamicListComponent) view.getComponentByReference("palletStorageStateDtos");
    for (FormComponent form : adl.getFormComponents()) {
        LookupComponent newStorageLocation = (LookupComponent) form.findFieldComponentByName("newStorageLocation");
        FilterValueHolder filter = newStorageLocation.getFilterValue();
        Entity dto = form.getPersistedEntityWithIncludedFormValues();
        String locationNumber = dto.getStringField("locationNumber");
        Entity location = locationDD.find().add(SearchRestrictions.eq(LocationFields.NUMBER, locationNumber)).setMaxResults(1).uniqueResult();
        filter.put(StorageLocationFields.LOCATION, location.getId());
        newStorageLocation.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) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 14 with AwesomeDynamicListComponent

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

the class UserDetailsHooksMF method setupUserLocationsSection.

public void setupUserLocationsSection(final ViewDefinitionState view) {
    view.getComponentByReference(L_USER_LOCATIONS_BORDER_LAYOUT).setVisible(true);
    // Override effect of com.qcadoo.plugins.users.internal.UserService.disableFormForAdmin
    if (securityService.hasCurrentUserRole("ROLE_ADMIN")) {
        view.getComponentByReference(L_USER_LOCATIONS).setEnabled(true);
        AwesomeDynamicListComponent userLocations = (AwesomeDynamicListComponent) view.getComponentByReference(L_USER_LOCATIONS);
        userLocations.getFormComponents().forEach(fc -> fc.findFieldComponentByName(L_LOCATION).setEnabled(true));
    }
}
Also used : AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 15 with AwesomeDynamicListComponent

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

the class MaterialRequirementCoverageHooksAspect method aroundcCopyLocationFromParameter.

@Around("copyLocationFromParameter(view, parameter)")
public void aroundcCopyLocationFromParameter(final ProceedingJoinPoint pjp, final ViewDefinitionState view, final Entity parameter) throws Throwable {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity mRCForOrder = form.getEntity();
    Entity order = mRCForOrder.getBelongsToField("order");
    if (mRCForOrder.getId() == null && order != null) {
        Set<Entity> locations = productFlowThruDivisionService.getProductsLocations(order.getBelongsToField(OrderFields.TECHNOLOGY).getId());
        List<Entity> parameterCoverageLocations = parameter.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();
        }
    } else {
        pjp.proceed();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) Around(org.aspectj.lang.annotation.Around)

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