use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductToIssueDetailsHooks method fillAdditionalUnit.
private void fillAdditionalUnit(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
if (product != null) {
String additionalUnit = product.getStringField(ProductFields.ADDITIONAL_UNIT);
FieldComponent conversionField = (FieldComponent) view.getComponentByReference("conversion");
if (StringUtils.isEmpty(additionalUnit)) {
conversionField.setFieldValue(BigDecimal.ONE);
conversionField.setEnabled(false);
conversionField.requestComponentUpdateState();
additionalUnit = product.getStringField(ProductFields.UNIT);
}
FieldComponent field = (FieldComponent) view.getComponentByReference("additionalDemandQuantityUnit");
field.setFieldValue(additionalUnit);
field.requestComponentUpdateState();
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductToIssueDetailsHooks method fillUnit.
private void fillUnit(ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
FieldComponent demandUnitField = (FieldComponent) view.getComponentByReference("demandQuantityUnit");
FieldComponent correctionUnitField = (FieldComponent) view.getComponentByReference("correctionUnit");
if (product != null) {
String unit = product.getStringField(ProductFields.UNIT);
demandUnitField.setFieldValue(unit);
correctionUnitField.setFieldValue(unit);
} else {
demandUnitField.setFieldValue(StringUtils.EMPTY);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionCountingServiceImpl method changeDoneQuantityAndAmountOfProducedQuantityFieldState.
@Override
public void changeDoneQuantityAndAmountOfProducedQuantityFieldState(final ViewDefinitionState view) {
FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent doneQuantityField = (FieldComponent) view.getComponentByReference(OrderFields.DONE_QUANTITY);
FieldComponent amountOfProductProducedField = (FieldComponent) view.getComponentByReference(OrderFields.AMOUNT_OF_PRODUCT_PRODUCED);
FieldComponent wastesQuantityField = (FieldComponent) view.getComponentByReference(OrderFields.WASTES_QUANTITY);
Long orderId = orderForm.getEntityId();
if (orderId == null) {
doneQuantityField.setEnabled(false);
amountOfProductProducedField.setEnabled(false);
wastesQuantityField.setEnabled(false);
return;
}
Entity order = orderForm.getEntity().getDataDefinition().get(orderId);
String state = order.getStringField(OrderFields.STATE);
if (OrderStateStringValues.IN_PROGRESS.equals(state) || OrderStateStringValues.INTERRUPTED.equals(state)) {
String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
if (checkIfTypeOfProductionRecordingIsEmptyOrBasic(typeOfProductionRecording)) {
doneQuantityField.setEnabled(true);
wastesQuantityField.setEnabled(true);
amountOfProductProducedField.setEnabled(false);
} else {
doneQuantityField.setEnabled(false);
wastesQuantityField.setEnabled(false);
amountOfProductProducedField.setEnabled(false);
}
} else {
doneQuantityField.setEnabled(false);
wastesQuantityField.setEnabled(false);
amountOfProductProducedField.setEnabled(false);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionTrackingServiceImpl method changeProducedQuantityFieldState.
@Override
public void changeProducedQuantityFieldState(final ViewDefinitionState viewDefinitionState) {
final FormComponent form = (FormComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_FORM);
Entity order = null;
if (form.getEntityId() != null) {
order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(form.getEntityId());
}
FieldComponent typeOfProductionRecording = (FieldComponent) viewDefinitionState.getComponentByReference(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
ComponentState doneQuantity = viewDefinitionState.getComponentByReference(L_DONE_QUANTITY);
ComponentState amountOfPP = viewDefinitionState.getComponentByReference(L_AMOUNT_OF_PRODUCT_PRODUCED);
if (order == null || order.getStringField(OrderFields.STATE).equals(OrderState.PENDING.getStringValue()) || order.getStringField(OrderFields.STATE).equals(OrderState.ACCEPTED.getStringValue())) {
doneQuantity.setEnabled(false);
amountOfPP.setEnabled(false);
} else if ("".equals(typeOfProductionRecording.getFieldValue()) || TypeOfProductionRecording.BASIC.getStringValue().equals(typeOfProductionRecording.getFieldValue())) {
doneQuantity.setEnabled(true);
amountOfPP.setEnabled(true);
} else {
doneQuantity.setEnabled(false);
amountOfPP.setEnabled(false);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class UsedBatchDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity usedBatch = form.getEntity();
Entity trackingOperationProductInComponent = usedBatch.getBelongsToField(UsedBatchFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENT);
if (view.isViewAfterRedirect() && Objects.nonNull(trackingOperationProductInComponent)) {
Entity product = trackingOperationProductInComponent.getBelongsToField(TrackingOperationProductInComponentFields.PRODUCT);
FieldComponent unitField = (FieldComponent) view.getComponentByReference(L_UNIT);
unitField.setFieldValue(product.getStringField(ProductFields.UNIT));
unitField.requestComponentUpdateState();
LookupComponent batchLookup = (LookupComponent) view.getComponentByReference(UsedBatchFields.BATCH);
FilterValueHolder batchFilterValueHolder = batchLookup.getFilterValue();
batchFilterValueHolder.put(L_PRODUCT_ID, product.getId());
batchLookup.setFilterValue(batchFilterValueHolder);
}
}
Aggregations