Search in sources :

Example 46 with GridComponent

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

the class DetailedProductionCountingAndProgressListHooks method setGridEditableDependsOfOrderState.

public void setGridEditableDependsOfOrderState(final ViewDefinitionState view) {
    FormComponent orderForm = (FormComponent) view.getComponentByReference(L_ORDER);
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    Long orderId = orderForm.getEntityId();
    if (orderId == null) {
        return;
    }
    if (disable(orderService.getOrder(orderId))) {
        grid.setEnabled(false);
    } else {
        boolean isLocked = progressModifyLockHelper.isLocked(orderService.getOrder(orderId));
        grid.setEnabled(!isLocked);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 47 with GridComponent

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

the class DetailedProductionCountingAndProgressListHooks method onRemoveSelectedProductionCountingQuantities.

public void onRemoveSelectedProductionCountingQuantities(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent grid = ((GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID));
    List<Entity> selectedEntities = grid.getSelectedEntities();
    List<Long> ids = new ArrayList<>();
    boolean deleteSuccessful = true;
    List<ErrorMessage> errors = Lists.newArrayList();
    for (Entity productionCountingQuantity : selectedEntities) {
        String typeOfMaterial = productionCountingQuantity.getStringField(ProductionCountingQuantityFields.TYPE_OF_MATERIAL);
        if (GlobalTypeOfMaterial.FINAL_PRODUCT.getStringValue().equals(typeOfMaterial)) {
            state.addMessage("basicProductionCounting.productionCountingQuantity.error.cantDeleteFinal", ComponentState.MessageType.INFO);
        } else {
            ids.add(productionCountingQuantity.getId());
            if (deleteSuccessful) {
                EntityOpResult result = productionCountingQuantity.getDataDefinition().delete(productionCountingQuantity.getId());
                if (!result.isSuccessfull()) {
                    deleteSuccessful = false;
                    errors.addAll(result.getMessagesHolder().getGlobalErrors());
                }
            }
        }
    }
    if (ids.size() == 1 && deleteSuccessful) {
        state.addMessage("qcadooView.message.deleteMessage", ComponentState.MessageType.SUCCESS);
    } else if (ids.size() > 1 && deleteSuccessful) {
        state.addMessage("qcadooView.message.deleteMessages", ComponentState.MessageType.SUCCESS, String.valueOf(ids.size()));
    } else if (!deleteSuccessful) {
        errors.stream().forEach(error -> state.addMessage(error));
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent) ArrayList(java.util.ArrayList) EntityOpResult(com.qcadoo.model.api.EntityOpResult) ErrorMessage(com.qcadoo.model.api.validators.ErrorMessage)

Example 48 with GridComponent

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

the class ProductFamilySizesHooks method addOnBeforeRender.

public void addOnBeforeRender(final ViewDefinitionState view) throws JSONException {
    JSONObject obj = view.getJsonContext();
    if (obj.has("window.mainTab.product.productId")) {
        GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
        FilterValueHolder holder = grid.getFilterValue();
        holder.put(ProductFamilySizesCriteriaModifiers.L_PRODUCT_ID, obj.getLong("window.mainTab.product.productId"));
        grid.setFilterValue(holder);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) JSONObject(org.json.JSONObject) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 49 with GridComponent

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

the class ProductReplacementsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) throws JSONException {
    JSONObject obj = view.getJsonContext();
    if (obj.has("window.mainTab.product.productId")) {
        GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
        FilterValueHolder holder = grid.getFilterValue();
        holder.put("PRODUCT_ID", obj.getLong("window.mainTab.product.productId"));
        grid.setFilterValue(holder);
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) JSONObject(org.json.JSONObject) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 50 with GridComponent

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

the class PalletNumberHelpersListHooks method addDiscriminatorRestrictionToGrid.

public final void addDiscriminatorRestrictionToGrid(final ViewDefinitionState view) {
    GridComponent palletNumberHelpersGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    palletNumberHelpersGrid.setCustomRestriction(new CustomRestriction() {

        @Override
        public void addRestriction(final SearchCriteriaBuilder searchBuilder) {
            searchBuilder.add(SearchRestrictions.eq(PalletNumberHelperFields.TEMPORARY, false));
        }
    });
}
Also used : SearchCriteriaBuilder(com.qcadoo.model.api.search.SearchCriteriaBuilder) GridComponent(com.qcadoo.view.api.components.GridComponent) CustomRestriction(com.qcadoo.model.api.search.CustomRestriction)

Aggregations

GridComponent (com.qcadoo.view.api.components.GridComponent)260 Entity (com.qcadoo.model.api.Entity)131 FormComponent (com.qcadoo.view.api.components.FormComponent)85 FieldComponent (com.qcadoo.view.api.components.FieldComponent)33 WindowComponent (com.qcadoo.view.api.components.WindowComponent)30 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)29 JSONObject (org.json.JSONObject)28 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)26 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)24 ComponentState (com.qcadoo.view.api.ComponentState)23 DataDefinition (com.qcadoo.model.api.DataDefinition)22 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)22 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)20 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)19 Autowired (org.springframework.beans.factory.annotation.Autowired)19 BigDecimal (java.math.BigDecimal)16 Service (org.springframework.stereotype.Service)16 LookupComponent (com.qcadoo.view.api.components.LookupComponent)15 Collectors (java.util.stream.Collectors)15 Lists (com.google.common.collect.Lists)12