use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.
the class GenerateMaterialRequirementCoverageListeners method showReplacementsAvailability.
public void showReplacementsAvailability(final ViewDefinitionState view, final ComponentState state, final String[] args) {
FormComponent materialRequirementCoverageForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long materialRequirementCoverageId = materialRequirementCoverageForm.getEntityId();
Entity materialRequirement = dataDefinitionService.get(OrderSuppliesConstants.PLUGIN_IDENTIFIER, OrderSuppliesConstants.MODEL_MATERIAL_REQUIREMENT_COVERAGE).get(materialRequirementCoverageId);
GridComponent grid = (GridComponent) view.getComponentByReference("coverageProducts");
Long cpId = grid.getSelectedEntitiesIds().stream().findFirst().get();
Entity cp = dataDefinitionService.get(OrderSuppliesConstants.PLUGIN_IDENTIFIER, OrderSuppliesConstants.MODEL_COVERAGE_PRODUCT).get(cpId);
Entity product = cp.getBelongsToField(CoverageProductFields.PRODUCT);
JSONObject json = new JSONObject();
try {
json.put("product.id", product.getId());
json.put("locationsIds", Lists.newArrayList(materialRequirement.getHasManyField(MaterialRequirementCoverageFields.COVERAGE_LOCATIONS).stream().map(cl -> cl.getBelongsToField(CoverageLocationFields.LOCATION).getId()).collect(Collectors.toList())));
} catch (JSONException e) {
throw new IllegalStateException(e);
}
String url = "/page/productFlowThruDivision/materialReplacementsAvailabilityList.html?context=" + json.toString();
view.redirectTo(url, false, true);
}
use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.
the class OperationalTasksDetailsHooks method fetchNumberFromDatabase.
private void fetchNumberFromDatabase(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (form.getEntityId() != null) {
ComponentState numberField = view.getComponentByReference(OperationalTaskFields.NUMBER);
String numberFieldValue = (String) numberField.getFieldValue();
if (Strings.isNullOrEmpty(numberFieldValue)) {
Entity ot = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_OPERATIONAL_TASK).get(form.getEntityId());
numberField.setFieldValue(ot.getField(OperationalTaskFields.NUMBER));
}
}
}
use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.
the class OrderPacksSingleOrderListListeners method printLabels.
public void printLabels(final ViewDefinitionState view, final ComponentState state, final String[] args) {
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
Set<Long> packsIds = grid.getSelectedEntitiesIds();
if (packsIds.isEmpty()) {
view.addMessage("orders.packs.notSelected", ComponentState.MessageType.INFO);
} else {
view.redirectTo("/orders/packsLabels.pdf?" + packsIds.stream().map(id -> "ids=" + id.toString()).collect(Collectors.joining("&")), true, false);
}
}
use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.
the class LocationDetailsPFTD method changeDivisionsTabAndGridVisibility.
public void changeDivisionsTabAndGridVisibility(final ViewDefinitionState view) {
FormComponent locationForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
GridComponent divisionsGrid = (GridComponent) view.getComponentByReference(L_DIVISIONS);
ComponentState divisionsTab = view.getComponentByReference(L_DIVISIONS_TAB);
Entity location = locationForm.getEntity();
boolean isVisible = location.getId() != null;
divisionsGrid.setVisible(isVisible);
divisionsTab.setVisible(isVisible);
}
use of com.qcadoo.view.api.ComponentState in project mes by qcadoo.
the class OrderDetailsHooksPFTD method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
orderDetailsRibbonHelper.setButtonEnabled(view, "materialFlow", "warehouseIssues", OrderDetailsRibbonHelper.HAS_CHECKED_OR_ACCEPTED_TECHNOLOGY::test);
orderDetailsRibbonHelper.setButtonEnabled(view, "materialFlow", "componentAvailability", OrderDetailsRibbonHelper.HAS_CHECKED_OR_ACCEPTED_TECHNOLOGY::test);
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
ComponentState staffTab = view.getComponentByReference("staffTab");
if (form.getEntityId() != null) {
Entity order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(form.getEntityId());
staffTab.setVisible(TypeOfProductionRecording.CUMULATED.getStringValue().equals(order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING)));
LookupComponent technologyLookup = (LookupComponent) view.getComponentByReference(OrderFields.TECHNOLOGY_PROTOTYPE);
LookupComponent productionLineLookup = (LookupComponent) view.getComponentByReference(OrderFields.PRODUCTION_LINE);
Entity technology = technologyLookup.getEntity();
Entity productionLine = productionLineLookup.getEntity();
if (technology != null && productionLine != null) {
FieldComponent plannedStaffField = (FieldComponent) view.getComponentByReference("plannedStaff");
Optional<Integer> plannedStaff = technologyService.getPlannedStaff(technology, productionLine);
if (plannedStaff.isPresent()) {
plannedStaffField.setFieldValue(plannedStaff.get());
} else {
plannedStaffField.setFieldValue(null);
}
}
FieldComponent actualStaff = (FieldComponent) view.getComponentByReference("actualStaff");
actualStaff.setFieldValue(order.getManyToManyField(OrderFields.STAFF).size());
LookupComponent staffLookup = (LookupComponent) view.getComponentByReference("staffLookup");
FilterValueHolder valueHolder = staffLookup.getFilterValue();
valueHolder.put(StaffCriteriaModifierPFTD.L_ORDER_ID, form.getEntityId());
if (productionLine != null) {
valueHolder.put(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID, productionLine.getId());
} else if (valueHolder.has(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID)) {
valueHolder.remove(StaffCriteriaModifierPFTD.L_PRODUCTION_LINE_ID);
}
staffLookup.setFilterValue(valueHolder);
} else {
staffTab.setVisible(false);
}
}
Aggregations