Adding notification when saving a Query or a ProjectionPart to warn about the effect of an empty filter group

This commit is contained in:
Benedek Farkas 2024-12-07 13:20:48 +01:00
parent 427f164b97
commit f4c22e69e5
2 changed files with 11 additions and 0 deletions

View File

@ -168,6 +168,11 @@ namespace Orchard.Projections.Controllers {
viewModel.FilterGroups = filterGroupEntries;
if (viewModel.FilterGroups.Any(group => group.Filters.Count() == 0)) {
_services.Notifier.Warning(
T("This Query has at least one empty filter group, which will cause all content items to be returned, unless the Projection using this Query limits the number of content items displayed."));
}
#endregion
#region Load Sort criterias

View File

@ -355,6 +355,12 @@ namespace Orchard.Projections.Drivers {
updater.AddModelError("PagerSuffix", T("Suffix should not contain special characters."));
}
if (model.Items == 0
&& (part.Record.QueryPartRecord?.FilterGroups.Any(group => group.Filters.Count == 0) ?? false)) {
_orchardServices.Notifier.Warning(
T("The selected Query has at least one empty filter group, which causes all content items to be returned. It is recommended to limit the number of content items queried by setting the 'Items to display' field to a non-zero value."));
}
return Editor(part, shapeHelper);
}