use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class ModifyTechnologyDetailsHooks method configureAddPart.
private void configureAddPart(ViewDefinitionState view) {
CheckBoxComponent addNewCheckBox = (CheckBoxComponent) view.getComponentByReference(ModifyTechnologyHelperFields.ADD_NEW);
AwesomeDynamicListComponent addProductAdl = (AwesomeDynamicListComponent) view.getComponentByReference(L_MODIFY_TECHNOLOGY_ADD_PRODUCTS);
if (addNewCheckBox.isChecked()) {
addProductAdl.setEnabled(true);
addProductAdl.getFormComponents().forEach(fc -> {
fc.setFormEnabled(true);
Entity addEntity = fc.getPersistedEntityWithIncludedFormValues();
Entity product = addEntity.getBelongsToField(PRODUCT);
if (Objects.nonNull(product)) {
addEntity.setField(L_UNIT, product.getStringField(ProductFields.UNIT));
fc.setEntity(addEntity);
}
});
} else {
addProductAdl.setEnabled(false);
addProductAdl.getFormComponents().forEach(fc -> fc.setFormEnabled(false));
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class TechnologicalProcessComponentDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
CheckBoxComponent extendedTimeForSizeGroupField = (CheckBoxComponent) view.getComponentByReference(EXTENDED_TIME_FOR_SIZE_GROUP);
FieldComponent increasePercentField = (FieldComponent) view.getComponentByReference(INCREASE_PERCENT);
LookupComponent sizeGroupLookup = (LookupComponent) view.getComponentByReference(SIZE_GROUP);
if (extendedTimeForSizeGroupField.isChecked()) {
increasePercentField.setEnabled(true);
increasePercentField.setRequired(true);
sizeGroupLookup.setEnabled(true);
sizeGroupLookup.setRequired(true);
} else {
increasePercentField.setEnabled(false);
increasePercentField.setFieldValue(null);
increasePercentField.setRequired(false);
sizeGroupLookup.setEnabled(false);
sizeGroupLookup.setFieldValue(null);
sizeGroupLookup.setRequired(false);
}
increasePercentField.requestComponentUpdateState();
sizeGroupLookup.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class ChangeTechnologyParametersListeners method onChangePerformanceNorm.
public void onChangePerformanceNorm(final ViewDefinitionState view, final ComponentState state, final String[] args) {
CheckBoxComponent changePerformanceNorm = (CheckBoxComponent) state;
FieldComponent standardPerformance = (FieldComponent) view.getComponentByReference(L_STANDARD_PERFORMANCE);
if (changePerformanceNorm.isChecked()) {
standardPerformance.setEnabled(true);
} else {
standardPerformance.setEnabled(false);
standardPerformance.setFieldValue(null);
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class TechnologyDetailsListeners method acceptTemplate.
public void acceptTemplate(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
CheckBoxComponent isTemplateAcceptedCheckBox = (CheckBoxComponent) view.getComponentByReference(TechnologyFields.IS_TEMPLATE_ACCEPTED);
Entity technology = technologyForm.getEntity();
Long technologyId = technology.getId();
boolean isTemplateAccepted = isTemplateAcceptedCheckBox.isChecked();
if (Objects.nonNull(technologyId)) {
technology = technology.getDataDefinition().save(technology);
if (isTemplateAccepted || validateTemplate(technologyForm, technology.getDataDefinition().get(technologyId))) {
isTemplateAcceptedCheckBox.setChecked(!isTemplateAccepted);
technologyForm.performEvent(view, "save");
if (technologyForm.isHasError()) {
isTemplateAcceptedCheckBox.setChecked(isTemplateAccepted);
}
}
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class ModifyTechnologyListeners method createTechnologies.
public void createTechnologies(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
componentState.performEvent(view, L_SAVE, args);
CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference(L_GENERATED);
FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (!formComponent.isValid()) {
return;
}
Entity mt = formComponent.getEntity().getDataDefinition().get(formComponent.getEntityId());
ModifyTechnologyResult modifyTechnologyResult = new ModifyTechnologyResult();
createModifiedTechnology(view, componentState, mt, modifyTechnologyResult);
if (!modifyTechnologyResult.getCreatedTechnologies().isEmpty()) {
view.addMessage("technologies.modifyTechnology.createdTechnologies", ComponentState.MessageType.SUCCESS, String.join(",", modifyTechnologyResult.getCreatedTechnologies()));
}
if (!modifyTechnologyResult.getNotCreatedTechnologies().isEmpty()) {
view.addMessage("technologies.modifyTechnology.notCreatedTechnologies", ComponentState.MessageType.FAILURE, String.join(",", modifyTechnologyResult.getNotCreatedTechnologies()));
}
generated.setChecked(true);
}
Aggregations