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);
}
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);
}
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();
}
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);
}
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);
}
}
Aggregations