use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class DivisionDetailsListenersPL method onAddExistingEntity.
public void onAddExistingEntity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
if (args.length < 1) {
return;
}
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity division = form.getPersistedEntityWithIncludedFormValues();
List<Long> addedWorkstationIds = lookupUtils.parseIds(args[0]);
for (Long addedWorkstationId : addedWorkstationIds) {
Entity workstation = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_WORKSTATION).get(addedWorkstationId);
workstation.setField(WorkstationFields.DIVISION, division);
workstation.getDataDefinition().save(workstation);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionLineDetailsListeners method onAddExistingEntity.
public void onAddExistingEntity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
if (args.length < 1) {
return;
}
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity productionLine = form.getPersistedEntityWithIncludedFormValues();
List<Long> addedWorkstationIds = lookupUtils.parseIds(args[0]);
for (Long addedWorkstationId : addedWorkstationIds) {
Entity workstation = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_WORKSTATION).get(addedWorkstationId);
workstation.setField(WorkstationFieldsPL.PRODUCTION_LINE, productionLine);
workstation.getDataDefinition().save(workstation);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionPerShiftDetailsHooks method disableReasonOfCorrection.
void disableReasonOfCorrection(final ViewDefinitionState view, final ProgressType progressType, final OrderState orderState) {
boolean enabled = progressType != ProgressType.PLANNED && !UNSUPPORTED_ORDER_STATES.contains(orderState);
AwesomeDynamicListComponent plannedProgressCorrectionTypes = (AwesomeDynamicListComponent) view.getComponentByReference(CORRECTION_CAUSE_TYPES_ADL_REF);
plannedProgressCorrectionTypes.setEnabled(enabled);
for (FormComponent plannedProgressCorrectionTypeForm : plannedProgressCorrectionTypes.getFormComponents()) {
plannedProgressCorrectionTypeForm.setFormEnabled(enabled);
}
view.getComponentByReference(CORRECTION_COMMENT_TEXT_AREA_REF).setEnabled(enabled);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionPerShiftDetailsHooks method fillProgressesUnitFields.
private void fillProgressesUnitFields(final AwesomeDynamicListComponent progressForDaysADL, final Optional<Entity> maybeMainOperationProduct) {
String unit = FluentOptional.wrap(maybeMainOperationProduct).flatMap(EntityUtils.<String>getSafeFieldExtractor(ProductFields.UNIT)).toOpt().orNull();
for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) {
AwesomeDynamicListComponent dailyProgressADL = (AwesomeDynamicListComponent) progressForDayForm.findFieldComponentByName(DAILY_PROGRESS_ADL_REF);
for (FormComponent dailyProgressForm : dailyProgressADL.getFormComponents()) {
FieldComponent unitField = dailyProgressForm.findFieldComponentByName(UNIT_COMPONENT_NAME);
unitField.setFieldValue(unit);
unitField.requestComponentUpdateState();
}
dailyProgressADL.requestComponentUpdateState();
}
progressForDaysADL.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionPerShiftDetailsHooks method setProductAndFillProgressForDays.
public void setProductAndFillProgressForDays(final ViewDefinitionState view, final AwesomeDynamicListComponent progressForDaysADL, final OrderState orderState, final ProgressType progressType) {
FormComponent productionPerShiftForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity pps = productionPerShiftForm.getPersistedEntityWithIncludedFormValues();
Optional<Entity> maybeMainOperationProduct = getMainOutProductFor(pps);
fillOperationProductLookup(view, maybeMainOperationProduct);
fillProgressForDays(progressForDaysADL, pps, maybeMainOperationProduct, progressType, orderState);
fillProgressesUnitFields(progressForDaysADL, maybeMainOperationProduct);
disableComponents(progressForDaysADL, progressType, orderState);
}
Aggregations