use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class WarehouseIssueDetailHooks method processProductsToIssueMode.
private void processProductsToIssueMode(final ViewDefinitionState view) {
FieldComponent component = (FieldComponent) view.getComponentByReference(WarehouseIssueFields.PRODUCTS_TO_ISSUE_MODE);
if (!warehouseIssueParameterService.issueForOrder()) {
component.setVisible(false);
component.requestComponentUpdateState();
return;
}
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (view.isViewAfterRedirect() && Objects.isNull(form.getEntityId())) {
component.setFieldValue(warehouseIssueParameterService.getProductsToIssue().getStrValue());
}
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductsToIssueDetailsListeners method onAdditionalDemandQuantityChange.
public void onAdditionalDemandQuantityChange(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
if (!checkIfDecimalFieldsCorrect(productToIssue, form)) {
return;
}
BigDecimal conversion = productToIssue.getDecimalField(ProductsToIssueFields.CONVERSION);
BigDecimal additionalDemandQuantity = productToIssue.getDecimalField(ProductsToIssueFields.ADDITIONAL_DEMAND_QUANTITY);
if (conversion != null && additionalDemandQuantity != null) {
FieldComponent demandQuantity = (FieldComponent) view.getComponentByReference(ProductsToIssueFields.DEMAND_QUANTITY);
Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
BigDecimal newDemandQuantity = calculationQuantityService.calculateQuantity(additionalDemandQuantity, conversion, product.getStringField(ProductFields.UNIT));
demandQuantity.setFieldValue(numberService.formatWithMinimumFractionDigits(newDemandQuantity, 0));
demandQuantity.requestComponentUpdateState();
}
}
use of com.qcadoo.view.api.components.FieldComponent 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.FieldComponent in project mes by qcadoo.
the class TechnologyDetailsHooksPFTD method showHideDivisionField.
public void showHideDivisionField(final ViewDefinitionState view) {
FieldComponent rangeField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.RANGE);
FieldComponent divisionField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.DIVISION);
String range = (String) rangeField.getFieldValue();
GridComponent rangeTechnologyOperationComponent = (GridComponent) view.getComponentByReference(RANGE_TECHNOLOGY_OPERATION_COMPONENT);
ComponentState operationRangeDescriptionLabel = view.getComponentByReference(OPERATION_RANGE_DESCRIPTION);
if (Range.ONE_DIVISION.getStringValue().equals(range)) {
showField(divisionField, true);
rangeTechnologyOperationComponent.setVisible(false);
operationRangeDescriptionLabel.setVisible(false);
} else {
showField(divisionField, false);
rangeTechnologyOperationComponent.setVisible(true);
operationRangeDescriptionLabel.setVisible(true);
}
}
use of com.qcadoo.view.api.components.FieldComponent 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();
}
Aggregations