use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class ProductDetailsHooks method disableEntityTypeWhenProductFamilyHasChildren.
public void disableEntityTypeWhenProductFamilyHasChildren(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);
Entity product = productForm.getPersistedEntityWithIncludedFormValues();
entityTypeField.setEnabled(product.getHasManyField(ProductFields.CHILDREN).isEmpty());
if (ProductFamilyElementType.PRODUCTS_FAMILY.getStringValue().equals(product.getField(ProductFields.ENTITY_TYPE))) {
parentField.setFieldValue(null);
parentField.setEnabled(false);
} else {
parentField.setEnabled(true);
}
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class SkillStaffDetails method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity opSkill = form.getEntity();
FieldComponent maxSkillLevelField = (FieldComponent) view.getComponentByReference(MAX_LEVEL);
maxSkillLevelField.setFieldValue(opSkill.getBelongsToField(StaffSkillsFields.SKILL).getIntegerField(SkillFields.MAXIMUM_LEVEL));
LookupComponent staffLookup = (LookupComponent) view.getComponentByReference(StaffSkillsFields.STAFF);
FilterValueHolder filterValueHolder = staffLookup.getFilterValue();
Long skillId = opSkill.getBelongsToField(StaffSkillsFields.SKILL).getId();
if (Objects.isNull(skillId)) {
filterValueHolder.remove(L_SKILL_ID);
} else {
filterValueHolder.put(L_SKILL_ID, skillId);
}
staffLookup.setFilterValue(filterValueHolder);
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class StaffSkillDetailsHooks method fillMaxSkill.
private void fillMaxSkill(final ViewDefinitionState view, final LookupComponent skillLookup) {
Entity skill = skillLookup.getEntity();
if (Objects.nonNull(skill)) {
FieldComponent maxSkillLevelField = (FieldComponent) view.getComponentByReference(MAX_LEVEL);
maxSkillLevelField.setFieldValue(skill.getIntegerField(SkillFields.MAXIMUM_LEVEL));
}
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class SubassemblyToWorkstationHelperHooks method refreshTypeComponentValue.
private void refreshTypeComponentValue(ViewDefinitionState view) {
FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity subassemblyToWorkstationHelper = formComponent.getEntity();
Entity subassemly = subassemblyToWorkstationHelper.getBelongsToField(SubassemblyToWorkstationHelperFields.SUBASSEMBLY);
if (subassemly != null) {
subassemblyToWorkstationHelper.setField(SubassemblyToWorkstationHelperFields.TYPE, subassemly.getField(SubassemblyFields.TYPE));
final FieldComponent typeComponent = (FieldComponent) view.getComponentByReference("type");
typeComponent.setFieldValue(subassemly.getField(SubassemblyFields.TYPE));
typeComponent.setEnabled(true);
typeComponent.requestComponentUpdateState();
}
}
use of com.qcadoo.view.api.components.FieldComponent in project mes by qcadoo.
the class PalletNumberDetailsHooks method generatePalletNumber.
private void generatePalletNumber(final ViewDefinitionState view) {
FieldComponent numberField = (FieldComponent) view.getComponentByReference(PalletNumberFields.NUMBER);
if (palletNumberGenerator.checkIfShouldInsertNumber(view)) {
String number = palletNumberGenerator.generate();
numberField.setFieldValue(number);
numberField.requestComponentUpdateState();
}
}
Aggregations