use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class StaffService method setOwnerCompany.
public void setOwnerCompany(final ViewDefinitionState view) {
FormComponent staffForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent workForLookup = (FieldComponent) view.getComponentByReference(StaffFields.WORK_FOR);
Entity ownerCompany = companyService.getCompany();
if ((staffForm.getEntityId() != null) || (workForLookup.getFieldValue() != null) || (ownerCompany == null)) {
return;
}
workForLookup.setFieldValue(ownerCompany.getId());
workForLookup.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductAttributeValueDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
setValueBold(view);
setFilters(view);
LookupComponent attributeLookup = (LookupComponent) view.getComponentByReference(ProductAttributeValueFields.ATTRIBUTE);
LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductAttributeValueFields.ATTRIBUTE_VALUE);
FieldComponent valueField = (FieldComponent) view.getComponentByReference(ProductAttributeValueFields.VALUE);
if (Objects.nonNull(attributeLookup.getEntity())) {
Entity attribute = attributeLookup.getEntity();
FieldComponent unitField = (FieldComponent) view.getComponentByReference(L_UNIT);
unitField.setFieldValue(attribute.getStringField(AttributeFields.UNIT));
unitField.requestComponentUpdateState();
if (AttributeDataType.CONTINUOUS.getStringValue().equals(attribute.getStringField(AttributeFields.DATA_TYPE))) {
valueField.setVisible(true);
attributeValueLookup.setVisible(false);
} else {
valueField.setVisible(false);
attributeValueLookup.setVisible(true);
}
} else {
valueField.setVisible(false);
attributeValueLookup.setVisible(false);
}
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductDetailsHooks method disableProductFormForExternalItems.
public void disableProductFormForExternalItems(final ViewDefinitionState view) {
FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent entityTypeField = (FieldComponent) view.getComponentByReference(ProductFields.ENTITY_TYPE);
FieldComponent parentField = (FieldComponent) view.getComponentByReference(ProductFields.PARENT);
FieldComponent categoryField = (FieldComponent) view.getComponentByReference(ProductFields.CATEGORY);
LookupComponent supplierLookup = (LookupComponent) view.getComponentByReference(ProductFields.SUPPLIER);
LookupComponent assortmentLookup = (LookupComponent) view.getComponentByReference(ProductFields.ASSORTMENT);
LookupComponent modelLookup = (LookupComponent) view.getComponentByReference(ProductFields.MODEL);
Long productId = productForm.getEntityId();
if (Objects.isNull(productId)) {
productForm.setFormEnabled(true);
return;
}
Entity product = getProductDD().get(productId);
if (Objects.isNull(product)) {
return;
}
String externalNumber = product.getStringField(ProductFields.EXTERNAL_NUMBER);
if (StringUtils.isEmpty(externalNumber)) {
productForm.setFormEnabled(true);
} else {
productForm.setFormEnabled(false);
entityTypeField.setEnabled(true);
parentField.setEnabled(true);
categoryField.setEnabled(true);
supplierLookup.setEnabled(true);
assortmentLookup.setEnabled(true);
modelLookup.setEnabled(true);
}
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductDetailsHooks method fillUnit.
public void fillUnit(final ViewDefinitionState view) {
FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent unitField = (FieldComponent) view.getComponentByReference(UNIT);
if (Objects.isNull(productForm.getEntityId()) && Objects.isNull(unitField.getFieldValue())) {
unitField.setFieldValue(unitService.getDefaultUnitFromSystemParameters());
unitField.requestComponentUpdateState();
}
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductDetailsHooks method disableUnitFromWhenFormIsSaved.
public void disableUnitFromWhenFormIsSaved(final ViewDefinitionState view) {
FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
AwesomeDynamicListComponent conversionItemsAdl = (AwesomeDynamicListComponent) view.getComponentByReference(CONVERSION_ITEMS);
conversionItemsAdl.setEnabled(Objects.nonNull(productForm.getEntityId()));
for (FormComponent formComponent : conversionItemsAdl.getFormComponents()) {
formComponent.findFieldComponentByName(UNIT_FROM).setEnabled(Objects.isNull(formComponent.getEntityId()));
}
FieldComponent additionalUnit = (FieldComponent) view.getComponentByReference(ProductFields.ADDITIONAL_UNIT);
additionalUnit.setEnabled(Objects.nonNull(productForm.getEntityId()));
}
Aggregations