private void AppendJoinsViewModel(Join join, JoinsViewModel joins) { var joinViewModel = joins.Joins.Last(); if (joinViewModel.LinkSelections.Any(ls => ls.Key.StartsWith($"nn:{join.TargetType}:{join.TargetField}"))) { joinViewModel.SelectedItem = joinViewModel.LinkSelections.First(ls => ls.Key.StartsWith($"nn:{join.TargetType}:{join.TargetField}")); } else if (joinViewModel.LinkSelections.Any(ls => ls.Key.StartsWith($"n1:{join.SourceField}:{join.TargetType}"))) { joinViewModel.SelectedItem = joinViewModel.LinkSelections.First(ls => ls.Key.StartsWith($"n1:{join.SourceField}:{join.TargetType}")); } else if (joinViewModel.LinkSelections.Any(ls => ls.Key.StartsWith($"1n:{join.TargetType}:{join.TargetField}"))) { joinViewModel.SelectedItem = joinViewModel.LinkSelections.First(ls => ls.Key.StartsWith($"1n:{join.TargetType}:{join.TargetField}")); } else { throw new NullReferenceException($"Could Not Find Matching Join For {joins.RecordType}.{join.SourceField} = {join.TargetType}.{join.TargetField}"); } AppendIntoFilterConditions(join.RootFilter, joinViewModel.FilterConditions, Joins.RecordType); if (joinViewModel.SelectedItem.Key.StartsWith("nn")) { foreach (var subJoin in join.Joins.First().Joins) { AppendJoinsViewModel(subJoin, joinViewModel.Joins); } } else { foreach (var subJoin in join.Joins) { AppendJoinsViewModel(subJoin, joinViewModel.Joins); } } }
public void RefreshConditionButtons(FilterConditionsViewModel filter = null, bool isRootFilter = true, bool processJoins = true, JoinsViewModel joins = null, bool isNotIn = false) { joins = joins ?? (isNotIn ? NotInJoins : Joins); var deleteButton = isNotIn ? NotInDeleteSelectedConditionsButton : DeleteSelectedConditionsButton; var groupAndButton = isNotIn ? NotInGroupSelectedConditionsAnd : GroupSelectedConditionsAnd; var groupOrButton = isNotIn ? NotInGroupSelectedConditionsOr : GroupSelectedConditionsOr; var ungroupButton = isNotIn ? NotInUngroupSelectedConditions : UngroupSelectedConditions; if (filter == null) { deleteButton.IsVisible = false; groupAndButton.IsVisible = false; groupOrButton.IsVisible = false; ungroupButton.IsVisible = false; filter = (isNotIn ? NotInFilterConditions : FilterConditions); if (!AllowQuery) { return; } } if (filter != null) { var selectedCount = filter.SelectedConditions.Count(); if (selectedCount > 0) { deleteButton.IsVisible = true; } if (selectedCount > 0 && !isRootFilter) { ungroupButton.IsVisible = true; } if (selectedCount > 1 && filter.FilterOperator == FilterOperator.And) { groupOrButton.IsVisible = true; } if (selectedCount > 1 && filter.FilterOperator == FilterOperator.Or) { groupAndButton.IsVisible = true; } foreach (var item in filter.FilterConditions) { RefreshConditionButtons(item, isRootFilter: false, processJoins: false, isNotIn: isNotIn); } if (processJoins && joins != null && joins.Joins != null) { foreach (var join in joins.Joins) { if (join.FilterConditions != null) { RefreshConditionButtons(join.FilterConditions, isRootFilter: true, processJoins: join.Joins != null, joins: join.Joins, isNotIn: isNotIn); } } } } }
public void RefreshConditionButtons(FilterConditionsViewModel filter = null, bool isRootFilter = true, bool processJoins = true, JoinsViewModel joins = null) { joins = joins ?? Joins; if (filter == null) { DeleteSelectedConditionsButton.IsVisible = false; GroupSelectedConditionsAnd.IsVisible = false; GroupSelectedConditionsOr.IsVisible = false; UngroupSelectedConditions.IsVisible = false; filter = FilterConditions; if (!AllowQuery) { return; } } if (filter != null) { var selectedCount = filter.SelectedConditions.Count(); if (selectedCount > 0) { DeleteSelectedConditionsButton.IsVisible = true; } if (selectedCount > 0 && !isRootFilter) { UngroupSelectedConditions.IsVisible = true; } if (selectedCount > 1 && filter.FilterOperator == FilterOperator.And) { GroupSelectedConditionsOr.IsVisible = true; } if (selectedCount > 1 && filter.FilterOperator == FilterOperator.Or) { GroupSelectedConditionsAnd.IsVisible = true; } foreach (var item in filter.FilterConditions) { RefreshConditionButtons(item, isRootFilter: false, processJoins: false); } if (processJoins && joins != null && joins.Joins != null) { foreach (var join in joins.Joins) { if (join.FilterConditions != null) { RefreshConditionButtons(join.FilterConditions, isRootFilter: true, processJoins: join.Joins != null, joins: join.Joins); } } } } }