Search in sources :

Example 81 with LookupComponent

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

the class OrderedProductDetailsListeners method clearAdditionalCode.

private void clearAdditionalCode(final ViewDefinitionState view) {
    LookupComponent additionalCodeLookup = (LookupComponent) view.getComponentByReference(OrderedProductFields.ADDITIONAL_CODE);
    additionalCodeLookup.setFieldValue(null);
    additionalCodeLookup.requestComponentUpdateState();
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 82 with LookupComponent

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

the class OrderedProductDetailsListeners method fillAdditionalUnit.

private void fillAdditionalUnit(final ViewDefinitionState view) {
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(OrderedProductFields.PRODUCT);
    Entity product = productLookup.getEntity();
    if (Objects.nonNull(product)) {
        String unit = product.getStringField(ProductFields.UNIT);
        String additionalUnit = product.getStringField(ProductFields.ADDITIONAL_UNIT);
        FieldComponent conversionField = (FieldComponent) view.getComponentByReference(OrderedProductFields.CONVERSION);
        if (!StringUtils.isEmpty(additionalUnit)) {
            String conversion = numberService.formatWithMinimumFractionDigits(getConversion(product, unit, additionalUnit), 0);
            conversionField.setFieldValue(conversion);
            conversionField.setEnabled(true);
            conversionField.requestComponentUpdateState();
        }
        quantityChange(view, null, null);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 83 with LookupComponent

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

the class DeliveryDetailsHooks method fillLocationDefaultValue.

private void fillLocationDefaultValue(final ViewDefinitionState view) {
    FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (Objects.nonNull(deliveryForm.getEntityId())) {
        return;
    }
    LookupComponent locationField = (LookupComponent) view.getComponentByReference(DeliveryFields.LOCATION);
    Entity location = locationField.getEntity();
    if (Objects.isNull(location) && !view.isViewAfterReload()) {
        Entity defaultLocation = parameterService.getParameter().getBelongsToField(DeliveryFields.LOCATION);
        if (Objects.isNull(defaultLocation)) {
            locationField.setFieldValue(null);
        } else {
            locationField.setFieldValue(defaultLocation.getId());
        }
        locationField.requestComponentUpdateState();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 84 with LookupComponent

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

the class DeliveryDetailsHooks method fillCurrencyFields.

private void fillCurrencyFields(final ViewDefinitionState view) {
    FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    List<String> referenceNames = Lists.newArrayList("deliveredProductsCumulatedTotalPriceCurrency", "orderedProductsCumulatedTotalPriceCurrency");
    Entity delivery = deliveryForm.getEntity();
    deliveriesService.fillCurrencyFieldsForDelivery(view, referenceNames, delivery);
    LookupComponent currencyLookup = (LookupComponent) view.getComponentByReference(DeliveryFields.CURRENCY);
    if (Objects.isNull(currencyLookup.getFieldValue()) && Objects.isNull(deliveryForm.getEntityId())) {
        Entity currencyEntity = currencyService.getCurrentCurrency();
        currencyLookup.setFieldValue(currencyEntity.getId());
        currencyLookup.requestComponentUpdateState();
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 85 with LookupComponent

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

the class DeliveryDetailsHooks method changeLocationEnabledDependOnState.

private void changeLocationEnabledDependOnState(final ViewDefinitionState view) {
    FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent locationField = (LookupComponent) view.getComponentByReference(DeliveryFields.LOCATION);
    if (Objects.isNull(deliveryForm.getEntityId())) {
        locationField.setEnabled(true);
    } else {
        FieldComponent stateField = (FieldComponent) view.getComponentByReference(DeliveryFields.STATE);
        String state = stateField.getFieldValue().toString();
        locationField.setEnabled(!DeliveryState.DECLINED.getStringValue().equals(state) && !DeliveryState.RECEIVED.getStringValue().equals(state) && !DeliveryState.RECEIVE_CONFIRM_WAITING.getStringValue().equals(state));
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) 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