use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class TechnologiesParametersHooksPFTD method setDivisionField.
public void setDivisionField(final ViewDefinitionState view) {
FieldComponent rangeField = (FieldComponent) view.getComponentByReference(ParameterFieldsPFTD.RANGE);
LookupComponent divisionField = (LookupComponent) view.getComponentByReference(ParameterFieldsPFTD.DIVISION);
String range = (String) rangeField.getFieldValue();
boolean isOneDivision = Range.ONE_DIVISION.getStringValue().equals(range);
boolean isManyDivisions = Range.MANY_DIVISIONS.getStringValue().equals(range);
if (isManyDivisions) {
divisionField.setFieldValue(null);
}
divisionField.setVisible(isOneDivision);
divisionField.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class TechnologyDetailsHooksPFTD method fillRangeAndDivision.
private void fillRangeAndDivision(final ViewDefinitionState view) {
FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent rangeField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.RANGE);
LookupComponent divisionLookup = (LookupComponent) view.getComponentByReference(TechnologyFieldsPFTD.DIVISION);
Long technologyId = technologyForm.getEntityId();
if (Objects.isNull(technologyId) && view.isViewAfterRedirect()) {
String range = parameterService.getParameter().getStringField(ParameterFieldsPFTD.RANGE);
Entity division = parameterService.getParameter().getBelongsToField(ParameterFieldsPFTD.DIVISION);
rangeField.setFieldValue(range);
if (Objects.nonNull(division)) {
divisionLookup.setFieldValue(division.getId());
fillFieldsForOneDivisionRange(view);
} else {
divisionLookup.setFieldValue(null);
}
}
rangeField.requestComponentUpdateState();
divisionLookup.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class TechnologyProductionLineDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
LookupComponent productionLineLookup = (LookupComponent) view.getComponentByReference(TechnologyProductionLineFields.PRODUCTION_LINE);
Entity entity = form.getEntity();
Entity technology = entity.getBelongsToField(TechnologyProductionLineFields.TECHNOLOGY);
Entity division = technology.getBelongsToField(TechnologyFieldsPFTD.DIVISION);
FilterValueHolder filterValueHolder = productionLineLookup.getFilterValue();
Long technologyId = technology.getId();
if (Objects.isNull(technologyId)) {
filterValueHolder.remove(TechnologyProductionLineCriteriaModifiers.L_TECHNOLOGY_ID);
} else {
filterValueHolder.put(TechnologyProductionLineCriteriaModifiers.L_TECHNOLOGY_ID, technologyId);
}
if (Objects.nonNull(division)) {
filterValueHolder.put(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID, division.getId());
} else if (filterValueHolder.has(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID)) {
filterValueHolder.remove(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID);
}
productionLineLookup.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class IssueCommonDetailsHelper method setFilterValue.
public void setFilterValue(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
Entity warehouse = productToIssue.getBelongsToField(ProductsToIssueFields.LOCATION);
LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(IssueCommonDetailsHelper.STORAGE_LOCATION);
FilterValueHolder filter = storageLocationLookup.getFilterValue();
LookupComponent additionalCodeLookup = (LookupComponent) view.getComponentByReference(ADDITIONAL_CODE);
FilterValueHolder additionalCodeFilter = additionalCodeLookup.getFilterValue();
if (product != null) {
filter.put(PRODUCT, product.getId());
additionalCodeFilter.put(PRODUCT, product.getId());
} else if (filter.has(PRODUCT)) {
filter.remove(PRODUCT);
additionalCodeFilter.remove(PRODUCT);
}
if (warehouse != null) {
filter.remove(LOCATION);
filter.put(LOCATION, warehouse.getId());
}
storageLocationLookup.setFilterValue(filter);
additionalCodeLookup.setFilterValue(additionalCodeFilter);
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class IssueCommonDetailsHelper method fillStorageLocation.
public void fillStorageLocation(ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
Entity warehouse = productToIssue.getBelongsToField(ProductsToIssueFields.LOCATION);
Entity storageLocation = productToIssue.getBelongsToField(ProductsToIssueFields.STORAGE_LOCATION);
if (product != null && warehouse != null && storageLocation == null) {
Optional<Entity> option = findStorageLocationForProduct(product, warehouse);
if (option.isPresent()) {
LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(IssueCommonDetailsHelper.STORAGE_LOCATION);
storageLocationLookup.setFieldValue(option.get().getId());
storageLocationLookup.requestComponentUpdateState();
}
}
}
Aggregations