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