Search in sources :

Example 36 with FormComponent

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);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 37 with FormComponent

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));
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) EntityList(com.qcadoo.model.api.EntityList)

Example 38 with FormComponent

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());
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 39 with FormComponent

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);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 40 with FormComponent

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();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Aggregations

FormComponent (com.qcadoo.view.api.components.FormComponent)644 Entity (com.qcadoo.model.api.Entity)501 FieldComponent (com.qcadoo.view.api.components.FieldComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)104 GridComponent (com.qcadoo.view.api.components.GridComponent)83 BigDecimal (java.math.BigDecimal)55 WindowComponent (com.qcadoo.view.api.components.WindowComponent)52 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)45 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)42 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)39 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)36 Date (java.util.Date)33 DataDefinition (com.qcadoo.model.api.DataDefinition)29 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)28 JSONObject (org.json.JSONObject)28 ComponentState (com.qcadoo.view.api.ComponentState)27 Transactional (org.springframework.transaction.annotation.Transactional)20 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)17 Optional (com.google.common.base.Optional)16 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)16