flag exclude children for taxonomies (#8481)

This commit is contained in:
ElenaRepository 2021-06-21 09:42:59 +02:00 committed by GitHub
parent 230dfc30da
commit f23d9292c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -47,8 +47,11 @@ namespace Orchard.Taxonomies.Projections {
var terms = ids.Select(_taxonomyService.GetTerm).ToList();
var allChildren = new List<TermPart>();
foreach (var term in terms) {
allChildren.AddRange(_taxonomyService.GetChildren(term));
allChildren.Add(term);
bool.TryParse(context.State.ExcludeChildren?.Value, out bool excludeChildren);
if (!excludeChildren)
allChildren.AddRange(_taxonomyService.GetChildren(term));
if (term != null)
allChildren.Add(term);
}
allChildren = allChildren.Distinct().ToList();

View File

@ -48,8 +48,13 @@ namespace Orchard.Taxonomies.Projections {
Id: "operator-is-all-of", Name: "Operator",
Title: T("Is all of"), Value: "1"
)
)
);
),
_ExcludeChildren: Shape.Checkbox(
Id: "ExcludeChildren", Name: "ExcludeChildren",
Title: T("Automatically exclude children terms in filtering"),
Value: "true"
)
);
foreach (var taxonomy in _taxonomyService.GetTaxonomies()) {
f._Terms.Add(new SelectListItem { Value = String.Empty, Text = taxonomy.Name });