use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class IssueDetailsHooks method fillUnit.
private void fillUnit(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity issue = form.getPersistedEntityWithIncludedFormValues();
if (issue.getBooleanField(IssueFields.ISSUED)) {
form.setFormEnabled(false);
return;
}
Entity product = issue.getBelongsToField(IssueFields.PRODUCT);
FieldComponent issueUnitField = (FieldComponent) view.getComponentByReference("issueQuantityUnit");
FieldComponent demandUnitField = (FieldComponent) view.getComponentByReference("demandQuantityUnit");
if (product != null) {
String unit = product.getStringField(ProductFields.UNIT);
issueUnitField.setFieldValue(unit);
demandUnitField.setFieldValue(unit);
} else {
issueUnitField.setFieldValue(StringUtils.EMPTY);
demandUnitField.setFieldValue(StringUtils.EMPTY);
}
}
use of com.qcadoo.view.api.components.FieldComponent 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.FieldComponent 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.FieldComponent 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.FieldComponent 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);
}
}
Aggregations