Search in sources :

Example 91 with LookupComponent

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

the class DeliveredProductAttributeValDetailsHooks method setFilters.

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

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

the class DeliveredProductAttributeValDetailsHooks method setValueBold.

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

Example 93 with LookupComponent

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

the class DeliveredProductDetailsHooks method fillConversion.

public void fillConversion(final ViewDefinitionState view) {
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(DeliveredProductFields.PRODUCT);
    Entity product = productLookup.getEntity();
    if (Objects.nonNull(product)) {
        String additionalUnit = product.getStringField(ProductFields.ADDITIONAL_UNIT);
        String unit = product.getStringField(ProductFields.UNIT);
        FieldComponent conversionField = (FieldComponent) view.getComponentByReference(DeliveredProductFields.CONVERSION);
        if (StringUtils.isEmpty(additionalUnit)) {
            conversionField.setFieldValue(BigDecimal.ONE);
            conversionField.setEnabled(false);
        } else {
            String conversion = numberService.formatWithMinimumFractionDigits(getConversion(product, unit, additionalUnit), 0);
            conversionField.setFieldValue(conversion);
            conversionField.setEnabled(true);
        }
        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 94 with LookupComponent

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

the class DeliveredProductDetailsHooks method setBatchLookupProductFilterValue.

public void setBatchLookupProductFilterValue(final ViewDefinitionState view, final Entity deliveredProduct) {
    LookupComponent batchLookup = (LookupComponent) view.getComponentByReference(DeliveredProductFields.BATCH);
    Entity product = deliveredProduct.getBelongsToField(DeliveredProductFields.PRODUCT);
    if (Objects.nonNull(product)) {
        batchCriteriaModifier.putProductFilterValue(batchLookup, product);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 95 with LookupComponent

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

the class DeliveredProductDetailsHooks method fillOrderedQuantities.

public void fillOrderedQuantities(final ViewDefinitionState view) {
    FormComponent deliveredProductForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(DeliveredProductFields.PRODUCT);
    FieldComponent orderedQuantity = (FieldComponent) view.getComponentByReference(OrderedProductFields.ORDERED_QUANTITY);
    Entity deliveredProduct = deliveredProductForm.getEntity();
    Entity product = productLookup.getEntity();
    if (Objects.isNull(product)) {
        orderedQuantity.setFieldValue(null);
    } else {
        orderedQuantity.setFieldValue(numberService.format(getOrderedProductQuantity(deliveredProduct)));
    }
    orderedQuantity.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)

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