Search in sources :

Example 86 with LookupComponent

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

the class OrderedProductDetailsHooks method fillConversion.

private void fillConversion(final ViewDefinitionState view) {
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(OrderedProductFields.PRODUCT);
    Entity product = productLookup.getEntity();
    if (Objects.nonNull(product)) {
        String additionalUnit = product.getStringField(ProductFields.ADDITIONAL_UNIT);
        FieldComponent conversionField = (FieldComponent) view.getComponentByReference(OrderedProductFields.CONVERSION);
        if (StringUtils.isEmpty(additionalUnit)) {
            conversionField.setFieldValue(BigDecimal.ONE);
            conversionField.setEnabled(false);
            conversionField.requestComponentUpdateState();
        }
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 87 with LookupComponent

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

the class DeliveredProductAttributeValDetailsListeners method onChangeAttributeValue.

public void onChangeAttributeValue(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ResourceAttributeValueFields.ATTRIBUTE_VALUE);
    FieldComponent valueField = (FieldComponent) view.getComponentByReference(ResourceAttributeValueFields.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)

Example 88 with LookupComponent

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

the class DeliveredProductDetailsListeners method onSelectedEntityChange.

public void onSelectedEntityChange(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(DeliveredProductFields.PRODUCT);
    Entity product = productLookup.getEntity();
    LookupComponent additionalCodeLookup = (LookupComponent) view.getComponentByReference(DeliveredProductFields.ADDITIONAL_CODE);
    LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(DeliveredProductFields.STORAGE_LOCATION);
    if (Objects.nonNull(product)) {
        filterByProduct(additionalCodeLookup, product.getId());
        filterByProduct(storageLocationLookup, product.getId());
    } else {
        clearAndDisable(additionalCodeLookup);
        clearAndDisable(storageLocationLookup);
    }
    fillConversion(view, state, args);
    quantityChange(view, state, args);
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 89 with LookupComponent

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

the class CompanyProductsDetailsHooks method onBeforeRenderForCompany.

public void onBeforeRenderForCompany(final ViewDefinitionState view) {
    LookupComponent productLookupComponent = (LookupComponent) view.getComponentByReference(CompanyProductFields.PRODUCT);
    FieldComponent unitField = (FieldComponent) view.getComponentByReference(L_UNIT);
    FieldComponent daysField = (FieldComponent) view.getComponentByReference(L_DAYS);
    daysField.setFieldValue(translationService.translate("deliveries.deliveryDetails.window.mainTab.deliveriesDetails.deliveryDateBufferDays.label", view.getLocale()));
    if (productLookupComponent.isEmpty()) {
        unitField.setFieldValue("");
    } else {
        Entity product = productLookupComponent.getEntity();
        if (Objects.nonNull(product)) {
            unitField.setFieldValue(product.getStringField(ProductFields.UNIT));
        }
    }
    unitField.requestComponentUpdateState();
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 90 with LookupComponent

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

the class DeliveredProductAddMultiHooks method setStorageLocationFilter.

private void setStorageLocationFilter(final ViewDefinitionState view) {
    FormComponent deliveredProductMultiForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity deliveredProductMultiEntity = deliveredProductMultiForm.getPersistedEntityWithIncludedFormValues();
    Entity delivery = deliveredProductMultiEntity.getBelongsToField(DeliveredProductMultiFields.DELIVERY);
    Entity location = delivery.getBelongsToField(DeliveryFields.LOCATION);
    if (Objects.nonNull(location)) {
        LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(DeliveredProductMultiFields.STORAGE_LOCATION);
        FilterValueHolder filterValueHolder = storageLocationLookup.getFilterValue();
        filterValueHolder.put(L_LOCATION, location.getId());
        storageLocationLookup.setFilterValue(filterValueHolder);
        storageLocationLookup.requestComponentUpdateState();
    }
}
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)

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