Search in sources :

Example 86 with FieldComponent

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

the class StaffService method setOwnerCompany.

public void setOwnerCompany(final ViewDefinitionState view) {
    FormComponent staffForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent workForLookup = (FieldComponent) view.getComponentByReference(StaffFields.WORK_FOR);
    Entity ownerCompany = companyService.getCompany();
    if ((staffForm.getEntityId() != null) || (workForLookup.getFieldValue() != null) || (ownerCompany == null)) {
        return;
    }
    workForLookup.setFieldValue(ownerCompany.getId());
    workForLookup.requestComponentUpdateState();
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 87 with FieldComponent

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

the class ProductAttributeValueDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    setValueBold(view);
    setFilters(view);
    LookupComponent attributeLookup = (LookupComponent) view.getComponentByReference(ProductAttributeValueFields.ATTRIBUTE);
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductAttributeValueFields.ATTRIBUTE_VALUE);
    FieldComponent valueField = (FieldComponent) view.getComponentByReference(ProductAttributeValueFields.VALUE);
    if (Objects.nonNull(attributeLookup.getEntity())) {
        Entity attribute = attributeLookup.getEntity();
        FieldComponent unitField = (FieldComponent) view.getComponentByReference(L_UNIT);
        unitField.setFieldValue(attribute.getStringField(AttributeFields.UNIT));
        unitField.requestComponentUpdateState();
        if (AttributeDataType.CONTINUOUS.getStringValue().equals(attribute.getStringField(AttributeFields.DATA_TYPE))) {
            valueField.setVisible(true);
            attributeValueLookup.setVisible(false);
        } else {
            valueField.setVisible(false);
            attributeValueLookup.setVisible(true);
        }
    } else {
        valueField.setVisible(false);
        attributeValueLookup.setVisible(false);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 88 with FieldComponent

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

the class ProductDetailsHooks method disableProductFormForExternalItems.

public void disableProductFormForExternalItems(final ViewDefinitionState view) {
    FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent entityTypeField = (FieldComponent) view.getComponentByReference(ProductFields.ENTITY_TYPE);
    FieldComponent parentField = (FieldComponent) view.getComponentByReference(ProductFields.PARENT);
    FieldComponent categoryField = (FieldComponent) view.getComponentByReference(ProductFields.CATEGORY);
    LookupComponent supplierLookup = (LookupComponent) view.getComponentByReference(ProductFields.SUPPLIER);
    LookupComponent assortmentLookup = (LookupComponent) view.getComponentByReference(ProductFields.ASSORTMENT);
    LookupComponent modelLookup = (LookupComponent) view.getComponentByReference(ProductFields.MODEL);
    Long productId = productForm.getEntityId();
    if (Objects.isNull(productId)) {
        productForm.setFormEnabled(true);
        return;
    }
    Entity product = getProductDD().get(productId);
    if (Objects.isNull(product)) {
        return;
    }
    String externalNumber = product.getStringField(ProductFields.EXTERNAL_NUMBER);
    if (StringUtils.isEmpty(externalNumber)) {
        productForm.setFormEnabled(true);
    } else {
        productForm.setFormEnabled(false);
        entityTypeField.setEnabled(true);
        parentField.setEnabled(true);
        categoryField.setEnabled(true);
        supplierLookup.setEnabled(true);
        assortmentLookup.setEnabled(true);
        modelLookup.setEnabled(true);
    }
}
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 89 with FieldComponent

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

the class ProductDetailsHooks method fillUnit.

public void fillUnit(final ViewDefinitionState view) {
    FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent unitField = (FieldComponent) view.getComponentByReference(UNIT);
    if (Objects.isNull(productForm.getEntityId()) && Objects.isNull(unitField.getFieldValue())) {
        unitField.setFieldValue(unitService.getDefaultUnitFromSystemParameters());
        unitField.requestComponentUpdateState();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 90 with FieldComponent

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

the class ProductDetailsHooks method disableUnitFromWhenFormIsSaved.

public void disableUnitFromWhenFormIsSaved(final ViewDefinitionState view) {
    FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    AwesomeDynamicListComponent conversionItemsAdl = (AwesomeDynamicListComponent) view.getComponentByReference(CONVERSION_ITEMS);
    conversionItemsAdl.setEnabled(Objects.nonNull(productForm.getEntityId()));
    for (FormComponent formComponent : conversionItemsAdl.getFormComponents()) {
        formComponent.findFieldComponentByName(UNIT_FROM).setEnabled(Objects.isNull(formComponent.getEntityId()));
    }
    FieldComponent additionalUnit = (FieldComponent) view.getComponentByReference(ProductFields.ADDITIONAL_UNIT);
    additionalUnit.setEnabled(Objects.nonNull(productForm.getEntityId()));
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

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