Search in sources :

Example 81 with FieldComponent

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

the class ProductionCountingQuantityAdvancedDetailsHooks method hideTab.

private void hideTab(ViewDefinitionState view) {
    ComponentState attributesTab = view.getComponentByReference(ATTRIBUTES);
    ComponentState batchesTab = view.getComponentByReference(L_BATCHES_TAB);
    FieldComponent roleField = (FieldComponent) view.getComponentByReference(ProductionCountingQuantityFields.ROLE);
    FieldComponent materialField = (FieldComponent) view.getComponentByReference(ProductionCountingQuantityFields.TYPE_OF_MATERIAL);
    boolean isProduced = checkIfIsProduced((String) roleField.getFieldValue());
    boolean isUsedMaterial = checkIfIsUsed((String) roleField.getFieldValue()) && checkIfIsComponent((String) materialField.getFieldValue());
    attributesTab.setVisible(isProduced);
    batchesTab.setVisible(isUsedMaterial);
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) ComponentState(com.qcadoo.view.api.ComponentState)

Example 82 with FieldComponent

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

the class ProductionCountingQuantityAdvancedDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    setCriteriaModifierParameters(view);
    disableFieldsDependsOfState(view);
    hideFieldsDependsOfState(view);
    fillProductField(view);
    fillUnitFields(view);
    setTechnologyOperationComponentFieldRequired(view);
    fillBatchLookupFilter(view);
    hideTab(view);
    FormComponent productionCountingQuantityForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (productionCountingQuantityForm.getEntityId() != null) {
        Entity productionCountingQuantityDto = dataDefinitionService.get(BasicProductionCountingConstants.PLUGIN_IDENTIFIER, BasicProductionCountingConstants.MODEL_PRODUCTION_COUNTING_QUANTITY_DTO).get(productionCountingQuantityForm.getEntityId());
        FieldComponent usedQuantity = (FieldComponent) view.getComponentByReference(ProductionCountingQuantityDtoFields.USED_QUANTITY);
        FieldComponent producedQuantity = (FieldComponent) view.getComponentByReference(ProductionCountingQuantityDtoFields.PRODUCED_QUANTITY);
        usedQuantity.setFieldValue(productionCountingQuantityDto.getDecimalField(ProductionCountingQuantityDtoFields.USED_QUANTITY));
        producedQuantity.setFieldValue(productionCountingQuantityDto.getDecimalField(ProductionCountingQuantityDtoFields.PRODUCED_QUANTITY));
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 83 with FieldComponent

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

the class BasicProductionCountingDetailsListeners method fillDoneQuantityField.

public void fillDoneQuantityField(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent producedQuantity = (FieldComponent) view.getComponentByReference(BasicProductionCountingFields.PRODUCED_QUANTITY);
    Long basicProductionCountingId = form.getEntityId();
    if (basicProductionCountingId != null) {
        Entity basicProductionCounting = basicProductionCountingService.getBasicProductionCounting(basicProductionCountingId);
        Entity order = basicProductionCounting.getBelongsToField(BasicProductionCountingFields.ORDER);
        Entity product = basicProductionCounting.getBelongsToField(BasicProductionCountingFields.PRODUCT);
        if (order.getBelongsToField(OrderFields.PRODUCT).getId().equals(product.getId())) {
            final String fieldValue = (String) producedQuantity.getFieldValue();
            if (fieldValue == null || fieldValue.isEmpty()) {
                return;
            }
            try {
                final BigDecimal doneQuantity = new BigDecimal(fieldValue.replace(",", ".").replace(" ", "").replace("\u00A0", ""));
                order.setField(OrderFields.DONE_QUANTITY, doneQuantity);
                order = order.getDataDefinition().save(order);
            } catch (NumberFormatException ex) {
                return;
            }
            if (!order.isValid()) {
                producedQuantity.addMessage(order.getError(OrderFields.DONE_QUANTITY));
            }
        }
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) BigDecimal(java.math.BigDecimal)

Example 84 with FieldComponent

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

the class ProductionCountingAttributeValueDetailsListeners method onChangeAttribute.

public void onChangeAttribute(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE_VALUE);
    FieldComponent valueField = (FieldComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.VALUE);
    attributeValueLookup.setFieldValue(null);
    attributeValueLookup.requestComponentUpdateState();
    valueField.setFieldValue(null);
    valueField.requestComponentUpdateState();
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 85 with FieldComponent

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

the class ProductionCountingReplacementListeners method onPlannedQuantityChange.

public void onPlannedQuantityChange(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FieldComponent plannedQuantity = (FieldComponent) view.getComponentByReference(L_PLANNED_QUANTITY);
    FieldComponent replacesQuantity = (FieldComponent) view.getComponentByReference(L_REPLACES_QUANTITY);
    replacesQuantity.setFieldValue(plannedQuantity.getFieldValue());
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent)

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