use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class ResourceDetailsHooks method setStorageLocationLookupFilterValue.
private void setStorageLocationLookupFilterValue(final ViewDefinitionState view, final Entity resource) {
LookupComponent storageLocationLookup = (LookupComponent) view.getComponentByReference(ResourceFields.STORAGE_LOCATION);
FilterValueHolder filter = storageLocationLookup.getFilterValue();
Entity product = resource.getBelongsToField(ResourceFields.PRODUCT);
Entity warehouse = resource.getBelongsToField(ResourceFields.LOCATION);
if (Objects.nonNull(product)) {
filter.put(ResourceFields.PRODUCT, product.getId());
}
if (Objects.nonNull(warehouse)) {
filter.put(ResourceFields.LOCATION, warehouse.getId());
}
storageLocationLookup.setFilterValue(filter);
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class PalletResourcesTransferHelperHooks method setStorageLocationFilters.
@Override
protected void setStorageLocationFilters(final ViewDefinitionState view) {
AwesomeDynamicListComponent adl = (AwesomeDynamicListComponent) view.getComponentByReference(L_PALLET_STORAGE_STATE_DTOS);
for (FormComponent form : adl.getFormComponents()) {
LookupComponent newPalletNumber = (LookupComponent) form.findFieldComponentByName("newPalletNumber");
FilterValueHolder filter = newPalletNumber.getFilterValue();
Entity persistedEntity = form.getPersistedEntityWithIncludedFormValues();
filter.put(LOCATION_NUMBER, persistedEntity.getStringField(LOCATION_NUMBER));
filter.put(PALLET_NUMBER, persistedEntity.getStringField(PALLET_NUMBER));
newPalletNumber.setFilterValue(filter);
}
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class PositionAddMultiHooks method onBeforeRender.
public final void onBeforeRender(final ViewDefinitionState view) throws JSONException {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity helper = form.getPersistedEntityWithIncludedFormValues();
JSONObject context = view.getJsonContext();
if (context != null) {
Long warehouseId = context.getLong("window.mainTab.helper.gridLayout.warehouseId");
Long documentId = context.getLong("window.mainTab.helper.gridLayout.documentId");
helper.setField("documentId", documentId);
helper.setField("warehouseId", warehouseId);
GridComponent grid = (GridComponent) view.getComponentByReference("resourceGrid");
FilterValueHolder filter = grid.getFilterValue();
filter.put(L_LOCATION_FROM, warehouseId);
grid.setFilterValue(filter);
form.setEntity(helper);
}
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class DocumentDetailsHooks method fillAddressLookupCriteriaModifier.
public void fillAddressLookupCriteriaModifier(final ViewDefinitionState view) {
LookupComponent companyLookup = (LookupComponent) view.getComponentByReference(DocumentFields.COMPANY);
LookupComponent addressLookup = (LookupComponent) view.getComponentByReference(DocumentFields.ADDRESS);
Entity company = companyLookup.getEntity();
FilterValueHolder filterValueHolder = addressLookup.getFilterValue();
if (company == null) {
filterValueHolder.remove(AddressCriteriaModifiers.L_COMPANY_ID);
addressLookup.setFieldValue(null);
} else {
Long companyId = company.getId();
if (filterValueHolder.has(AddressCriteriaModifiers.L_COMPANY_ID)) {
Long oldCompanyId = filterValueHolder.getLong(AddressCriteriaModifiers.L_COMPANY_ID);
if (!companyId.equals(oldCompanyId)) {
addressLookup.setFieldValue(null);
}
}
filterValueHolder.put(AddressCriteriaModifiers.L_COMPANY_ID, companyId);
}
addressLookup.setFilterValue(filterValueHolder);
addressLookup.requestComponentUpdateState();
}
use of com.qcadoo.view.api.components.lookup.FilterValueHolder in project mes by qcadoo.
the class DocumentPositionsCriteriaModifier method restrictToUserLocations.
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) {
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.or(SearchRestrictions.in(LOCATION_TO_ID, locationIds), SearchRestrictions.in(LOCATION_FROM_ID, locationIds)));
}
}
}
Aggregations