use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionBalanceDetailsListeners method addAllRelatedOrders.
public final void addAllRelatedOrders(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent ordersGrid = (GridComponent) view.getComponentByReference(ProductionBalanceFields.ORDERS);
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity balance = form.getPersistedEntityWithIncludedFormValues();
List<Entity> orders = Lists.newArrayList(balance.getHasManyField(ProductionBalanceFields.ORDERS));
for (Entity entity : ordersGrid.getSelectedEntities()) {
Entity root = entity.getBelongsToField("root");
if (root == null) {
root = entity;
}
orders.add(root);
List<Entity> children = entity.getDataDefinition().find().add(SearchRestrictions.belongsTo("root", OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER, root.getId())).list().getEntities();
orders.addAll(children);
}
balance.setField(ProductionBalanceFields.ORDERS, orders);
balance = balance.getDataDefinition().save(balance);
form.setEntity(balance);
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionTrackingDetailsListeners method copyPlannedQuantityToUsedQuantity.
public void copyPlannedQuantityToUsedQuantity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent productionRecordForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long productionRecordId = productionRecordForm.getEntityId();
if (Objects.isNull(productionRecordId)) {
return;
}
Entity productionRecord = productionRecordForm.getEntity().getDataDefinition().get(productionRecordId);
EntityList trackingOperationProductInComponents = productionRecord.getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS);
clearWasteUsedDetails(trackingOperationProductInComponents);
copyPlannedQuantityToUsedQuantity(trackingOperationProductInComponents);
copyPlannedQuantityToUsedQuantity(productionRecord.getHasManyField(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_OUT_COMPONENTS));
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionTrackingDetailsListeners method clearFields.
public void clearFields(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
FieldComponent technologyOperationComponentField = (FieldComponent) view.getComponentByReference(ProductionTrackingFields.TECHNOLOGY_OPERATION_COMPONENT);
technologyOperationComponentField.setFieldValue("");
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (Objects.isNull(form.getEntityId())) {
return;
}
GridComponent trackingOperationProductInComponentsGrid = (GridComponent) view.getComponentByReference(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS);
GridComponent trackingOperationProductOutComponentsGrid = (GridComponent) view.getComponentByReference(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_OUT_COMPONENTS);
trackingOperationProductInComponentsGrid.setEntities(Lists.newArrayList());
trackingOperationProductOutComponentsGrid.setEntities(Lists.newArrayList());
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class ProductionTrackingDetailsListeners method addToAnomaliesList.
public void addToAnomaliesList(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent trackingOperationProductInComponentsGrid = (GridComponent) view.getComponentByReference(ProductionTrackingFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENTS);
if (!trackingOperationProductInComponentsGrid.getSelectedEntitiesIds().isEmpty()) {
FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long productionTrackingId = productionTrackingForm.getEntityId();
Map<String, Object> parameters = Maps.newHashMap();
parameters.put("form.productionTrackingId", productionTrackingId);
parameters.put("form.selectedTOPICs", trackingOperationProductInComponentsGrid.getSelectedEntitiesIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
parameters.put("form.performAndAccept", Boolean.FALSE);
String url = "/productionCounting/anomalyProductionTrackingDetails.html";
view.openModal(url, parameters);
}
}
use of com.qcadoo.view.api.components.FormComponent in project mes by qcadoo.
the class AnomalyDetailsHooks method fillFields.
private void fillFields(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity anomaly = form.getEntity().getDataDefinition().get(form.getEntityId());
FieldComponent productionTrackingNumberField = (FieldComponent) view.getComponentByReference("productionTrackingNumber");
FieldComponent createDateField = (FieldComponent) view.getComponentByReference("createDate");
createDateField.setEnabled(false);
FieldComponent orderNumberField = (FieldComponent) view.getComponentByReference("orderNumber");
FieldComponent masterProductNumberField = (FieldComponent) view.getComponentByReference("masterProductNumber");
FieldComponent productionLineNumberField = (FieldComponent) view.getComponentByReference("productionLineNumber");
FieldComponent productNumberField = (FieldComponent) view.getComponentByReference("productNumber");
FieldComponent reasonsField = (FieldComponent) view.getComponentByReference("reasons");
FieldComponent unitField = (FieldComponent) view.getComponentByReference("unit");
FieldComponent locationField = (FieldComponent) view.getComponentByReference("location");
Entity productionTracking = anomaly.getBelongsToField("productionTracking");
productionTrackingNumberField.setFieldValue(productionTracking.getStringField(ProductionTrackingFields.NUMBER));
orderNumberField.setFieldValue(productionTracking.getBelongsToField(ProductionTrackingFields.ORDER).getStringField(OrderFields.NUMBER));
productionLineNumberField.setFieldValue(productionTracking.getBelongsToField(ProductionTrackingFields.ORDER).getBelongsToField(OrderFields.PRODUCTION_LINE).getStringField(ProductionLineFields.NUMBER));
masterProductNumberField.setFieldValue(anomaly.getBelongsToField("masterProduct").getStringField(ProductFields.NUMBER));
productNumberField.setFieldValue(anomaly.getBelongsToField("product").getStringField(ProductFields.NUMBER));
unitField.setFieldValue(anomaly.getBelongsToField("product").getStringField(ProductFields.UNIT));
reasonsField.setFieldValue(anomaly.getHasManyField("anomalyReasons").stream().map(a -> a.getStringField("name")).collect(Collectors.joining(", ")));
if (Objects.nonNull(anomaly.getBelongsToField(AnomalyFields.LOCATION))) {
locationField.setFieldValue(anomaly.getBelongsToField(AnomalyFields.LOCATION).getStringField("number"));
locationField.requestComponentUpdateState();
}
if (anomaly.getStringField(AnomalyFields.STATE).equals("03completed")) {
view.getComponentByReference("anomalyExplanations").setEnabled(false);
}
productionTrackingNumberField.requestComponentUpdateState();
orderNumberField.requestComponentUpdateState();
productionLineNumberField.requestComponentUpdateState();
masterProductNumberField.requestComponentUpdateState();
productNumberField.requestComponentUpdateState();
unitField.requestComponentUpdateState();
reasonsField.requestComponentUpdateState();
}
Aggregations