-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTopicQueryOptions.cs
More file actions
249 lines (226 loc) · 11.7 KB
/
TopicQueryOptions.cs
File metadata and controls
249 lines (226 loc) · 11.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/*==============================================================================================================================
| Author Ignia, LLC
| Client Ignia, LLC
| Project Topics Library
\=============================================================================================================================*/
namespace OnTopic.Editor.AspNetCore.Models.Queryable {
/*============================================================================================================================
| CLASS: TOPIC QUERY OPTIONS
\---------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Establishes options for the <see cref="TopicQueryService"/> class.
/// </summary>
public record TopicQueryOptions {
/*==========================================================================================================================
| PRIVATE VARIABLES
\-------------------------------------------------------------------------------------------------------------------------*/
bool _markRelated;
bool _expandRelated = true;
bool _showCheckboxes;
/*==========================================================================================================================
| CONSTRUCTOR
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Initializes a new instance of the <see cref="TopicQueryOptions"/> class.
/// </summary>
public TopicQueryOptions() {
/*--------------------------------------------------------------------------------------------------------------------------
| Set default values
\-------------------------------------------------------------------------------------------------------------------------*/
ShowRoot = false;
ShowAll = true;
UseKeyAsText = false;
IsRecursive = true;
FlattenStructure = false;
ShowNestedTopics = false;
UsePartialMatch = false;
ResultLimit = -1;
AttributeName = null;
AttributeValue = null;
Query = null;
MarkRelated = false;
ExpandRelated = true;
RelatedTopicId = -1;
RelatedNamespace = null;
EnableCheckboxes = false;
}
/*==========================================================================================================================
| SHOW ROOT
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determine whether or not the root passed should be displayed in the tree view, or if it should only display children.
/// </summary>
public bool ShowRoot {
get;
init;
}
/*==========================================================================================================================
| SHOW ALL
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determine whether or not hidden and inactive children should be displayed; typically used exclusively for the editor.
/// </summary>
public bool ShowAll {
get;
init;
}
/*==========================================================================================================================
| USE KEY AS TEXT
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determines if the name should be displayed using the Title (if available) or the Key. Defaults to Title.
/// </summary>
public bool UseKeyAsText {
get;
init;
}
/*==========================================================================================================================
| IS RECURSIVE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determine whether grandchildren of the RootTopic should be displayed, or whether the tree should only show one tier of
/// Topics. Defaults to recursive.
/// </summary>
public bool IsRecursive {
get;
init;
}
/*==========================================================================================================================
| FLATTEN STRUCTURE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determine whether all Topics should be added to the output at the same (top) level, or whether sub-tiers of Topics
/// should be added to the output under a "children" array (of the parent).
/// </summary>
public bool FlattenStructure {
get;
init;
}
/*==========================================================================================================================
| SHOW NESTED TOPICS
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determine whether or not nested topics (i.e., topics within List ContentTypes) should be displayed or not. By default,
/// it is assumed that they should not be displayed.
/// </summary>
public bool ShowNestedTopics {
get;
init;
}
/*==========================================================================================================================
| USE PARTIAL MATCH
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// If set, changes the FilterChildren query to find Topics based on a partial match against the specified AttributeName's
/// AttributeValue, if both are present; otherwise, the query returns only exact matches.
/// </summary>
public bool UsePartialMatch {
get;
init;
}
/*==========================================================================================================================
| RESULT LIMIT
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// If set, should limit the number of Topics loaded/output to the JSON. Includes setter in order to be decremented along
/// with resultLimit in AddNodeToOutput().
/// </summary>
public int ResultLimit {
get;
init;
}
/*==========================================================================================================================
| ATTRIBUTE NAME
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// May optionally filter out topics based on attribute values; if so, this property defines the attribute name.
/// </summary>
public string? AttributeName {
get;
init;
}
/*==========================================================================================================================
| ATTRIBUTE VALUE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// May optionally filter out topics based on attribute values; if so, this property defines the attribute value.
/// </summary>
public string? AttributeValue {
get;
init;
}
/*==========================================================================================================================
| QUERY
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// May optionally filter out topics based on attribute values; if so, this property defines the attribute value.
/// </summary>
public string? Query {
get;
init;
}
/*==========================================================================================================================
| ENABLE CHECKBOXES
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determines whether or not to display checkboxes by including the <see cref="QueryResultTopicViewModel.IsChecked"/> value.
/// </summary>
/// <remarks>
/// This will automatically be set to true is <see cref="MarkRelated"/> is set to <c>true</c>. Otherwise, it defaults to
/// false.
/// </remarks>
public bool EnableCheckboxes {
get => (MarkRelated || _showCheckboxes);
set => _showCheckboxes = value;
}
/*==========================================================================================================================
| MARK RELATED
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determines whether <see cref="QueryResultTopicViewModel"/>s should be marked as <see cref="QueryResultTopicViewModel.
/// IsChecked"/> based on their presence in related topics.
/// </summary>
/// <remarks>
/// This will automatically be set to true if <see cref="RelatedTopicId"/> or <see cref="RelatedNamespace"/> are set. If
/// <see cref="RelatedTopicId"/> is <i>not</i> set, then the current <see cref="Topic"/> should be assumed.
/// </remarks>
public bool MarkRelated {
get => (RelatedTopicId > 0 || !String.IsNullOrEmpty(RelatedNamespace) || _markRelated);
set => _markRelated = value;
}
/*==========================================================================================================================
| EXPAND RELATED
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determines whether <see cref="QueryResultTopicViewModel"/>s should be marked ascendants as nodes marked as <see
/// cref="QueryResultTopicViewModel.IsChecked"/> as <see cref="QueryResultTopicViewModel.IsExpanded"/>.
/// </summary>
/// <remarks>
/// This will automatically be set to true if <see cref="MarkRelated"/> is set to true.
/// </remarks>
public bool ExpandRelated {
get => (MarkRelated && _expandRelated);
set => _expandRelated = value;
}
/*==========================================================================================================================
| RELATED TOPIC ID
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// The identifier of the topic to use to determine if items are marked as checked, based on its relationships.
/// </summary>
public int RelatedTopicId {
get;
init;
}
/*==========================================================================================================================
| RELATED NAMESPACE
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// The name of the relationship scope to use with the <see cref="RelatedTopicId"/>.
/// </summary>
public string? RelatedNamespace {
get;
init;
}
} // Class
} // Namespace