Search in sources :

Example 21 with FieldComponent

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

the class UsedBatchDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity usedBatch = form.getEntity();
    Entity trackingOperationProductInComponent = usedBatch.getBelongsToField(UsedBatchFields.TRACKING_OPERATION_PRODUCT_IN_COMPONENT);
    if (view.isViewAfterRedirect() && Objects.nonNull(trackingOperationProductInComponent)) {
        Entity product = trackingOperationProductInComponent.getBelongsToField(TrackingOperationProductInComponentFields.PRODUCT);
        FieldComponent unitField = (FieldComponent) view.getComponentByReference(L_UNIT);
        unitField.setFieldValue(product.getStringField(ProductFields.UNIT));
        unitField.requestComponentUpdateState();
        LookupComponent batchLookup = (LookupComponent) view.getComponentByReference(UsedBatchFields.BATCH);
        FilterValueHolder batchFilterValueHolder = batchLookup.getFilterValue();
        batchFilterValueHolder.put(L_PRODUCT_ID, product.getId());
        batchLookup.setFilterValue(batchFilterValueHolder);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 22 with FieldComponent

use of com.qcadoo.view.api.components.FieldComponent 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)

Example 23 with FieldComponent

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

the class FinalProductAnalysisGeneratorListeners 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_finalproductanalysisentry", dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_FINAL_PRODUCT_ANALYSIS_ENTRY));
        String multiFilterQ = GridComponentFilterSQLUtils.addMultiSearchFilter(multiSearchFilter, grid.getColumns(), "productioncounting_finalproductanalysisentry", dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_FINAL_PRODUCT_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)

Example 24 with FieldComponent

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

the class ProductionTrackingDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    setCriteriaModifierParameters(view);
    productionTrackingService.fillProductionLineLookup(view);
    if ((view.isViewAfterRedirect() || view.isViewAfterReload()) && !((CheckBoxComponent) view.getComponentByReference(ProductionTrackingFields.ADD_BATCH)).isChecked()) {
        FieldComponent batchNumber = (FieldComponent) view.getComponentByReference(ProductionTrackingFields.BATCH_NUMBER);
        batchNumber.setEnabled(false);
    }
    if (Objects.isNull(productionTrackingForm.getEntityId())) {
        setStateFieldValueToDraft(view);
    } else {
        Entity productionTracking = getProductionTrackingFromDB(productionTrackingForm.getEntityId());
        initializeProductionTrackingDetailsView(view);
        showLastStateChangeFailNotification(productionTrackingForm, productionTracking);
        changeFieldComponentsEnabledAndGridsEditable(view);
        updateRibbonState(view);
        toggleCorrectButton(view, productionTracking);
        toggleCorrectionFields(view, productionTracking);
        fetchNumberFromDatabase(view, productionTracking);
    }
    fillBatchOrderedProductLabel(view);
    changeStoppagesTabVisible(view);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 25 with FieldComponent

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

the class TechnologyDetailsHooksPC method setTechnologyDefaultValues.

public void setTechnologyDefaultValues(final ViewDefinitionState view) {
    FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent typeOfProductionRecordingField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
    if (Objects.nonNull(orderForm.getEntityId())) {
        return;
    }
    for (String fieldComponentName : L_TECHNOLOGY_FIELD_NAMES) {
        FieldComponent fieldComponent = (FieldComponent) view.getComponentByReference(fieldComponentName);
        if (Objects.isNull(fieldComponent.getFieldValue())) {
            fieldComponent.setFieldValue(getDefaultValueForProductionCountingFromParameter(fieldComponentName));
            fieldComponent.requestComponentUpdateState();
        }
        fieldComponent.setEnabled(false);
    }
    if (Objects.isNull(typeOfProductionRecordingField.getFieldValue())) {
        typeOfProductionRecordingField.setFieldValue(getDefaultValueForTypeOfProductionRecordingParameter(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING));
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Aggregations

FieldComponent (com.qcadoo.view.api.components.FieldComponent)443 Entity (com.qcadoo.model.api.Entity)201 FormComponent (com.qcadoo.view.api.components.FormComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)107 BigDecimal (java.math.BigDecimal)47 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)31 GridComponent (com.qcadoo.view.api.components.GridComponent)31 Date (java.util.Date)30 Optional (com.google.common.base.Optional)18 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)14 ComponentState (com.qcadoo.view.api.ComponentState)13 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)13 WindowComponent (com.qcadoo.view.api.components.WindowComponent)12 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)11 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)9 PossibleUnitConversions (com.qcadoo.model.api.units.PossibleUnitConversions)7 SimpleDateFormat (java.text.SimpleDateFormat)7 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)6 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)6 Collectors (java.util.stream.Collectors)6