Search in sources :

Example 61 with LookupComponent

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

the class ProductDetailsHooks method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(final ViewDefinitionState view) {
    LookupComponent assortmentLookup = (LookupComponent) view.getComponentByReference(ProductFields.ASSORTMENT);
    LookupComponent modelLookup = (LookupComponent) view.getComponentByReference(ProductFields.MODEL);
    Entity assortment = assortmentLookup.getEntity();
    FilterValueHolder filterValueHolder = modelLookup.getFilterValue();
    if (Objects.isNull(assortment)) {
        if (filterValueHolder.has(ModelCriteriaModifiers.L_ASSORTMENT_ID)) {
            filterValueHolder.remove(ModelCriteriaModifiers.L_ASSORTMENT_ID);
        }
    } else {
        filterValueHolder.put(ModelCriteriaModifiers.L_ASSORTMENT_ID, assortment.getId());
    }
    modelLookup.setFilterValue(filterValueHolder);
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 62 with LookupComponent

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

the class SkillStaffDetails method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity opSkill = form.getEntity();
    FieldComponent maxSkillLevelField = (FieldComponent) view.getComponentByReference(MAX_LEVEL);
    maxSkillLevelField.setFieldValue(opSkill.getBelongsToField(StaffSkillsFields.SKILL).getIntegerField(SkillFields.MAXIMUM_LEVEL));
    LookupComponent staffLookup = (LookupComponent) view.getComponentByReference(StaffSkillsFields.STAFF);
    FilterValueHolder filterValueHolder = staffLookup.getFilterValue();
    Long skillId = opSkill.getBelongsToField(StaffSkillsFields.SKILL).getId();
    if (Objects.isNull(skillId)) {
        filterValueHolder.remove(L_SKILL_ID);
    } else {
        filterValueHolder.put(L_SKILL_ID, skillId);
    }
    staffLookup.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) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 63 with LookupComponent

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

the class UserDetailsHooksB method setFieldsEnabledForAdmin.

public void setFieldsEnabledForAdmin(final ViewDefinitionState view) {
    if (securityService.hasCurrentUserRole("ROLE_ADMIN")) {
        Stream.of(UserFields.STAFF, UserFields.FACTORY).forEach(fieldName -> {
            LookupComponent lookupComponent = (LookupComponent) view.getComponentByReference(fieldName);
            if (Objects.nonNull(lookupComponent)) {
                lookupComponent.setEnabled(true);
                lookupComponent.requestComponentUpdateState();
            }
        });
    }
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 64 with LookupComponent

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

the class ParametersHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent parametersForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent companyLookup = (LookupComponent) view.getComponentByReference(ParameterFields.COMPANY);
    boolean isSaved = (parametersForm.getEntityId() != null);
    boolean isCompany = (companyLookup.getEntity() != null);
    changeButtonsState(view, isSaved && isCompany);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 65 with LookupComponent

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

the class ProductAttributeValueDetailsHooks method setFilters.

private void setFilters(ViewDefinitionState view) {
    LookupComponent attributeLookup = (LookupComponent) view.getComponentByReference(ProductAttributeValueFields.ATTRIBUTE);
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductAttributeValueFields.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)

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