Search in sources :

Example 66 with LookupComponent

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

the class ProductAttributeValueDetailsHooks method setValueBold.

private void setValueBold(ViewDefinitionState view) {
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductAttributeValueFields.ATTRIBUTE_VALUE);
    attributeValueLookup.setRequired(true);
    attributeValueLookup.requestComponentUpdateState();
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 67 with LookupComponent

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

the class BaseAttributeValueDetailsHooks method setFilters.

private void setFilters(ViewDefinitionState view) {
    LookupComponent attributeLookup = (LookupComponent) view.getComponentByReference(ATTRIBUTE);
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ATTRIBUTE_VALUE);
    FilterValueHolder attributeValueLookupFilters = attributeValueLookup.getFilterValue();
    if (Objects.nonNull(attributeLookup.getEntity())) {
        attributeValueLookupFilters.put(L_ATTRIBUTE_ID, attributeLookup.getEntity().getId());
    } else if (attributeValueLookupFilters.has(L_ATTRIBUTE_ID)) {
        attributeValueLookupFilters.remove(L_ATTRIBUTE_ID);
    }
    attributeValueLookup.setFilterValue(attributeValueLookupFilters);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 68 with LookupComponent

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

the class CompanyDetailsHooks method fillDefaultCountry.

public void fillDefaultCountry(final ViewDefinitionState view) {
    FormComponent companyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (companyForm.getEntityId() != null) {
        return;
    }
    CheckBoxComponent isSetFieldsFromParameter = (CheckBoxComponent) view.getComponentByReference(CompanyFields.IS_SET_FIELDS_FROM_PARAMETER);
    if (isSetFieldsFromParameter.isChecked()) {
        return;
    }
    LookupComponent countryField = (LookupComponent) view.getComponentByReference(CompanyFields.COUNTRY);
    LookupComponent taxCountryField = (LookupComponent) view.getComponentByReference(CompanyFields.TAX_COUNTRY_CODE);
    Entity defaultCountry = parameterService.getParameter().getBelongsToField(CompanyFields.COUNTRY);
    if (defaultCountry != null) {
        countryField.setFieldValue(defaultCountry.getId());
        taxCountryField.setFieldValue(defaultCountry.getId());
        taxCountryField.requestComponentUpdateState();
        countryField.requestComponentUpdateState();
    }
    isSetFieldsFromParameter.setFieldValue(true);
    isSetFieldsFromParameter.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 69 with LookupComponent

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

the class ModelDetailsHooks method fillCriteriaModifiers.

private void fillCriteriaModifiers(final ViewDefinitionState view) {
    FormComponent modelForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent assortmentLookup = (LookupComponent) view.getComponentByReference(ModelFields.ASSORTMENT);
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference("productLookup");
    Long modelId = modelForm.getEntityId();
    Entity assortment = assortmentLookup.getEntity();
    FilterValueHolder filterValueHolder = productLookup.getFilterValue();
    if (Objects.nonNull(modelId)) {
        filterValueHolder.put(ProductCriteriaModifiers.L_MODEL_ID, modelId);
    }
    if (Objects.isNull(assortment)) {
        if (filterValueHolder.has(ProductCriteriaModifiers.L_ASSORTMENT_ID)) {
            filterValueHolder.remove(ProductCriteriaModifiers.L_ASSORTMENT_ID);
        }
    } else {
        filterValueHolder.put(ProductCriteriaModifiers.L_ASSORTMENT_ID, assortment.getId());
    }
    productLookup.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 70 with LookupComponent

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

the class ProductAttributeValueDetailsListeners method onChangeAttributeValue.

public void onChangeAttributeValue(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductAttributeValueFields.ATTRIBUTE_VALUE);
    FieldComponent valueField = (FieldComponent) view.getComponentByReference(ProductAttributeValueFields.VALUE);
    if (Objects.nonNull(attributeValueLookup.getEntity())) {
        valueField.setFieldValue(attributeValueLookup.getEntity().getStringField(AttributeValueFields.VALUE));
        valueField.requestComponentUpdateState();
    }
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

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