Search in sources :

Example 21 with GridComponent

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

the class PerformanceAnalysisListeners method showDetails.

public void showDetails(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent performanceAnalysisGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Entity analysis = performanceAnalysisGrid.getSelectedEntities().get(0);
    Map<String, String> filters = Maps.newHashMap();
    filters.put(PerformanceAnalysisDetailsDtoFields.PRODUCTION_LINE_NUMBER, "[" + analysis.getStringField(PerformanceAnalysisDetailsDtoFields.PRODUCTION_LINE_NUMBER) + "]");
    String staffName = analysis.getStringField(PerformanceAnalysisDetailsDtoFields.STAFF_NAME);
    if (!Objects.isNull(staffName)) {
        filters.put(PerformanceAnalysisDetailsDtoFields.STAFF_NAME, "[" + staffName + "]");
    } else {
        filters.put(PerformanceAnalysisDetailsDtoFields.STAFF_NAME, ISNULL);
    }
    String shiftName = analysis.getStringField(PerformanceAnalysisDetailsDtoFields.SHIFT_NAME);
    if (!Objects.isNull(shiftName)) {
        filters.put(PerformanceAnalysisDetailsDtoFields.SHIFT_NAME, "[" + shiftName + "]");
    } else {
        filters.put(PerformanceAnalysisDetailsDtoFields.SHIFT_NAME, ISNULL);
    }
    Date timeRangeFrom = analysis.getDateField(PerformanceAnalysisDetailsDtoFields.TIME_RANGE_FROM);
    if (!Objects.isNull(timeRangeFrom)) {
        filters.put(PerformanceAnalysisDetailsDtoFields.TIME_RANGE_FROM, DateUtils.toDateString(timeRangeFrom));
    } else {
        filters.put(PerformanceAnalysisDetailsDtoFields.TIME_RANGE_FROM, ISNULL);
    }
    Date timeRangeTo = analysis.getDateField(PerformanceAnalysisDetailsDtoFields.TIME_RANGE_TO);
    if (!Objects.isNull(timeRangeTo)) {
        filters.put(PerformanceAnalysisDetailsDtoFields.TIME_RANGE_TO, DateUtils.toDateString(timeRangeTo));
    } else {
        filters.put(PerformanceAnalysisDetailsDtoFields.TIME_RANGE_TO, ISNULL);
    }
    Map<String, Object> gridOptions = Maps.newHashMap();
    gridOptions.put(L_FILTERS, filters);
    Map<String, Object> parameters = Maps.newHashMap();
    parameters.put(L_GRID_OPTIONS, gridOptions);
    parameters.put(L_WINDOW_ACTIVE_MENU, "analysis.performanceAnalysis");
    String url = "../page/productionCounting/performanceAnalysisDetails.html";
    view.redirectTo(url, false, true, parameters);
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) Date(java.util.Date)

Example 22 with GridComponent

use of com.qcadoo.view.api.components.GridComponent 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 23 with GridComponent

use of com.qcadoo.view.api.components.GridComponent 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 24 with GridComponent

use of com.qcadoo.view.api.components.GridComponent 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 25 with GridComponent

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

the class DivisionDetailsHooksPL method fillCriteriaModifiers.

public void fillCriteriaModifiers(final ViewDefinitionState viewDefinitionState) {
    GridComponent workstations = (GridComponent) viewDefinitionState.getComponentByReference("workstations");
    FormComponent form = (FormComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_FORM);
    if (form.getEntityId() != null) {
        FilterValueHolder filter = workstations.getFilterValue();
        filter.put("division", form.getEntityId());
        workstations.setFilterValue(filter);
    }
    workstations.reloadEntities();
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

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