Search in sources :

Example 36 with Ribbon

use of com.qcadoo.view.api.ribbon.Ribbon in project mes by qcadoo.

the class OrderDetailsHooks method disabledRibbonWhenOrderIsSynchronized.

public void disabledRibbonWhenOrderIsSynchronized(final ViewDefinitionState view) {
    FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    List<RibbonGroup> ribbonGroups = ribbon.getGroups();
    Long orderId = orderForm.getEntityId();
    if (Objects.isNull(orderId)) {
        return;
    }
    Entity order = orderService.getOrder(orderId);
    if (orderStateService.isSynchronized(order)) {
        return;
    }
    for (RibbonGroup ribbonGroup : ribbonGroups) {
        for (RibbonActionItem ribbonActionItem : ribbonGroup.getItems()) {
            ribbonActionItem.setEnabled(false);
            ribbonActionItem.requestUpdate(true);
        }
    }
    RibbonActionItem refreshRibbonActionItem = ribbon.getGroupByName(L_ORDER_DETAILS_ACTIONS).getItemByName(L_REFRESH);
    RibbonActionItem backRibbonActionItem = ribbon.getGroupByName(L_NAVIGATION).getItemByName(L_BACK);
    refreshRibbonActionItem.setEnabled(true);
    backRibbonActionItem.setEnabled(true);
    refreshRibbonActionItem.requestUpdate(true);
    backRibbonActionItem.requestUpdate(true);
    orderForm.setFormEnabled(false);
}
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) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 37 with Ribbon

use of com.qcadoo.view.api.ribbon.Ribbon in project mes by qcadoo.

the class OrderPacksSingleOrderListHooks method onBeforeRender.

public final void onBeforeRender(final ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(OrdersConstants.MODEL_ORDER);
    Entity order = form.getPersistedEntityWithIncludedFormValues();
    String orderState = order.getStringField(OrderFields.STATE);
    if (OrderState.COMPLETED.getStringValue().equals(orderState) || OrderState.DECLINED.getStringValue().equals(orderState) || OrderState.ABANDONED.getStringValue().equals(orderState) || OrderState.PENDING.getStringValue().equals(orderState)) {
        GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
        grid.setEditable(false);
        grid.setEnabled(false);
        WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
        Ribbon ribbon = window.getRibbon();
        RibbonActionItem generateOrderPacks = ribbon.getGroupByName("orderPacks").getItemByName("generateOrderPacks");
        RibbonActionItem actionsNew = ribbon.getGroupByName(ACTIONS).getItemByName("new");
        generateOrderPacks.setEnabled(false);
        generateOrderPacks.requestUpdate(true);
        actionsNew.setEnabled(false);
        actionsNew.requestUpdate(true);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 38 with Ribbon

use of com.qcadoo.view.api.ribbon.Ribbon in project mes by qcadoo.

the class ProductsToIssueDetailsHooks method onBeforeRender.

public void onBeforeRender(final ViewDefinitionState view) {
    FormComponent productToIssueForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    FieldComponent locationFromLabel = (FieldComponent) view.getComponentByReference("locationFromLabel");
    FieldComponent helperField = (FieldComponent) view.getComponentByReference("generated");
    Entity helper = productToIssueForm.getEntity();
    Entity locationFrom = helper.getBelongsToField("locationFrom");
    if (Objects.nonNull(locationFrom)) {
        locationFromLabel.setFieldValue(translationService.translate("productFlowThruDivision.productsToIssueHelperDetails.window.mainTab.form.locationFromLabel.label", LocaleContextHolder.getLocale(), locationFrom.getStringField(LocationFields.NUMBER)));
        locationFromLabel.setRequired(true);
    }
    if (view.isViewAfterRedirect() && helper.getHasManyField("issues").isEmpty()) {
        String idsStr = helper.getStringField("productsToIssueIds");
        String[] split = idsStr.split(",");
        List<Long> ids = Lists.newArrayList(split).stream().map(Long::valueOf).collect(Collectors.toList());
        Multimap<Entity, Entity> locationFromProductMultimap = HashMultimap.create();
        Multimap<Entity, Entity> locationToProductMultimap = HashMultimap.create();
        List<Entity> createdIssues = Lists.newArrayList();
        for (Long id : ids) {
            Entity productToIssue = getProductToIssueDD().get(id);
            Entity product = productToIssue.getBelongsToField(ProductsToIssueFields.PRODUCT);
            locationFromProductMultimap.put(productToIssue.getBelongsToField(ProductsToIssueFields.WAREHOUSE_ISSUE).getBelongsToField(WarehouseIssueFields.PLACE_OF_ISSUE), product);
            locationToProductMultimap.put(productToIssue.getBelongsToField(ProductsToIssueFields.LOCATION), product);
            createdIssues.add(createIssue(getIssueDD(), productToIssue));
        }
        Map<Long, Map<Long, BigDecimal>> stockForWarehousesFrom = getStockForWarehouses(locationFromProductMultimap);
        Map<Long, Map<Long, BigDecimal>> stockForWarehousesTo = getStockForWarehouses(locationToProductMultimap);
        fillLocationQuantity(createdIssues, stockForWarehousesFrom, stockForWarehousesTo);
        helper.setField("issues", sortIssuesBasedOnFilter(view, createdIssues));
        productToIssueForm.setEntity(helper);
    } else {
        List<Entity> issues = helper.getHasManyField("issues");
        if (!issues.isEmpty() && issues.stream().allMatch(issue -> Objects.nonNull(issue.getId()))) {
            WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
            Ribbon ribbon = window.getRibbon();
            RibbonGroup group = ribbon.getGroupByName("actions");
            RibbonActionItem createDocumentsItem = group.getItemByName("createDocuments");
            RibbonActionItem createDocumentsAndGoBackItem = group.getItemByName("createDocumentsAndGoBack");
            createDocumentsItem.setEnabled(!Boolean.valueOf((String) helperField.getFieldValue()));
            createDocumentsItem.requestUpdate(true);
            createDocumentsAndGoBackItem.setEnabled(!Boolean.valueOf((String) helperField.getFieldValue()));
            createDocumentsAndGoBackItem.requestUpdate(true);
        }
        fillQuantitiesInAdditionalUnit(view);
    }
    fillUnits(view);
}
Also used : LocaleContextHolder(org.springframework.context.i18n.LocaleContextHolder) Arrays(java.util.Arrays) ProductsToIssueFields(com.qcadoo.mes.productFlowThruDivision.warehouseIssue.constans.ProductsToIssueFields) ResourceStockDtoFields(com.qcadoo.mes.materialFlowResources.constants.ResourceStockDtoFields) Autowired(org.springframework.beans.factory.annotation.Autowired) BigDecimalUtils(com.qcadoo.model.api.BigDecimalUtils) BigDecimal(java.math.BigDecimal) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) HashMultimap(com.google.common.collect.HashMultimap) Optional(com.google.common.base.Optional) Map(java.util.Map) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WarehouseIssueParameterService(com.qcadoo.mes.productFlowThruDivision.warehouseIssue.WarehouseIssueParameterService) Collectors(java.util.stream.Collectors) DataDefinition(com.qcadoo.model.api.DataDefinition) Objects(java.util.Objects) List(java.util.List) Entity(com.qcadoo.model.api.Entity) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) FieldComponent(com.qcadoo.view.api.components.FieldComponent) CalculationQuantityService(com.qcadoo.mes.basic.CalculationQuantityService) WindowComponent(com.qcadoo.view.api.components.WindowComponent) DataDefinitionService(com.qcadoo.model.api.DataDefinitionService) IssueFields(com.qcadoo.mes.productFlowThruDivision.warehouseIssue.constans.IssueFields) QcadooViewConstants(com.qcadoo.view.constants.QcadooViewConstants) OrderFields(com.qcadoo.mes.orders.constants.OrderFields) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) Multimap(com.google.common.collect.Multimap) OrdersConstants(com.qcadoo.mes.orders.constants.OrdersConstants) ArrayList(java.util.ArrayList) ViewDefinitionState(com.qcadoo.view.api.ViewDefinitionState) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) FormComponent(com.qcadoo.view.api.components.FormComponent) WarehouseIssueFields(com.qcadoo.mes.productFlowThruDivision.warehouseIssue.constans.WarehouseIssueFields) LocationFields(com.qcadoo.mes.materialFlow.constants.LocationFields) LinkedHashSet(java.util.LinkedHashSet) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) MaterialFlowResourcesService(com.qcadoo.mes.materialFlowResources.MaterialFlowResourcesService) TranslationService(com.qcadoo.localization.api.TranslationService) Maps(com.google.common.collect.Maps) Either(com.qcadoo.commons.functional.Either) NumberService(com.qcadoo.model.api.NumberService) ProductFields(com.qcadoo.mes.basic.constants.ProductFields) ProductFlowThruDivisionConstants(com.qcadoo.mes.productFlowThruDivision.constants.ProductFlowThruDivisionConstants) Comparator(java.util.Comparator) StringUtils(org.springframework.util.StringUtils) 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) FieldComponent(com.qcadoo.view.api.components.FieldComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) Map(java.util.Map) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 39 with Ribbon

use of com.qcadoo.view.api.ribbon.Ribbon in project mes by qcadoo.

the class WarehouseIssueDetailHooks method updateRibbonState.

private void updateRibbonState(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup group = ribbon.getGroupByName("issue");
    RibbonActionItem productsToIssue = group.getItemByName("productsToIssue");
    RibbonGroup groupCopyProductsToIssue = ribbon.getGroupByName("copyissue");
    RibbonActionItem copyProductsToIssue = groupCopyProductsToIssue.getItemByName("copyProductsToIssue");
    if (!warehouseIssueParameterService.issueForOrder()) {
        productsToIssue.setEnabled(false);
        productsToIssue.setMessage("productFlowThruDivision.issue.activeWhenIssueForOrder");
        productsToIssue.requestUpdate(true);
        window.requestRibbonRender();
    }
    String state = (String) view.getComponentByReference(WarehouseIssueFields.STATE).getFieldValue();
    if (state.equals(WarehouseIssueStringValues.DISCARD) || state.equals(WarehouseIssueStringValues.COMPLETED)) {
        copyProductsToIssue.setEnabled(false);
        copyProductsToIssue.requestUpdate(true);
        window.requestRibbonRender();
    }
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 40 with Ribbon

use of com.qcadoo.view.api.ribbon.Ribbon in project mes by qcadoo.

the class ProductDetailsHooksPC method updateButtonsState.

public void updateButtonsState(final ViewDefinitionState view) {
    FormComponent productForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup showProductionTrackingsRibbonGroup = ribbon.getGroupByName(L_SHOW_PRODUCTION_TRACKINGS);
    RibbonActionItem showProductionTrackingsForProductRibbonActionItem = showProductionTrackingsRibbonGroup.getItemByName(L_SHOW_PRODUCTION_TRACKINGS_FOR_PRODUCT);
    RibbonActionItem showProductionTrackingsForProductGroupedRibbonActionItem = showProductionTrackingsRibbonGroup.getItemByName(L_SHOW_PRODUCTION_TRACKINGS_FOR_PRODUCT_GROUPED);
    Long productionTrackingId = productForm.getEntityId();
    boolean isSaved = (productionTrackingId != null);
    showProductionTrackingsForProductRibbonActionItem.setEnabled(isSaved);
    showProductionTrackingsForProductGroupedRibbonActionItem.setEnabled(isSaved);
    showProductionTrackingsForProductRibbonActionItem.requestUpdate(true);
    showProductionTrackingsForProductGroupedRibbonActionItem.requestUpdate(true);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Aggregations

Ribbon (com.qcadoo.view.api.ribbon.Ribbon)40 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)37 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)36 WindowComponent (com.qcadoo.view.api.components.WindowComponent)31 FormComponent (com.qcadoo.view.api.components.FormComponent)16 Entity (com.qcadoo.model.api.Entity)10 GridComponent (com.qcadoo.view.api.components.GridComponent)8 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)4 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)3 Optional (com.google.common.base.Optional)2 Lists (com.google.common.collect.Lists)2 AssignmentToShiftState (com.qcadoo.mes.assignmentToShift.states.constants.AssignmentToShiftState)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 DataDefinitionService (com.qcadoo.model.api.DataDefinitionService)2 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)2 FieldComponent (com.qcadoo.view.api.components.FieldComponent)2 BigDecimal (java.math.BigDecimal)2 Arrays (java.util.Arrays)2 Service (org.springframework.stereotype.Service)2 HashMultimap (com.google.common.collect.HashMultimap)1