use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class OrderedProductDetailsListeners method clearAdditionalCode.
private void clearAdditionalCode(final ViewDefinitionState view) {
LookupComponent additionalCodeLookup = (LookupComponent) view.getComponentByReference(OrderedProductFields.ADDITIONAL_CODE);
additionalCodeLookup.setFieldValue(null);
additionalCodeLookup.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class OrderedProductDetailsListeners method fillAdditionalUnit.
private void fillAdditionalUnit(final ViewDefinitionState view) {
LookupComponent productLookup = (LookupComponent) view.getComponentByReference(OrderedProductFields.PRODUCT);
Entity product = productLookup.getEntity();
if (Objects.nonNull(product)) {
String unit = product.getStringField(ProductFields.UNIT);
String additionalUnit = product.getStringField(ProductFields.ADDITIONAL_UNIT);
FieldComponent conversionField = (FieldComponent) view.getComponentByReference(OrderedProductFields.CONVERSION);
if (!StringUtils.isEmpty(additionalUnit)) {
String conversion = numberService.formatWithMinimumFractionDigits(getConversion(product, unit, additionalUnit), 0);
conversionField.setFieldValue(conversion);
conversionField.setEnabled(true);
conversionField.requestComponentUpdateState();
}
quantityChange(view, null, null);
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class DeliveryDetailsHooks method fillLocationDefaultValue.
private void fillLocationDefaultValue(final ViewDefinitionState view) {
FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (Objects.nonNull(deliveryForm.getEntityId())) {
return;
}
LookupComponent locationField = (LookupComponent) view.getComponentByReference(DeliveryFields.LOCATION);
Entity location = locationField.getEntity();
if (Objects.isNull(location) && !view.isViewAfterReload()) {
Entity defaultLocation = parameterService.getParameter().getBelongsToField(DeliveryFields.LOCATION);
if (Objects.isNull(defaultLocation)) {
locationField.setFieldValue(null);
} else {
locationField.setFieldValue(defaultLocation.getId());
}
locationField.requestComponentUpdateState();
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class DeliveryDetailsHooks method fillCurrencyFields.
private void fillCurrencyFields(final ViewDefinitionState view) {
FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
List<String> referenceNames = Lists.newArrayList("deliveredProductsCumulatedTotalPriceCurrency", "orderedProductsCumulatedTotalPriceCurrency");
Entity delivery = deliveryForm.getEntity();
deliveriesService.fillCurrencyFieldsForDelivery(view, referenceNames, delivery);
LookupComponent currencyLookup = (LookupComponent) view.getComponentByReference(DeliveryFields.CURRENCY);
if (Objects.isNull(currencyLookup.getFieldValue()) && Objects.isNull(deliveryForm.getEntityId())) {
Entity currencyEntity = currencyService.getCurrentCurrency();
currencyLookup.setFieldValue(currencyEntity.getId());
currencyLookup.requestComponentUpdateState();
}
}
use of com.qcadoo.view.api.components.LookupComponent in project mes by qcadoo.
the class DeliveryDetailsHooks method changeLocationEnabledDependOnState.
private void changeLocationEnabledDependOnState(final ViewDefinitionState view) {
FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
LookupComponent locationField = (LookupComponent) view.getComponentByReference(DeliveryFields.LOCATION);
if (Objects.isNull(deliveryForm.getEntityId())) {
locationField.setEnabled(true);
} else {
FieldComponent stateField = (FieldComponent) view.getComponentByReference(DeliveryFields.STATE);
String state = stateField.getFieldValue().toString();
locationField.setEnabled(!DeliveryState.DECLINED.getStringValue().equals(state) && !DeliveryState.RECEIVED.getStringValue().equals(state) && !DeliveryState.RECEIVE_CONFIRM_WAITING.getStringValue().equals(state));
}
}
Aggregations