Search in sources :

Example 6 with LookupComponent

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

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

Example 8 with LookupComponent

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

the class TechnologyProductionLineDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent productionLineLookup = (LookupComponent) view.getComponentByReference(TechnologyProductionLineFields.PRODUCTION_LINE);
    Entity entity = form.getEntity();
    Entity technology = entity.getBelongsToField(TechnologyProductionLineFields.TECHNOLOGY);
    Entity division = technology.getBelongsToField(TechnologyFieldsPFTD.DIVISION);
    FilterValueHolder filterValueHolder = productionLineLookup.getFilterValue();
    Long technologyId = technology.getId();
    if (Objects.isNull(technologyId)) {
        filterValueHolder.remove(TechnologyProductionLineCriteriaModifiers.L_TECHNOLOGY_ID);
    } else {
        filterValueHolder.put(TechnologyProductionLineCriteriaModifiers.L_TECHNOLOGY_ID, technologyId);
    }
    if (Objects.nonNull(division)) {
        filterValueHolder.put(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID, division.getId());
    } else if (filterValueHolder.has(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID)) {
        filterValueHolder.remove(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID);
    }
    productionLineLookup.setFilterValue(filterValueHolder);
}
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)

Example 9 with LookupComponent

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

the class IssueCommonDetailsHelper method setFilterValue.

public void setFilterValue(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
    Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
    Entity warehouse = productToIssue.getBelongsToField(ProductsToIssueFields.LOCATION);
    LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(IssueCommonDetailsHelper.STORAGE_LOCATION);
    FilterValueHolder filter = storageLocationLookup.getFilterValue();
    LookupComponent additionalCodeLookup = (LookupComponent) view.getComponentByReference(ADDITIONAL_CODE);
    FilterValueHolder additionalCodeFilter = additionalCodeLookup.getFilterValue();
    if (product != null) {
        filter.put(PRODUCT, product.getId());
        additionalCodeFilter.put(PRODUCT, product.getId());
    } else if (filter.has(PRODUCT)) {
        filter.remove(PRODUCT);
        additionalCodeFilter.remove(PRODUCT);
    }
    if (warehouse != null) {
        filter.remove(LOCATION);
        filter.put(LOCATION, warehouse.getId());
    }
    storageLocationLookup.setFilterValue(filter);
    additionalCodeLookup.setFilterValue(additionalCodeFilter);
}
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)

Example 10 with LookupComponent

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

the class IssueCommonDetailsHelper method fillStorageLocation.

public void fillStorageLocation(ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity productToIssue = form.getPersistedEntityWithIncludedFormValues();
    Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
    Entity warehouse = productToIssue.getBelongsToField(ProductsToIssueFields.LOCATION);
    Entity storageLocation = productToIssue.getBelongsToField(ProductsToIssueFields.STORAGE_LOCATION);
    if (product != null && warehouse != null && storageLocation == null) {
        Optional<Entity> option = findStorageLocationForProduct(product, warehouse);
        if (option.isPresent()) {
            LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(IssueCommonDetailsHelper.STORAGE_LOCATION);
            storageLocationLookup.setFieldValue(option.get().getId());
            storageLocationLookup.requestComponentUpdateState();
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Aggregations

LookupComponent (com.qcadoo.view.api.components.LookupComponent)277 Entity (com.qcadoo.model.api.Entity)182 FieldComponent (com.qcadoo.view.api.components.FieldComponent)105 FormComponent (com.qcadoo.view.api.components.FormComponent)102 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)69 BigDecimal (java.math.BigDecimal)16 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)12 GridComponent (com.qcadoo.view.api.components.GridComponent)11 WindowComponent (com.qcadoo.view.api.components.WindowComponent)8 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)7 Date (java.util.Date)6 JSONObject (org.json.JSONObject)6 ComponentState (com.qcadoo.view.api.ComponentState)5 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)5 JSONException (org.json.JSONException)5 DataDefinition (com.qcadoo.model.api.DataDefinition)3 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)3 Optional (com.google.common.base.Optional)2 ProductFields (com.qcadoo.mes.basic.constants.ProductFields)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2