Search in sources :

Example 91 with FormComponent

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

the class ProductDetailsListenersT method showTechnologiesWithProduct.

public final void showTechnologiesWithProduct(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
    FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Entity product = productForm.getEntity();
    if (product.getId() == null) {
        return;
    }
    String productNumber = product.getStringField(NUMBER);
    if (productNumber == null) {
        return;
    }
    Map<String, String> filters = Maps.newHashMap();
    filters.put("productNumber", applyInOperator(productNumber));
    Map<String, Object> gridOptions = Maps.newHashMap();
    gridOptions.put(L_FILTERS, filters);
    Map<String, Object> parameters = Maps.newHashMap();
    parameters.put(L_GRID_OPTIONS, gridOptions);
    parameters.put(L_WINDOW_ACTIVE_MENU, "technology.technologies");
    String url = "../page/technologies/technologiesList.html";
    view.redirectTo(url, false, true, parameters);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity)

Example 92 with FormComponent

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

the class GenerateTimeGapsListeners method generateTimeGaps.

public void generateTimeGaps(final ViewDefinitionState viewState, final ComponentState formState, final String[] args) throws ParseException {
    FormComponent form = (FormComponent) formState;
    Entity contextEntity = form.getPersistedEntityWithIncludedFormValues();
    // We don't want to reuse contexts - in case of the user working with many browser tabs to compare a couple of results
    contextEntity.setId(null);
    contextEntity.setField(TimeGapsContextFields.TIME_GAPS, Collections.<Entity>emptyList());
    // Call validation
    contextEntity = contextEntity.getDataDefinition().save(contextEntity);
    if (!contextEntity.isValid()) {
        clearSummaryFields(contextEntity);
        form.setEntity(contextEntity);
        return;
    }
    // Generate & persist results
    TimeGapsSearchResult searchResult = performGeneration(contextEntity);
    Entity persistedContext = persistResults(contextEntity, searchResult);
    if (persistedContext.isValid()) {
        // Show 'time gaps' tab
        WindowComponent window = (WindowComponent) findComponentByReferenceName(viewState, QcadooViewConstants.L_WINDOW);
        window.setActiveTab("timeGaps");
    }
    form.setEntity(persistedContext);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) TimeGapsSearchResult(com.qcadoo.mes.timeGapsPreview.TimeGapsSearchResult)

Example 93 with FormComponent

use of com.qcadoo.view.api.components.FormComponent 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 94 with FormComponent

use of com.qcadoo.view.api.components.FormComponent 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 95 with FormComponent

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

the class TechnologyOperationComponentDetailsHooks method checkOperationOutputQuantities.

public void checkOperationOutputQuantities(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    if (form.getEntityId() == null) {
        return;
    }
    Entity operationComponent = form.getEntity();
    operationComponent = operationComponent.getDataDefinition().get(operationComponent.getId());
    BigDecimal timeNormsQuantity = operationComponent.getDecimalField("productionInOneCycle");
    Entity productOutComponent = null;
    try {
        productOutComponent = technologyService.getMainOutputProductComponent(operationComponent);
    } catch (IllegalStateException e) {
        return;
    }
    BigDecimal currentQuantity = productOutComponent.getDecimalField("quantity");
    if (timeNormsQuantity != null && timeNormsQuantity.compareTo(currentQuantity) != 0) {
        form.addMessage("technologies.technologyOperationComponent.validate.error.invalidQuantity", MessageType.INFO, false, numberService.format(currentQuantity), productOutComponent.getBelongsToField("product").getStringField("unit"));
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) BigDecimal(java.math.BigDecimal)

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