Skip to content

Commit f043ea5

Browse files
committed
Introduced ExpandRelated topic query option
The new `TopicQueryOption.ExpandRelated` option allows callers to control whether or not an ExtJs TreePanel bound to a serialized `QueryResultTopicViewModel` should be expanded such that any nodes leading to marked related topics are expanded. By default, this is enabled if `MarkRelated` is enabled, which in turn is automatically enabled if a `RelatedTopicId` is defined and a `RelatedNamespace` is declared. If `MarkRelated` or `ExpandRelated` are disabled, then it won't be used.
1 parent 769d9a1 commit f043ea5

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

OnTopic.Editor.AspNetCore/Infrastructure/TopicQueryService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private void MapQueryResult(
101101
topic.GetWebPath(),
102102
options.EnableCheckboxes ? (options.MarkRelated ? related.Contains(topic) : true) : new bool?(),
103103
topic.Attributes.GetValue("DisableDelete", "0").Equals("0"),
104-
options.MarkRelated && related.Any(r => r.GetUniqueKey().StartsWith(topic.GetUniqueKey(), StringComparison.Ordinal))
104+
options.ExpandRelated && related.Any(r => r.GetUniqueKey().StartsWith(topic.GetUniqueKey(), StringComparison.Ordinal))
105105
);
106106

107107
//Add topic to topic list

OnTopic.Editor.Models/Queryable/TopicQueryOptions.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class TopicQueryOptions {
1919
| PRIVATE VARIABLES
2020
\-------------------------------------------------------------------------------------------------------------------------*/
2121
bool _markRelated = false;
22+
bool _expandRelated = true;
2223
bool _showCheckboxes = false;
2324

2425
/*==========================================================================================================================
@@ -44,6 +45,7 @@ public TopicQueryOptions() {
4445
AttributeValue = null;
4546
Query = null;
4647
MarkRelated = false;
48+
ExpandRelated = false;
4749
RelatedTopicId = -1;
4850
RelatedNamespace = null;
4951
EnableCheckboxes = false;
@@ -195,18 +197,33 @@ public bool EnableCheckboxes {
195197
| MARK RELATED
196198
\-------------------------------------------------------------------------------------------------------------------------*/
197199
/// <summary>
198-
/// Determines whether <see cref="QueryResultTopicViewModel"/>s should be marked as <see cref="QueryResultTopicViewModel.IsChecked"/>
199-
/// based on their presence in related topics.
200+
/// Determines whether <see cref="QueryResultTopicViewModel"/>s should be marked as <see cref="QueryResultTopicViewModel.
201+
/// IsChecked"/> based on their presence in related topics.
200202
/// </summary>
201203
/// <remarks>
202-
/// This will automatically be set to true is <see cref="RelatedTopicId"/> or <see cref="RelatedNamespace"/> are set. If
204+
/// This will automatically be set to true if <see cref="RelatedTopicId"/> or <see cref="RelatedNamespace"/> are set. If
203205
/// <see cref="RelatedTopicId"/> is <i>not</i> set, then the current <see cref="Topic"/> should be assumed.
204206
/// </remarks>
205207
public bool MarkRelated {
206208
get => (RelatedTopicId > 0 || !String.IsNullOrEmpty(RelatedNamespace) || _markRelated);
207209
set => _markRelated = value;
208210
}
209211

212+
/*==========================================================================================================================
213+
| EXPAND RELATED
214+
\-------------------------------------------------------------------------------------------------------------------------*/
215+
/// <summary>
216+
/// Determines whether <see cref="QueryResultTopicViewModel"/>s should be marked ascendants as nodes marked as <see
217+
/// cref="QueryResultTopicViewModel.IsChecked"/> as <see cref="QueryResultTopicViewModel.IsExpanded"/>.
218+
/// </summary>
219+
/// <remarks>
220+
/// This will automatically be set to true if <see cref="MarkRelated"/> is set to true.
221+
/// </remarks>
222+
public bool ExpandRelated {
223+
get => (MarkRelated && _expandRelated);
224+
set => _expandRelated = value;
225+
}
226+
210227
/*==========================================================================================================================
211228
| RELATED TOPIC ID
212229
\-------------------------------------------------------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)