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);
}
}
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();
}
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);
}
}
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));
}
}
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();
}
}
Aggregations