Search in sources :

Example 11 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class OrderWithMaterialAvailabilityListListeners method showReplacementsAvailability.

public void showReplacementsAvailability(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Entity record = grid.getSelectedEntities().get(0);
    Entity oma = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MATERIAL_AVAILABILITY).get(record.getId());
    Long productId = oma.getBelongsToField(MaterialAvailabilityFields.PRODUCT).getId();
    JSONObject json = new JSONObject();
    try {
        json.put("product.id", productId);
    } catch (JSONException e) {
        throw new IllegalStateException(e);
    }
    String url = "/page/productFlowThruDivision/materialReplacementsAvailabilityList.html?context=" + json.toString();
    view.redirectTo(url, false, true);
}
Also used : Entity(com.qcadoo.model.api.Entity) JSONObject(org.json.JSONObject) GridComponent(com.qcadoo.view.api.components.GridComponent) JSONException(org.json.JSONException)

Example 12 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class OrdersPlanningListListenersPFTD method showMaterialAvailabilityForOrders.

public void showMaterialAvailabilityForOrders(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Map<String, Object> parameters = Maps.newHashMap();
    parameters.put("ordersIds", grid.getSelectedEntitiesIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
    String url = "/page/productFlowThruDivision/ordersWithMaterialAvailabilityList.html";
    view.redirectTo(url, false, true, parameters);
}
Also used : GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 13 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class AnomalyExplanationDetailsListeners method onRemoveSelectedEntity.

public void onRemoveSelectedEntity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent anomalyExplanationsGrid = (GridComponent) view.getComponentByReference("anomalyExplanations");
    DataDefinition dataDefinition = dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_ANOMALY_EXPLANATION);
    dataDefinition.delete(toArray(anomalyExplanationsGrid.getSelectedEntitiesIds(), Long.class));
    FormComponent documentForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    documentForm.performEvent(view, "reset");
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 14 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class AnomalyListListeners method completeWithoutIssue.

public void completeWithoutIssue(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent gridComponent = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    for (Long anomalyId : gridComponent.getSelectedEntitiesIds()) {
        DataDefinition anomalyDD = getAnomalyDD();
        Entity anomaly = anomalyDD.get(anomalyId);
        anomaly.setField(AnomalyFields.STATE, AnomalyFields.State.COMPLETED);
        anomaly.setField(AnomalyFields.ISSUED, false);
        anomalyDD.save(anomaly);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 15 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class BeforeAdditionalActionsAnalysisGeneratorListeners method calculateTotalQuantity.

public void calculateTotalQuantity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    String query = buildQuery();
    Map<String, String> filter = grid.getFilters();
    GridComponentMultiSearchFilter multiSearchFilter = grid.getMultiSearchFilter();
    String filterQ;
    try {
        filterQ = GridComponentFilterSQLUtils.addFilters(filter, grid.getColumns(), "productioncounting_beforeadditionalactionsanalysisentry", dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_BEFORE_ADDITIONAL_ACTIONS_ANALYSIS_ENTRY));
        String multiFilterQ = GridComponentFilterSQLUtils.addMultiSearchFilter(multiSearchFilter, grid.getColumns(), "productioncounting_beforeadditionalactionsanalysisentry", dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_BEFORE_ADDITIONAL_ACTIONS_ANALYSIS_ENTRY));
        if (!Strings.isNullOrEmpty(multiFilterQ)) {
            if (!Strings.isNullOrEmpty(filterQ))
                filterQ += " AND ";
            filterQ += multiFilterQ;
        }
    } catch (Exception e) {
        filterQ = "";
    }
    if (!Strings.isNullOrEmpty(filterQ)) {
        query = query + " WHERE " + filterQ;
    }
    Map<String, Object> values = jdbcTemplate.queryForMap(query, Collections.emptyMap());
    FieldComponent totalQuantity = (FieldComponent) view.getComponentByReference("totalQuantity");
    totalQuantity.setFieldValue(numberService.format(values.get("totalDoneQuantity")));
    totalQuantity.requestComponentUpdateState();
}
Also used : GridComponentMultiSearchFilter(com.qcadoo.view.api.components.grid.GridComponentMultiSearchFilter) GridComponent(com.qcadoo.view.api.components.GridComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Aggregations

GridComponent (com.qcadoo.view.api.components.GridComponent)260 Entity (com.qcadoo.model.api.Entity)131 FormComponent (com.qcadoo.view.api.components.FormComponent)85 FieldComponent (com.qcadoo.view.api.components.FieldComponent)33 WindowComponent (com.qcadoo.view.api.components.WindowComponent)30 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)29 JSONObject (org.json.JSONObject)28 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)26 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)24 ComponentState (com.qcadoo.view.api.ComponentState)23 DataDefinition (com.qcadoo.model.api.DataDefinition)22 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)22 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)20 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)19 Autowired (org.springframework.beans.factory.annotation.Autowired)19 BigDecimal (java.math.BigDecimal)16 Service (org.springframework.stereotype.Service)16 LookupComponent (com.qcadoo.view.api.components.LookupComponent)15 Collectors (java.util.stream.Collectors)15 Lists (com.google.common.collect.Lists)12