Search in sources :

Example 26 with FormComponent

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

the class AnomalyDetailsListeners method completeWithoutIssue.

public void completeWithoutIssue(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity anomaly = form.getEntity();
    if (anomaly.getId() == null) {
        return;
    }
    anomaly.setField(AnomalyFields.STATE, AnomalyFields.State.COMPLETED);
    anomaly.setField(AnomalyFields.ISSUED, false);
    anomaly.getDataDefinition().save(anomaly);
    state.performEvent(view, "reset", new String[0]);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity)

Example 27 with FormComponent

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

the class AnomalyExplanationDetailsListeners method onRemoveSelectedEntity.

public void onRemoveSelectedEntity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent anomalyExplanationsGrid = (GridComponent) view.getComponentByReference("anomalyExplanations");
    DataDefinition dataDefinition = dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, ProductionCountingConstants.MODEL_ANOMALY_EXPLANATION);
    dataDefinition.delete(toArray(anomalyExplanationsGrid.getSelectedEntitiesIds(), Long.class));
    FormComponent documentForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    documentForm.performEvent(view, "reset");
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) DataDefinition(com.qcadoo.model.api.DataDefinition)

Example 28 with FormComponent

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

the class ProductionTrackingDetailsHooks method updateRibbonState.

public void updateRibbonState(final ViewDefinitionState view) {
    FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup actionsRibbonGroup = window.getRibbon().getGroupByName(L_ACTIONS);
    RibbonGroup productsQuantitiesRibbonGroup = window.getRibbon().getGroupByName(L_PRODUCTS_QUANTITIES);
    RibbonGroup productionCountingQuantitiesRibbonGroup = window.getRibbon().getGroupByName(L_PRODUCTION_COUNTING_QUANTITIES);
    RibbonGroup anomaliesRibbonGroup = window.getRibbon().getGroupByName(L_ANOMALIES);
    RibbonActionItem copyRibbonActionItem = actionsRibbonGroup.getItemByName(L_COPY);
    RibbonActionItem copyPlannedQuantityToUsedQuantityRibbonActionItem = productsQuantitiesRibbonGroup.getItemByName(L_COPY_PLANNED_QUANTITY_TO_USED_QUANTITY);
    RibbonActionItem productionCountingQuantitiesRibbonActionItem = productionCountingQuantitiesRibbonGroup.getItemByName(L_PRODUCTION_COUNTING_QUANTITIES);
    RibbonActionItem addToAnomaliesListRibbonActionItem = anomaliesRibbonGroup.getItemByName(L_ADD_TO_ANOMALIES_LIST);
    if (Objects.isNull(productionTrackingForm.getEntityId())) {
        return;
    }
    Entity productionTracking = productionTrackingForm.getEntity();
    Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER);
    if (Objects.isNull(order)) {
        return;
    }
    String state = productionTracking.getStringField(ProductionTrackingFields.STATE);
    String orderState = order.getStringField(OrderFields.STATE);
    boolean isInProgress = OrderStateStringValues.IN_PROGRESS.equals(orderState);
    boolean isDraft = ProductionTrackingStateStringValues.DRAFT.equals(state);
    boolean registerQuantityInProduct = order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_IN_PRODUCT);
    boolean registerQuantityOutProduct = order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_OUT_PRODUCT);
    copyRibbonActionItem.setEnabled(isInProgress);
    String releaseOfMaterials = parameterService.getParameter().getStringField(ParameterFieldsPC.RELEASE_OF_MATERIALS);
    if (ReleaseOfMaterials.MANUALLY_TO_ORDER_OR_GROUP.getStringValue().equals(releaseOfMaterials)) {
        copyPlannedQuantityToUsedQuantityRibbonActionItem.setEnabled(false);
    } else {
        copyPlannedQuantityToUsedQuantityRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
    }
    productionCountingQuantitiesRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
    addToAnomaliesListRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
    copyRibbonActionItem.requestUpdate(true);
    copyPlannedQuantityToUsedQuantityRibbonActionItem.requestUpdate(true);
    productionCountingQuantitiesRibbonActionItem.requestUpdate(true);
    addToAnomaliesListRibbonActionItem.requestUpdate(true);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 29 with FormComponent

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

the class ProductionTrackingDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    setCriteriaModifierParameters(view);
    productionTrackingService.fillProductionLineLookup(view);
    if ((view.isViewAfterRedirect() || view.isViewAfterReload()) && !((CheckBoxComponent) view.getComponentByReference(ProductionTrackingFields.ADD_BATCH)).isChecked()) {
        FieldComponent batchNumber = (FieldComponent) view.getComponentByReference(ProductionTrackingFields.BATCH_NUMBER);
        batchNumber.setEnabled(false);
    }
    if (Objects.isNull(productionTrackingForm.getEntityId())) {
        setStateFieldValueToDraft(view);
    } else {
        Entity productionTracking = getProductionTrackingFromDB(productionTrackingForm.getEntityId());
        initializeProductionTrackingDetailsView(view);
        showLastStateChangeFailNotification(productionTrackingForm, productionTracking);
        changeFieldComponentsEnabledAndGridsEditable(view);
        updateRibbonState(view);
        toggleCorrectButton(view, productionTracking);
        toggleCorrectionFields(view, productionTracking);
        fetchNumberFromDatabase(view, productionTracking);
    }
    fillBatchOrderedProductLabel(view);
    changeStoppagesTabVisible(view);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Example 30 with FormComponent

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

the class TechnologyDetailsHooksPC method setTechnologyDefaultValues.

public void setTechnologyDefaultValues(final ViewDefinitionState view) {
    FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent typeOfProductionRecordingField = (FieldComponent) view.getComponentByReference(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
    if (Objects.nonNull(orderForm.getEntityId())) {
        return;
    }
    for (String fieldComponentName : L_TECHNOLOGY_FIELD_NAMES) {
        FieldComponent fieldComponent = (FieldComponent) view.getComponentByReference(fieldComponentName);
        if (Objects.isNull(fieldComponent.getFieldValue())) {
            fieldComponent.setFieldValue(getDefaultValueForProductionCountingFromParameter(fieldComponentName));
            fieldComponent.requestComponentUpdateState();
        }
        fieldComponent.setEnabled(false);
    }
    if (Objects.isNull(typeOfProductionRecordingField.getFieldValue())) {
        typeOfProductionRecordingField.setFieldValue(getDefaultValueForTypeOfProductionRecordingParameter(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING));
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Aggregations

FormComponent (com.qcadoo.view.api.components.FormComponent)644 Entity (com.qcadoo.model.api.Entity)501 FieldComponent (com.qcadoo.view.api.components.FieldComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)104 GridComponent (com.qcadoo.view.api.components.GridComponent)83 BigDecimal (java.math.BigDecimal)55 WindowComponent (com.qcadoo.view.api.components.WindowComponent)52 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)45 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)42 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)39 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)36 Date (java.util.Date)33 DataDefinition (com.qcadoo.model.api.DataDefinition)29 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)28 JSONObject (org.json.JSONObject)28 ComponentState (com.qcadoo.view.api.ComponentState)27 Transactional (org.springframework.transaction.annotation.Transactional)20 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)17 Optional (com.google.common.base.Optional)16 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)16