use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class ProductionLineAddMultiHooks method onBeforeRender.
public final void onBeforeRender(final ViewDefinitionState view) throws JSONException {
JSONObject context = view.getJsonContext();
GridComponent grid = (GridComponent) view.getComponentByReference("productionLineGrid");
FilterValueHolder filter = grid.getFilterValue();
filter.put(TechnologyProductionLineCriteriaModifiers.L_TECHNOLOGY_ID, context.getLong("window.mainTab.form.gridLayout.technologyId"));
if (context.has("window.mainTab.form.gridLayout.divisionId")) {
filter.put(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID, context.getLong("window.mainTab.form.gridLayout.divisionId"));
} else if (filter.has(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID)) {
filter.remove(TechnologyProductionLineCriteriaModifiers.L_DIVISION_ID);
}
grid.setFilterValue(filter);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class LocationDetailsPFTD method setCriteriaModifierParameters.
public void setCriteriaModifierParameters(final ViewDefinitionState view) {
FormComponent locationForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
GridComponent divisionsGrid = (GridComponent) view.getComponentByReference(L_DIVISIONS);
Entity location = locationForm.getEntity();
if (location.getId() != null) {
FilterValueHolder filterValueHolder = divisionsGrid.getFilterValue();
filterValueHolder.put(L_LOCATION, location.getId());
divisionsGrid.setFilterValue(filterValueHolder);
}
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class IssueCriteriaModifiers method restrictToUserLocations.
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filter) {
Long currentUserId = securityService.getCurrentUserId();
if (Objects.nonNull(currentUserId)) {
EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS);
if (!userLocations.isEmpty()) {
Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)).mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet());
scb.add(SearchRestrictions.in("locationId", locationIds));
}
}
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class GeneratorViewHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
GeneratorView generatorView = GeneratorView.from(view);
generateProductNumber(view);
showRibbonButtons(generatorView, view);
GridComponent grid = (GridComponent) view.getComponentByReference("generatorTechnologiesForProducts");
FilterValueHolder gridHolder = grid.getFilterValue();
gridHolder.put(TechnologiesForProductsCM.PARAMETER, generatorView.getFormEntity().getId());
grid.setFilterValue(gridHolder);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class OperationDetailsHooks method setWorkstationsCriteriaModifiers.
private void setWorkstationsCriteriaModifiers(final ViewDefinitionState view) {
LookupComponent divisionLookup = (LookupComponent) view.getComponentByReference(OperationFields.DIVISION);
LookupComponent workstationLookup = (LookupComponent) view.getComponentByReference(L_WORKSTATION_LOOKUP);
GridComponent workstations = (GridComponent) view.getComponentByReference(OperationFields.WORKSTATIONS);
Entity division = divisionLookup.getEntity();
FilterValueHolder filter = workstationLookup.getFilterValue();
if (division != null) {
filter.put(OperationFields.DIVISION, division.getId());
workstations.setEditable(true);
} else {
filter.remove(OperationFields.DIVISION);
workstations.setEditable(false);
}
workstationLookup.setFilterValue(filter);
}
Aggregations