Skip to content

Commit ebfcaad

Browse files
committed
Merge branch 'maintenance/ViewModels-deprecate-placeholders' into develop
The `List` content type is implicitly created as a container for nested topics in the topic graph, and is not expected to mapped directly. Collections on view models that correspond to a nested topic `List` are automatically mapped to its children, without mapping the `List` itself. Instead, the `List` content type was exclusively introduced to support the OnTopic Editor's `QueryableAttributeDescriptor.BaseTopic` property, so that a nested topic list could be referenced as the source for e.g. a `TopicListAttributeDescriptor`, thus allowing the editor to display dropdown boxes. This functionality can now be better served by the new `[MapAs()]` attribute (#41). This not only eliminates the need for this placeholder, but also allows binding to any arbitrary content type, even if there's not a view model associated with it. This will be implemented in OnTopic Editor 5.1.0, as tracked in OnTopicCMS/OnTopic-Editor-AspNetCore#29. In anticipation of that, this placeholder is being marked as obsolete.
2 parents 4e9ec50 + 8c24e7a commit ebfcaad

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

OnTopic.ViewModels/TopicViewModelLookupService.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,18 @@ public TopicViewModelLookupService(IEnumerable<Type>? types = null) : base(types
5050
\-----------------------------------------------------------------------------------------------------------------------*/
5151
TryAdd(typeof(ItemTopicViewModel));
5252
TryAdd(typeof(ContentItemTopicViewModel));
53-
TryAdd(typeof(ListTopicViewModel));
5453
TryAdd(typeof(LookupListItemTopicViewModel));
5554
TryAdd(typeof(SlideTopicViewModel));
5655

56+
/*------------------------------------------------------------------------------------------------------------------------
57+
| Add obsolete types
58+
>-------------------------------------------------------------------------------------------------------------------------
59+
| These will be removed in the next major version of OnTopic.
60+
\-----------------------------------------------------------------------------------------------------------------------*/
61+
#pragma warning disable CS0618 // Type or member is obsolete
62+
TryAdd(typeof(ListTopicViewModel));
63+
#pragma warning restore CS0618 // Type or member is obsolete
64+
5765
/*------------------------------------------------------------------------------------------------------------------------
5866
| Add support types
5967
\-----------------------------------------------------------------------------------------------------------------------*/

OnTopic.ViewModels/_items/ListTopicViewModel.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
| Client Ignia, LLC
44
| Project Topics Library
55
\=============================================================================================================================*/
6+
using System;
67
using System.Collections;
78

89
namespace OnTopic.ViewModels {
@@ -26,6 +27,11 @@ namespace OnTopic.ViewModels {
2627
/// are supplied for convenience to model factory default settings for out-of-the-box content types.
2728
/// </para>
2829
/// </remarks>
30+
[Obsolete(
31+
"There should not be a need for a LookupListItem view model. If these must be referenced, prefer using e.g. [MapAs()] " +
32+
"to specify a common view model.",
33+
false
34+
)]
2935
public record ListTopicViewModel: ContentItemTopicViewModel {
3036

3137
} //Class

0 commit comments

Comments
 (0)