Skip to content

Commit dc6afa6

Browse files
committed
Merge branch 'bugfix/AttributeDictionary-constructors' into develop
Picked up a few gaps from the original `AttributeDictionary` constructors (e3a1b7), such as a missing property assignment, and an attribute view model without a `AttributeDictionary` constructor. Additionally provided some minor cleanup, such as removing empty constructors where they aren't needed, removing some extraneous comment headers, and fixing some alignment issues in the code.
2 parents d3b141a + 35ca7f5 commit dc6afa6

8 files changed

Lines changed: 30 additions & 28 deletions

File tree

OnTopic.Editor.AspNetCore.Attributes/MetadataListAttribute/MetadataListAttributeDescriptorViewModel.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ public MetadataListAttributeDescriptorViewModel(AttributeDictionary attributes):
3030
/// Initializes a new instance of a <see cref="MetadataListAttributeDescriptorViewModel"/>
3131
/// </summary>
3232
public MetadataListAttributeDescriptorViewModel(): base() {
33-
34-
/*------------------------------------------------------------------------------------------------------------------------
35-
| Customize values
36-
\-----------------------------------------------------------------------------------------------------------------------*/
3733
RelativeTopicPath = "LookupList";
38-
3934
}
4035

4136
} //Class

OnTopic.Editor.AspNetCore.Attributes/NumberAttribute/NumberAttributeDescriptorViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public record NumberAttributeDescriptorViewModel: AttributeDescriptorViewModel {
2525
public NumberAttributeDescriptorViewModel(AttributeDictionary attributes): base(attributes) {
2626
Contract.Requires(attributes, nameof(attributes));
2727
MinimumValue = attributes.GetInteger(nameof(MinimumValue))?? MinimumValue;
28+
MaximumValue = attributes.GetInteger(nameof(MaximumValue))?? MaximumValue;
2829
}
2930

3031
/// <summary>

OnTopic.Editor.AspNetCore.Attributes/RelationshipAttribute/RelationshipAttributeDescriptorViewModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,33 @@ public record RelationshipAttributeDescriptorViewModel: QueryableTopicListAttrib
1818
/*==========================================================================================================================
1919
| CONSTRUCTOR
2020
\-------------------------------------------------------------------------------------------------------------------------*/
21+
/// <summary>
22+
/// Initializes a new <see cref="RelationshipAttributeDescriptorViewModel"/> with an <paramref name="attributes"/> dictionary.
23+
/// </summary>
24+
/// <param name="attributes">An <see cref="AttributeDictionary"/> of attribute values.</param>
25+
public RelationshipAttributeDescriptorViewModel(AttributeDictionary attributes): base(attributes) {
26+
Contract.Requires(attributes, nameof(attributes));
27+
ShowRoot = attributes.GetBoolean(nameof(ShowRoot));
28+
ExpandRelated = attributes.GetBoolean(nameof(ExpandRelated));
29+
CheckAscendants = attributes.GetBoolean(nameof(CheckAscendants));
30+
RegisterResources();
31+
}
32+
2133
/// <summary>
2234
/// Initializes a new instance of a <see cref="RelationshipAttributeDescriptorViewModel"/>
2335
/// </summary>
2436
public RelationshipAttributeDescriptorViewModel() {
37+
RegisterResources();
38+
}
39+
40+
/*==========================================================================================================================
41+
| REGISTER RESOURCES
42+
\-------------------------------------------------------------------------------------------------------------------------*/
43+
/// <summary>
44+
/// Derived classes may optionally override this method in order to register resources, as an alternative to setting these
45+
/// in the constructor.
46+
/// </summary>
47+
protected void RegisterResources() {
2548
Scripts.Register(GetNamespacedUri("/Shared/Scripts/SelectableTreeView.js"));
2649
}
2750

OnTopic.Editor.AspNetCore.Attributes/TopicListAttribute/TopicListAttributeDescriptorViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public TopicListAttributeDescriptorViewModel(AttributeDictionary attributes): ba
2929
DefaultLabel = attributes.GetValue(nameof(DefaultLabel))?? DefaultLabel;
3030
RelativeTopicBase = attributes.GetValue(nameof(RelativeTopicBase));
3131
RelativeTopicPath = attributes.GetValue(nameof(RelativeTopicPath));
32-
ValueProperty = attributes.GetValue(nameof(ValueProperty))?? ValueProperty;
32+
ValueProperty = attributes.GetValue(nameof(ValueProperty))?? ValueProperty;
3333
}
3434

3535
/// <summary>

OnTopic.Editor.AspNetCore.Attributes/TopicReferenceAttribute/TopicReferenceAttributeDescriptorViewModel.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,7 @@ public TopicReferenceAttributeDescriptorViewModel(AttributeDictionary attributes
3333
/// Initializes a new instance of a <see cref="TopicReferenceAttributeDescriptorViewModel"/>
3434
/// </summary>
3535
public TopicReferenceAttributeDescriptorViewModel(): base() {
36-
37-
/*------------------------------------------------------------------------------------------------------------------------
38-
| Restrict token limit
39-
\-----------------------------------------------------------------------------------------------------------------------*/
40-
TokenLimit = 1;
41-
36+
TokenLimit = 1;
4237
}
4338

4439
/*==========================================================================================================================

OnTopic.Editor.AspNetCore/Models/Components/ContentTypeListViewModel.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ namespace OnTopic.Editor.AspNetCore.Models.Components {
1515
/// </summary>
1616
public record ContentTypeListViewModel {
1717

18-
/*==========================================================================================================================
19-
| CONSTRUCTOR
20-
\-------------------------------------------------------------------------------------------------------------------------*/
21-
/// <summary>
22-
/// Initializes a new instance of the <see cref="ContentTypeListViewModel"/> class.
23-
/// </summary>
24-
public ContentTypeListViewModel() { }
25-
2618
/*==========================================================================================================================
2719
| PROPERTY: CURRENT TOPIC
2820
\-------------------------------------------------------------------------------------------------------------------------*/

OnTopic.Editor.AspNetCore/Models/Metadata/AttributeDescriptorViewModel.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.ComponentModel.DataAnnotations;
77
using OnTopic.Attributes;
88
using OnTopic.Editor.AspNetCore.Models.ClientResources;
9+
using OnTopic.Mapping.Annotations;
910

1011
namespace OnTopic.Editor.AspNetCore.Models.Metadata {
1112

@@ -145,6 +146,7 @@ public AttributeDescriptorViewModel(): base() { }
145146
/// This is kept separate from <see cref="IsRequired"/> so that the attribute labels can still be marked as required in
146147
/// the interface; this should be used to disable <c>required</c> on the associated <c>Value</c> field, however.
147148
/// </remarks>
149+
[DisableMapping]
148150
public bool IsValueRequired => IsRequired && String.IsNullOrEmpty(DefaultValue);
149151

150152
/*==========================================================================================================================
@@ -169,6 +171,7 @@ public AttributeDescriptorViewModel(): base() { }
169171
/// <summary>
170172
/// Provides a list of client-side stylesheets associated with this <see cref="AttributeDescriptorViewModel"/>.
171173
/// </summary>
174+
[DisableMapping]
172175
public StyleSheetCollection StyleSheets { get; } = new();
173176

174177
/*==========================================================================================================================
@@ -177,6 +180,7 @@ public AttributeDescriptorViewModel(): base() { }
177180
/// <summary>
178181
/// Provides a list of client-side scripts associated with this <see cref="AttributeDescriptorViewModel"/>.
179182
/// </summary>
183+
[DisableMapping]
180184
public ScriptCollection Scripts { get; } = new();
181185

182186
/*==========================================================================================================================

OnTopic.Editor.AspNetCore/Models/Metadata/PermittedContentTypeViewModel.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@ namespace OnTopic.Editor.AspNetCore.Models.Metadata {
1717
/// </summary>
1818
public record PermittedContentTypeViewModel {
1919

20-
/*==========================================================================================================================
21-
| CONSTRUCTOR
22-
\-------------------------------------------------------------------------------------------------------------------------*/
23-
/// <summary>
24-
/// Initializes a new instance of the <see cref="PermittedContentTypeViewModel"/> class.
25-
/// </summary>
26-
public PermittedContentTypeViewModel(): base() {}
27-
2820
/*==========================================================================================================================
2921
| PROPERTY: KEY
3022
\-------------------------------------------------------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)