Search in sources :

Example 56 with WindowComponent

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

the class DeliveryDetailsHooks method updateChangeStorageLocationButton.

private void updateChangeStorageLocationButton(final ViewDefinitionState view) {
    FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent deliveredProductsGrid = (GridComponent) view.getComponentByReference(DeliveryFields.DELIVERED_PRODUCTS);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    Ribbon ribbon = window.getRibbon();
    RibbonGroup group = ribbon.getGroupByName(L_DELIVERY_POSITIONS);
    RibbonActionItem changeStorageLocations = group.getItemByName(L_CHANGE_STORAGE_LOCATIONS);
    List<Entity> selectedProducts = deliveredProductsGrid.getSelectedEntities();
    Long deliveryId = deliveryForm.getEntityId();
    boolean enabled = false;
    if (Objects.nonNull(deliveryId)) {
        Entity delivery = deliveriesService.getDelivery(deliveryId);
        String state = delivery.getStringField(DeliveryFields.STATE);
        boolean isFinished = DeliveryState.RECEIVED.getStringValue().equals(state) || DeliveryState.DECLINED.getStringValue().equals(state);
        enabled = !selectedProducts.isEmpty() && !isFinished;
        if (enabled) {
            String baseStorageLocation = Optional.ofNullable(selectedProducts.get(0).getStringField("storageLocationNumber")).orElse(StringUtils.EMPTY);
            for (Entity deliveredProduct : selectedProducts) {
                String storageLocation = Optional.ofNullable(deliveredProduct.getStringField("storageLocationNumber")).orElse(StringUtils.EMPTY);
                if (!baseStorageLocation.equals(storageLocation)) {
                    enabled = false;
                }
            }
        }
    }
    updateButtonState(changeStorageLocations, enabled);
}
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) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 57 with WindowComponent

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

the class DeliveryDetailsHooks method updateCopyOrderedProductButtonsState.

private void updateCopyOrderedProductButtonsState(final ViewDefinitionState view) {
    FormComponent deliveryForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long deliveryId = deliveryForm.getEntityId();
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup reports = window.getRibbon().getGroupByName(L_COPY_ORDERED_PRODUCTS_TO_DELIVERY);
    RibbonActionItem copyWithout = reports.getItemByName(L_COPY_PRODUCTS_WITHOUT_QUANTITY);
    RibbonActionItem copyWith = reports.getItemByName(L_COPY_PRODUCTS_WITH_QUANTITY);
    if (Objects.isNull(deliveryId)) {
        return;
    }
    Entity delivery = deliveriesService.getDelivery(deliveryId);
    boolean hasOrderedProducts = !delivery.getHasManyField(DeliveryFields.ORDERED_PRODUCTS).isEmpty();
    String state = delivery.getStringField(DeliveryFields.STATE);
    boolean isFinished = DeliveryState.RECEIVED.getStringValue().equals(state) || DeliveryState.DECLINED.getStringValue().equals(state);
    copyWith.setEnabled(hasOrderedProducts && !isFinished);
    copyWithout.setEnabled(hasOrderedProducts && !isFinished);
    copyWith.requestUpdate(true);
    copyWithout.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 58 with WindowComponent

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

the class DeliveriesServiceImpl method disableShowProductButton.

@Override
public void disableShowProductButton(final ViewDefinitionState view) {
    GridComponent orderedProductGrid = (GridComponent) view.getComponentByReference(DeliveryFields.ORDERED_PRODUCTS);
    GridComponent deliveredProductsGrid = (GridComponent) view.getComponentByReference(DeliveryFields.DELIVERED_PRODUCTS);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup product = window.getRibbon().getGroupByName(L_PRODUCT);
    RibbonActionItem showProduct = product.getItemByName(L_SHOW_PRODUCT);
    int sizeOfSelectedEntitiesOrderedGrid = orderedProductGrid.getSelectedEntities().size();
    int sizeOfSelectedEntitiesDeliveredGrid = deliveredProductsGrid.getSelectedEntities().size();
    boolean isEnabled = ((sizeOfSelectedEntitiesOrderedGrid == 1) && (sizeOfSelectedEntitiesDeliveredGrid == 0)) || ((sizeOfSelectedEntitiesOrderedGrid == 0) && (sizeOfSelectedEntitiesDeliveredGrid == 1));
    showProduct.setEnabled(isEnabled);
    showProduct.requestUpdate(true);
    window.requestRibbonRender();
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 59 with WindowComponent

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

the class CompanyDetailsHooksD method updateRibbonState.

public void updateRibbonState(final ViewDefinitionState view) {
    FormComponent companyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    RibbonGroup suppliers = window.getRibbon().getGroupByName(L_SUPPLIERS);
    RibbonActionItem redirectToFilteredDeliveriesList = suppliers.getItemByName(L_REDIRECT_TO_FILTERED_DELIVERIES_LIST);
    Entity company = companyForm.getEntity();
    boolean isEnabled = Objects.nonNull(company.getId());
    updateButtonState(redirectToFilteredDeliveriesList, isEnabled);
}
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 60 with WindowComponent

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

the class DocumentDetailsHooks method initializeDocument.

public void initializeDocument(final ViewDefinitionState view) {
    showFieldsByDocumentType(view);
    WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
    FormComponent documentForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    Long documentId = documentForm.getEntityId();
    Entity document = documentForm.getPersistedEntityWithIncludedFormValues();
    DocumentState state = DocumentState.of(document);
    if (documentId == null) {
        changeAcceptButtonState(window, false);
        changePrintButtonState(window, false);
        changeFillResourceButtonState(window, false);
        changeCheckResourcesStockButtonState(window, false);
        changeAddMultipleResourcesButtonState(window, false);
        FieldComponent dateField = (FieldComponent) view.getComponentByReference(DocumentFields.TIME);
        FieldComponent userField = (FieldComponent) view.getComponentByReference(DocumentFields.USER);
        if (dateField.getFieldValue() == null) {
            dateField.setFieldValue(setDateToField(new Date()));
        }
        userField.setFieldValue(userService.getCurrentUserEntity().getId());
    } else if (DocumentState.DRAFT.equals(state)) {
        changeAcceptButtonState(window, true);
        changePrintButtonState(window, true);
        changeFillResourceButtonState(window, reservationsService.reservationsEnabledForDocumentPositions(document));
        changeCheckResourcesStockButtonState(window, DocumentType.isOutbound(document.getStringField(DocumentFields.TYPE)) && !reservationsService.reservationsEnabledForDocumentPositions(document));
        changeAddMultipleResourcesButtonState(window, DocumentType.isOutbound(document.getStringField(DocumentFields.TYPE)));
        if (pluginManager.isPluginEnabled(ESILCO)) {
            if (document.getBooleanField(DocumentFields.WMS) && !document.getBooleanField(DocumentFields.EDIT_IN_WMS)) {
                toggleRibbon(window, false);
                changeFillResourceButtonState(window, false);
                changeAddMultipleResourcesButtonState(window, false);
            } else {
                toggleRibbon(window, true);
            }
        }
    } else if (DocumentState.ACCEPTED.equals(state)) {
        documentForm.setFormEnabled(false);
        toggleRibbon(window, false);
        changePrintButtonState(window, true);
        changeFillResourceButtonState(window, false);
        changeCheckResourcesStockButtonState(window, false);
        changeAddMultipleResourcesButtonState(window, false);
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) DocumentState(com.qcadoo.mes.materialFlowResources.constants.DocumentState) WindowComponent(com.qcadoo.view.api.components.WindowComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Aggregations

WindowComponent (com.qcadoo.view.api.components.WindowComponent)105 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)93 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)75 FormComponent (com.qcadoo.view.api.components.FormComponent)51 Entity (com.qcadoo.model.api.Entity)46 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)31 GridComponent (com.qcadoo.view.api.components.GridComponent)28 FieldComponent (com.qcadoo.view.api.components.FieldComponent)12 LookupComponent (com.qcadoo.view.api.components.LookupComponent)8 EntityTree (com.qcadoo.model.api.EntityTree)4 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)3 JSONObject (org.json.JSONObject)3 Optional (com.google.common.base.Optional)2 AssignmentToShiftState (com.qcadoo.mes.assignmentToShift.states.constants.AssignmentToShiftState)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)2 TreeComponent (com.qcadoo.view.api.components.TreeComponent)2 Date (java.util.Date)2 HashMultimap (com.google.common.collect.HashMultimap)1 Lists (com.google.common.collect.Lists)1