Search in sources :

Example 6 with FieldComponent

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

the class WarehouseIssueDetailHooks method processProductsToIssueMode.

private void processProductsToIssueMode(final ViewDefinitionState view) {
    FieldComponent component = (FieldComponent) view.getComponentByReference(WarehouseIssueFields.PRODUCTS_TO_ISSUE_MODE);
    if (!warehouseIssueParameterService.issueForOrder()) {
        component.setVisible(false);
        component.requestComponentUpdateState();
        return;
    }
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (view.isViewAfterRedirect() && Objects.isNull(form.getEntityId())) {
        component.setFieldValue(warehouseIssueParameterService.getProductsToIssue().getStrValue());
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 7 with FieldComponent

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

the class ProductsToIssueDetailsListeners method onAdditionalDemandQuantityChange.

public void onAdditionalDemandQuantityChange(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
    if (!checkIfDecimalFieldsCorrect(productToIssue, form)) {
        return;
    }
    BigDecimal conversion = productToIssue.getDecimalField(ProductsToIssueFields.CONVERSION);
    BigDecimal additionalDemandQuantity = productToIssue.getDecimalField(ProductsToIssueFields.ADDITIONAL_DEMAND_QUANTITY);
    if (conversion != null && additionalDemandQuantity != null) {
        FieldComponent demandQuantity = (FieldComponent) view.getComponentByReference(ProductsToIssueFields.DEMAND_QUANTITY);
        Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
        BigDecimal newDemandQuantity = calculationQuantityService.calculateQuantity(additionalDemandQuantity, conversion, product.getStringField(ProductFields.UNIT));
        demandQuantity.setFieldValue(numberService.formatWithMinimumFractionDigits(newDemandQuantity, 0));
        demandQuantity.requestComponentUpdateState();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) BigDecimal(java.math.BigDecimal)

Example 8 with FieldComponent

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

the class TechnologiesParametersHooksPFTD method setDivisionField.

public void setDivisionField(final ViewDefinitionState view) {
    FieldComponent rangeField = (FieldComponent) view.getComponentByReference(ParameterFieldsPFTD.RANGE);
    LookupComponent divisionField = (LookupComponent) view.getComponentByReference(ParameterFieldsPFTD.DIVISION);
    String range = (String) rangeField.getFieldValue();
    boolean isOneDivision = Range.ONE_DIVISION.getStringValue().equals(range);
    boolean isManyDivisions = Range.MANY_DIVISIONS.getStringValue().equals(range);
    if (isManyDivisions) {
        divisionField.setFieldValue(null);
    }
    divisionField.setVisible(isOneDivision);
    divisionField.requestComponentUpdateState();
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 9 with FieldComponent

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

the class TechnologyDetailsHooksPFTD method showHideDivisionField.

public void showHideDivisionField(final ViewDefinitionState view) {
    FieldComponent rangeField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.RANGE);
    FieldComponent divisionField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.DIVISION);
    String range = (String) rangeField.getFieldValue();
    GridComponent rangeTechnologyOperationComponent = (GridComponent) view.getComponentByReference(RANGE_TECHNOLOGY_OPERATION_COMPONENT);
    ComponentState operationRangeDescriptionLabel = view.getComponentByReference(OPERATION_RANGE_DESCRIPTION);
    if (Range.ONE_DIVISION.getStringValue().equals(range)) {
        showField(divisionField, true);
        rangeTechnologyOperationComponent.setVisible(false);
        operationRangeDescriptionLabel.setVisible(false);
    } else {
        showField(divisionField, false);
        rangeTechnologyOperationComponent.setVisible(true);
        operationRangeDescriptionLabel.setVisible(true);
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) ComponentState(com.qcadoo.view.api.ComponentState)

Example 10 with FieldComponent

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

the class TechnologyDetailsHooksPFTD method fillRangeAndDivision.

private void fillRangeAndDivision(final ViewDefinitionState view) {
    FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent rangeField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPFTD.RANGE);
    LookupComponent divisionLookup = (LookupComponent) view.getComponentByReference(TechnologyFieldsPFTD.DIVISION);
    Long technologyId = technologyForm.getEntityId();
    if (Objects.isNull(technologyId) && view.isViewAfterRedirect()) {
        String range = parameterService.getParameter().getStringField(ParameterFieldsPFTD.RANGE);
        Entity division = parameterService.getParameter().getBelongsToField(ParameterFieldsPFTD.DIVISION);
        rangeField.setFieldValue(range);
        if (Objects.nonNull(division)) {
            divisionLookup.setFieldValue(division.getId());
            fillFieldsForOneDivisionRange(view);
        } else {
            divisionLookup.setFieldValue(null);
        }
    }
    rangeField.requestComponentUpdateState();
    divisionLookup.requestComponentUpdateState();
}
Also used : 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)

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