use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class MaterialRequirementCoverageDetailsHooks method updateFormState.
public void updateFormState(final ViewDefinitionState view) {
FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
AwesomeDynamicListComponent adlc = (AwesomeDynamicListComponent) view.getComponentByReference(MaterialRequirementCoverageFields.COVERAGE_LOCATIONS);
materialRequirementCoverageForm.setFormEnabled(false);
List<FormComponent> formComponents = adlc.getFormComponents();
for (FormComponent formComponent : formComponents) {
formComponent.setFormEnabled(false);
}
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class DivideOrderTechnologicalProcessListeners method onDeleteRow.
public void onDeleteRow(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
AwesomeDynamicListComponent orderTechnologicalProcessPartsADL = (AwesomeDynamicListComponent) view.getComponentByReference(OrderTechnologicalProcessFields.ORDER_TECHNOLOGICAL_PROCESS_PARTS);
List<FormComponent> orderTechnologicalProcessPartForms = orderTechnologicalProcessPartsADL.getFormComponents();
if (orderTechnologicalProcessPartForms.size() < 2) {
view.addMessage("orders.divideOrderTechnologicalProcess.divide.notEnough", ComponentState.MessageType.INFO);
}
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent 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.AwesomeDynamicListComponent in project mes by qcadoo.
the class DeliveredProductAddMultiHooks method beforeRender.
public void beforeRender(final ViewDefinitionState view) {
AwesomeDynamicListComponent deliveredProductMultiPositions = (AwesomeDynamicListComponent) view.getComponentByReference(DeliveredProductMultiFields.DELIVERED_PRODUCT_MULTI_POSITIONS);
List<FormComponent> formComponents = deliveredProductMultiPositions.getFormComponents();
BigInteger ordinal = BigInteger.ONE;
for (FormComponent formComponent : formComponents) {
FieldComponent conversionField = formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.CONVERSION);
LookupComponent productLookup = (LookupComponent) formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.PRODUCT);
FieldComponent unitField = formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.UNIT);
FieldComponent additionalUnitField = formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.ADDITIONAL_UNIT);
LookupComponent additionalCodeLookup = (LookupComponent) formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.ADDITIONAL_CODE);
FieldComponent ordinalField = formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.ORDINAL);
LookupComponent batchLookup = (LookupComponent) formComponent.findFieldComponentByName(DeliveredProductMultiPositionFields.BATCH);
ordinalField.setFieldValue(ordinal);
ordinalField.requestComponentUpdateState();
ordinal = ordinal.add(BigInteger.ONE);
Entity product = productLookup.getEntity();
filterAdditionalCode(additionalCodeLookup, product);
filterBatch(batchLookup, product);
String unit = (String) unitField.getFieldValue();
String additionalUnit = (String) additionalUnitField.getFieldValue();
if (unit.equals(additionalUnit)) {
conversionField.setEnabled(false);
conversionField.requestComponentUpdateState();
}
boldRequired(formComponent);
}
FieldComponent palletNumber = (FieldComponent) view.getComponentByReference(DeliveredProductMultiFields.PALLET_NUMBER);
palletNumber.setRequired(true);
FieldComponent storageLocation = (FieldComponent) view.getComponentByReference(DeliveredProductMultiFields.STORAGE_LOCATION);
storageLocation.setRequired(true);
setStorageLocationFilter(view);
}
use of com.qcadoo.view.api.components.AwesomeDynamicListComponent in project mes by qcadoo.
the class PalletResourcesTransferHelperHooks method setStorageLocationFilters.
@Override
protected void setStorageLocationFilters(final ViewDefinitionState view) {
AwesomeDynamicListComponent adl = (AwesomeDynamicListComponent) view.getComponentByReference(L_PALLET_STORAGE_STATE_DTOS);
for (FormComponent form : adl.getFormComponents()) {
LookupComponent newPalletNumber = (LookupComponent) form.findFieldComponentByName("newPalletNumber");
FilterValueHolder filter = newPalletNumber.getFilterValue();
Entity persistedEntity = form.getPersistedEntityWithIncludedFormValues();
filter.put(LOCATION_NUMBER, persistedEntity.getStringField(LOCATION_NUMBER));
filter.put(PALLET_NUMBER, persistedEntity.getStringField(PALLET_NUMBER));
newPalletNumber.setFilterValue(filter);
}
}
Aggregations