Search in sources :

Example 51 with LookupComponent

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

the class WarehouseMinimumStateListListener method createMultiMinimalStates.

@Transactional
public void createMultiMinimalStates(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity state = form.getPersistedEntityWithIncludedFormValues();
    if (state.getBelongsToField(WarehouseMinimumStateFields.LOCATION) == null) {
        LookupComponent location = (LookupComponent) view.getComponentByReference(WarehouseMinimumStateFields.LOCATION);
        location.addMessage(new ErrorMessage(L_QCADOO_VIEW_VALIDATE_FIELD_ERROR_MISSING));
        location.requestComponentUpdateState();
        return;
    }
    if (state.getManyToManyField("products") == null || state.getManyToManyField("products").isEmpty()) {
        view.addMessage(new ErrorMessage("warehouseMinimalState.warehouseMinimumStateAddMulti.error.productsEmpthy"));
        return;
    }
    state.getManyToManyField("products").forEach(p -> createMinimalStateEntity(state, p));
    componentState.addMessage("warehouseMinimalState.warehouseMinimumStateAddMulti.info.generated", ComponentState.MessageType.SUCCESS);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) ErrorMessage(com.qcadoo.model.api.validators.ErrorMessage) Transactional(org.springframework.transaction.annotation.Transactional)

Example 52 with LookupComponent

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

the class TechOperCompWorkstationTimeDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    LookupComponent workstationLookup = (LookupComponent) view.getComponentByReference(TechOperCompWorkstationTimeFields.WORKSTATION);
    Entity techOperCompWorkstationTime = form.getEntity();
    Entity technologyOperationComponent = techOperCompWorkstationTime.getBelongsToField(TechOperCompWorkstationTimeFields.TECHNOLOGY_OPERATION_COMPONENT);
    Entity workstation = techOperCompWorkstationTime.getBelongsToField(TechOperCompWorkstationTimeFields.WORKSTATION);
    filterWorkstationLookup(workstationLookup, technologyOperationComponent, workstation);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent)

Example 53 with LookupComponent

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

the class StaffDetailsHooks method fillFieldAboutWageGroup.

public void fillFieldAboutWageGroup(final ViewDefinitionState view) {
    LookupComponent lookup = (LookupComponent) view.getComponentByReference("wageGroup");
    Entity wageGroup = lookup.getEntity();
    FieldComponent laborCostFromWageGroups = (FieldComponent) view.getComponentByReference("laborCostFromWageGroups");
    FieldComponent superiorWageGroups = (FieldComponent) view.getComponentByReference("superiorWageGroups");
    if (wageGroup != null) {
        laborCostFromWageGroups.setFieldValue(wageGroup.getField(LABOR_HOURLY_COST));
        superiorWageGroups.setFieldValue(wageGroup.getStringField(SUPERIOR_WAGE_GROUP));
    } else {
        laborCostFromWageGroups.setFieldValue(null);
        superiorWageGroups.setFieldValue(null);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 54 with LookupComponent

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

the class ProductionCountingAttributeValueDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    setValueBold(view);
    setFilters(view);
    LookupComponent attributeLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE);
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.ATTRIBUTE_VALUE);
    FieldComponent valueField = (FieldComponent) view.getComponentByReference(ProductionCountingAttributeValueFields.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 55 with LookupComponent

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

the class ProductionCountingAttributeValueDetailsHooks method setFilters.

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

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