use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class OrderTechnologicalProcessesSingleOrderListHooks method updateRibbonState.
private void updateRibbonState(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup orderTechnologicalProcessesGroup = window.getRibbon().getGroupByName(L_ORDER_TECHNOLOGICAL_PROCESSES);
RibbonActionItem generateOrderTechnologicalProcessesActionItem = orderTechnologicalProcessesGroup.getItemByName(L_GENERATE_ORDER_TECHNOLOGICAL_PROCESSES);
RibbonActionItem divideOrderTechnologicalProcessActionItem = orderTechnologicalProcessesGroup.getItemByName(L_DIVIDE_ORDER_TECHNOLOGICAL_PROCESS);
FormComponent orderForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
GridComponent orderTechnologicalProcessesGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Set<Long> orderTechnologicalProcessesIds = orderTechnologicalProcessesGrid.getSelectedEntitiesIds();
boolean isOrderTechnologicalProcessSelected = orderTechnologicalProcessesIds.size() == 1;
boolean isOrderStateValid = false;
Entity order = orderForm.getEntity();
Long orderId = order.getId();
if (Objects.nonNull(orderId)) {
order = order.getDataDefinition().get(orderId);
isOrderStateValid = !orderTechnologicalProcessService.checkOrderState(order);
}
generateOrderTechnologicalProcessesActionItem.setEnabled(isOrderStateValid);
generateOrderTechnologicalProcessesActionItem.requestUpdate(true);
divideOrderTechnologicalProcessActionItem.setEnabled(isOrderTechnologicalProcessSelected && isOrderStateValid);
divideOrderTechnologicalProcessActionItem.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent 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.components.WindowComponent 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.components.WindowComponent in project mes by qcadoo.
the class ProductsToIssueListListeners method changeRibbonState.
private void changeRibbonState(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup group = window.getRibbon().getGroupByName("warehouseIssues");
RibbonActionItem copyProducts = group.getItemByName("copyProducts");
RibbonActionItem correctReservations = group.getItemByName("correctReservations");
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
DataDefinition productsToIssueDD = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_PRODUCTS_TO_ISSUE);
Set<Long> selectedEntitiesIds = grid.getSelectedEntitiesIds();
boolean enabled = !selectedEntitiesIds.isEmpty();
boolean correctionEnabled = !selectedEntitiesIds.isEmpty();
if (enabled) {
Entity warehouse = null;
Entity location = null;
for (Long id : selectedEntitiesIds) {
Entity productToIssue = productsToIssueDD.get(id);
if (productToIssue != null) {
Entity warehouseIssue = productToIssue.getBelongsToField(ProductsToIssueFields.WAREHOUSE_ISSUE);
String state = warehouseIssue.getStringField(WarehouseIssueFields.STATE);
Entity productLocation = productToIssue.getBelongsToField(ProductsToIssueFields.LOCATION);
if (location == null) {
location = productLocation;
} else {
if (productLocation != null && !location.getId().equals(productLocation.getId())) {
correctionEnabled = false;
}
}
if (WarehouseIssueState.DISCARD.getStringValue().equals(state) || WarehouseIssueState.COMPLETED.getStringValue().equals(state)) {
enabled = false;
} else {
Entity issueWarehouse = warehouseIssue.getBelongsToField(WarehouseIssueFields.PLACE_OF_ISSUE);
if (warehouse == null) {
warehouse = issueWarehouse;
} else {
if (!warehouse.getId().equals(issueWarehouse.getId())) {
enabled = false;
correctionEnabled = false;
}
}
}
} else {
enabled = false;
}
}
}
correctReservations.setEnabled(correctionEnabled);
correctReservations.requestUpdate(true);
copyProducts.setEnabled(enabled);
copyProducts.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent 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