use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class DivideOrderTechnologicalProcessListeners method saveDivision.
public void saveDivision(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent orderTechnologicalProcessForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
AwesomeDynamicListComponent orderTechnologicalProcessPartsADL = (AwesomeDynamicListComponent) view.getComponentByReference(OrderTechnologicalProcessFields.ORDER_TECHNOLOGICAL_PROCESS_PARTS);
CheckBoxComponent isValidCheckBox = (CheckBoxComponent) view.getComponentByReference(OrderTechnologicalProcessFields.IS_VALID);
Entity orderTechnologicalProcess = orderTechnologicalProcessForm.getEntity();
Long orderTechnologicalProcessId = orderTechnologicalProcess.getId();
orderTechnologicalProcess = orderTechnologicalProcess.getDataDefinition().get(orderTechnologicalProcessId);
List<FormComponent> orderTechnologicalProcessPartForms = orderTechnologicalProcessPartsADL.getFormComponents();
boolean isValid = validateDivision(orderTechnologicalProcessForm, orderTechnologicalProcessPartForms, orderTechnologicalProcess);
if (isValid) {
for (FormComponent orderTechnologicalProcessPartForm : orderTechnologicalProcessPartForms) {
FieldComponent numberField = orderTechnologicalProcessPartForm.findFieldComponentByName(OrderTechnologicalProcessPartFields.NUMBER);
FieldComponent quantityField = orderTechnologicalProcessPartForm.findFieldComponentByName(OrderTechnologicalProcessPartFields.QUANTITY);
String number = (String) numberField.getFieldValue();
Either<Exception, Optional<BigDecimal>> eitherQuantity = BigDecimalUtils.tryParse(quantityField.getFieldValue().toString(), LocaleContextHolder.getLocale());
Optional<BigDecimal> mayBeQuantity = eitherQuantity.getRight();
if ("1".equals(number)) {
if (mayBeQuantity.isPresent()) {
orderTechnologicalProcess.setField(OrderTechnologicalProcessFields.QUANTITY, mayBeQuantity.get());
}
orderTechnologicalProcess.getDataDefinition().save(orderTechnologicalProcess);
} else {
Entity orderPack = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.ORDER_PACK);
Entity order = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.ORDER);
Entity product = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.PRODUCT);
Entity operation = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.OPERATION);
Entity technologyOperationComponent = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.TECHNOLOGY_OPERATION_COMPONENT);
Entity technologicalProcess = orderTechnologicalProcess.getBelongsToField(OrderTechnologicalProcessFields.TECHNOLOGICAL_PROCESS);
if (mayBeQuantity.isPresent()) {
createOrderTechnologicalProcess(orderPack, order, product, technologyOperationComponent, operation, technologicalProcess, mayBeQuantity.get());
}
}
}
view.addMessage("orders.divideOrderTechnologicalProcess.divide.success", ComponentState.MessageType.SUCCESS);
} else {
view.addMessage("orders.divideOrderTechnologicalProcess.divide.failure", ComponentState.MessageType.FAILURE);
}
isValidCheckBox.setChecked(isValid);
isValidCheckBox.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class OrderTechnologicalProcessWasteSingleDetailsListeners method saveWaste.
public void saveWaste(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent orderTechnologicalProcessWasteForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
CheckBoxComponent isValidCheckBox = (CheckBoxComponent) view.getComponentByReference(OrderTechnologicalProcessFields.IS_VALID);
orderTechnologicalProcessWasteForm.performEvent(view, "save");
boolean isValid = orderTechnologicalProcessWasteForm.isValid();
isValidCheckBox.setChecked(isValid);
isValidCheckBox.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class SetCategoryListeners method setCategory.
public void setCategory(final ViewDefinitionState view, final ComponentState state, final String[] args) throws JSONException {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
CheckBoxComponent generated = (CheckBoxComponent) view.getComponentByReference("generated");
FieldComponent orderCategory = (FieldComponent) view.getComponentByReference("orderCategory");
String value = (String) orderCategory.getFieldValue();
JSONObject context = view.getJsonContext();
Set<Long> ids = Arrays.stream(context.getString("window.mainTab.form.selectedEntities").replaceAll("[\\[\\]]", "").split(",")).map(Long::valueOf).collect(Collectors.toSet());
ids.forEach(orderId -> {
fillCategory(value, orderId);
});
generated.setChecked(true);
view.addMessage("orders.order.setCategory.success", ComponentState.MessageType.SUCCESS);
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class ParametersHooksO method onPlanningParametersBeforeRender.
public void onPlanningParametersBeforeRender(final ViewDefinitionState view) {
CheckBoxComponent automaticallyGenerateTasksForOrder = (CheckBoxComponent) view.getComponentByReference(L_AUTOMATICALLY_GENERATE_TASKS_FOR_ORDER);
CheckBoxComponent completeStationAndEmployeeInGeneratedTasks = (CheckBoxComponent) view.getComponentByReference(L_COMPLETE_STATION_AND_EMPLOYEE_IN_GENERATED_TASKS);
if (automaticallyGenerateTasksForOrder.isChecked()) {
completeStationAndEmployeeInGeneratedTasks.setEnabled(true);
} else {
completeStationAndEmployeeInGeneratedTasks.setEnabled(false);
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class ParametersHooksO method onOrdersParameterBeforeRender.
public void onOrdersParameterBeforeRender(final ViewDefinitionState view) {
CheckBoxComponent realizationFromStockComponent = (CheckBoxComponent) view.getComponentByReference(L_REALIZATION_FROM_STOCK);
CheckBoxComponent alwaysOrderItemsWithPersonalizationComponent = (CheckBoxComponent) view.getComponentByReference(L_ALWAYS_ORDER_ITEMS_WITH_PERSONALIZATION);
GridComponent realizationLocationsGrid = (GridComponent) view.getComponentByReference(L_REALIZATION_LOCATIONS);
if (realizationFromStockComponent.isChecked()) {
alwaysOrderItemsWithPersonalizationComponent.setEnabled(true);
realizationLocationsGrid.setEditable(true);
} else {
alwaysOrderItemsWithPersonalizationComponent.setEnabled(false);
realizationLocationsGrid.setEditable(false);
}
alwaysOrderItemsWithPersonalizationComponent.requestComponentUpdateState();
}
Aggregations