Skip to content

Commit 3b468d3

Browse files
committed
Merge branch 'release/5.1.0' into master
OnTopic Editor 5.1.0 is a minor release which introduces the new `MetadataList` (#30) and `Reflexive` (#44) attributes, which primarily aid in the Ouroboros Configuration. Primarily, however, it is focused on bug fixes, and resolves a number of priority issues, such as the inability to rollback recent versions (#18), `TopicList` not displaying more than 100 records (#16), inability to find topics with a `key` but not a `Title` (#15), and the inability to bind to topic references that didn't have a corresponding model (#29). Finally, it also includes a number of improvements, such as an upgrade to Boostrap 5.0.0 Beta 3 (#41), sorting the `DisplayGroup`s more intelligently (#33), displaying inferred values for `Boolean` and `TopicList` attributes (#26), and making the `AttributeBindingModel` optional for attribute type plugins (#42). For a full rollup of new features, improvements, and bug fixes, see Pull Request #46.
2 parents 4d0e5a4 + c96b750 commit 3b468d3

91 files changed

Lines changed: 12535 additions & 16064 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<RepositoryType>git</RepositoryType>
2121
<NeutralLanguage>en</NeutralLanguage>
2222
<IncludeSymbols>true</IncludeSymbols>
23+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2324
<EmbedUntrackedSources>true</EmbedUntrackedSources>
2425
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2526
<PackageIcon>Icon.png</PackageIcon>

OnTopic.Editor.AspNetCore.All/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# OnTopic Editor Metapackage
22
The `OnTopic.Editor.AspNetCore.All` metapackage includes a reference to both the core OnTopic Editor as well as all standard attribute type plugins. It is recommended that implementers reference this package instead of referencing each of the OnTopic Editor packages individually, unless they have a specific need to customize e.g. which attribute plugins are referenced.
33

4-
[![OnTopic.Editor.AspNetCore package in Internal feed in Azure Artifacts](https://igniasoftware.feeds.visualstudio.com/_apis/public/Packaging/Feeds/46d5f49c-5e1e-47bb-8b14-43be6c719ba8/Packages/682244bf-1062-48de-949e-16f9cb11a6cf/Badge)](https://igniasoftware.visualstudio.com/OnTopic/_packaging?_a=package&feed=46d5f49c-5e1e-47bb-8b14-43be6c719ba8&package=682244bf-1062-48de-949e-16f9cb11a6cf&preferRelease=true)
4+
[![OnTopic.Editor.AspNetCore.All package in Internal feed in Azure Artifacts](https://igniasoftware.feeds.visualstudio.com/_apis/public/Packaging/Feeds/46d5f49c-5e1e-47bb-8b14-43be6c719ba8/Packages/faa44518-dd61-4e2c-8904-b2aecbbf70e5/Badge)](https://www.nuget.org/packages/OnTopic.Editor.AspNetCore.All/)
55
[![Build Status](https://igniasoftware.visualstudio.com/OnTopic/_apis/build/status/OnTopic-Editor-CI-V1?branchName=master)](https://igniasoftware.visualstudio.com/OnTopic/_build/latest?definitionId=8&branchName=master)
66
![NuGet Deployment Status](https://rmsprodscussu1.vsrm.visualstudio.com/A09668467-721c-4517-8d2e-aedbe2a7d67f/_apis/public/Release/badge/bd7f03e0-6fcf-4ec6-939d-4e995668d40f/2/2)
77

@@ -23,6 +23,4 @@ Installation can be performed by providing a `<PackageReference /`> to the `OnTo
2323
<PackageReference Include="OnTopic.Editor.AspNetCore.All" Version="5.0.0" />
2424
</ItemGroup>
2525
</Project>
26-
```
27-
28-
> *Note:* This package is currently only available on Ignia's private **NuGet** repository. For access, please contact [Ignia](http://www.ignia.com/).
26+
```

OnTopic.Editor.AspNetCore.Attributes/BooleanAttribute/BooleanAttributeViewModel.cs

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
| Project Topics Library
55
\=============================================================================================================================*/
66
using System;
7+
using System.Diagnostics.CodeAnalysis;
78
using OnTopic.Editor.AspNetCore.Models;
89
using OnTopic.Editor.AspNetCore.Models.Metadata;
910

@@ -44,10 +45,7 @@ public BooleanAttributeViewModel(
4445
/// Determines whether the value is explicitly set to true.
4546
/// </summary>
4647
public bool? IsTrue() {
47-
if (
48-
(Value?.Equals("1", StringComparison.OrdinalIgnoreCase)?? false) ||
49-
(Value?.Equals("true", StringComparison.OrdinalIgnoreCase)?? false)
50-
) {
48+
if (IsBoolean(Value, out var value) && value.Value) {
5149
return true;
5250
}
5351
return null;
@@ -60,15 +58,72 @@ public BooleanAttributeViewModel(
6058
/// Determines whether value is explicitly set to false.
6159
/// </summary>
6260
public bool? IsFalse() {
61+
if (IsBoolean(Value, out var value) && !value.Value) {
62+
return true;
63+
}
64+
return null;
65+
}
66+
67+
/*==========================================================================================================================
68+
| IS BOOLEAN?
69+
\-------------------------------------------------------------------------------------------------------------------------*/
70+
/// <summary>
71+
/// Determines if the <paramref name="input"/> is a <see cref="Boolean"/>. If it is, converts it to a <see cref="Boolean"
72+
/// /> via the <paramref name="value"/>.
73+
/// </summary>
74+
public static bool IsBoolean(string? input, [NotNullWhen(true)] out bool? value) {
75+
value = null;
76+
if (String.IsNullOrEmpty(input)) {
77+
return false;
78+
}
6379
if (
64-
(Value?.Equals("0", StringComparison.OrdinalIgnoreCase) ?? false) ||
65-
(Value?.Equals("false", StringComparison.OrdinalIgnoreCase) ?? false)
80+
input.Equals("1", StringComparison.OrdinalIgnoreCase) ||
81+
input.Equals("true", StringComparison.OrdinalIgnoreCase)
6682
) {
67-
return false;
83+
value = true;
84+
return true;
6885
}
69-
return null;
86+
if (
87+
input.Equals("0", StringComparison.OrdinalIgnoreCase) ||
88+
input.Equals("false", StringComparison.OrdinalIgnoreCase)
89+
) {
90+
value = false;
91+
return true;
92+
}
93+
return false;
7094
}
7195

96+
/*==========================================================================================================================
97+
| IS VALUE INFERRED?
98+
\-------------------------------------------------------------------------------------------------------------------------*/
99+
/// <summary>
100+
/// Determines whether the value is explicitly set to .
101+
/// </summary>
102+
public bool IsValueInferred([NotNullWhen(true)] out bool? value, out string? source) {
103+
104+
/*------------------------------------------------------------------------------------------------------------------------
105+
| Determine source
106+
\-----------------------------------------------------------------------------------------------------------------------*/
107+
source = null;
108+
109+
if (IsBoolean(AttributeDescriptor.DefaultValue, out value)) {
110+
if (!IsBoolean(Value, out _)) {
111+
source = "default value";
112+
}
113+
}
114+
else if (IsBoolean(AttributeDescriptor.ImplicitValue, out value)) {
115+
source = "implicit value";
116+
}
117+
else if (IsBoolean(InheritedValue, out value)) {
118+
source = "inherited value";
119+
}
120+
121+
/*------------------------------------------------------------------------------------------------------------------------
122+
| Handle default
123+
\-----------------------------------------------------------------------------------------------------------------------*/
124+
return source is not null;
125+
126+
}
72127

73128
} // Class
74129
} // Namespace

OnTopic.Editor.AspNetCore.Attributes/FileListAttribute/FileListAttributeBindingModel.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

OnTopic.Editor.AspNetCore.Attributes/FileListAttribute/FileListAttributeViewModel.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
\=============================================================================================================================*/
66
using System.Collections.ObjectModel;
77
using System.ComponentModel.DataAnnotations;
8-
using System.Diagnostics.CodeAnalysis;
98
using Microsoft.AspNetCore.Mvc.Rendering;
109
using OnTopic.Editor.AspNetCore.Models;
1110
using OnTopic.Editor.AspNetCore.Models.Metadata;
@@ -62,8 +61,8 @@ public FileListAttributeViewModel(
6261
/// While the <i>relative</i> file path can be retrieved from <see cref="FileListAttributeDescriptorViewModel.Path"
6362
/// />, that doesn't include the base path of the web application. The <see cref="AbsolutePath"/> addresses this.
6463
/// </remarks>
65-
[Required, NotNull, DisallowNull]
66-
public string? AbsolutePath { get; set; }
64+
[Required]
65+
public string AbsolutePath { get; set; } = default!;
6766

6867
} // Class
6968
} // Namespace

OnTopic.Editor.AspNetCore.Attributes/FileListAttribute/FileListViewComponent.cs

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ string htmlFieldPrefix
6363
/*------------------------------------------------------------------------------------------------------------------------
6464
| Establish view model
6565
\-----------------------------------------------------------------------------------------------------------------------*/
66-
var model = new FileListAttributeViewModel(currentTopic, attribute);
66+
var model = new FileListAttributeViewModel(currentTopic, attribute) {
67+
AbsolutePath = _webHostEnvironment.ContentRootPath + attribute.Path
68+
};
6769

6870
/*------------------------------------------------------------------------------------------------------------------------
6971
| Set model values
7072
\-----------------------------------------------------------------------------------------------------------------------*/
71-
foreach (var file in GetFiles(model.InheritedValue, attribute, model.AbsolutePath)) {
73+
foreach (var file in GetFiles(model)) {
7274
model.Files.Add(file);
7375
};
74-
model.AbsolutePath = _webHostEnvironment.ContentRootPath + attribute.Path;
7576

7677
/*------------------------------------------------------------------------------------------------------------------------
7778
| Return view with view model
@@ -86,20 +87,18 @@ string htmlFieldPrefix
8687
/// <summary>
8788
/// Retrieves a collection of files in a directory, given the provided <see cref="Path"/>.
8889
/// </summary>
89-
public static Collection<SelectListItem> GetFiles(
90-
string? inheritedValue,
91-
FileListAttributeDescriptorViewModel attribute,
92-
string absolutePath
93-
) {
90+
public static Collection<SelectListItem> GetFiles(FileListAttributeViewModel viewModel) {
9491

9592
/*------------------------------------------------------------------------------------------------------------------------
9693
| Validate parameters
9794
\-----------------------------------------------------------------------------------------------------------------------*/
98-
Contract.Requires(attribute, nameof(attribute));
95+
Contract.Requires(viewModel, nameof(viewModel));
9996

10097
/*------------------------------------------------------------------------------------------------------------------------
10198
| INSTANTIATE OBJECTS
10299
\-----------------------------------------------------------------------------------------------------------------------*/
100+
var attribute = viewModel.AttributeDescriptor;
101+
var absolutePath = viewModel.AbsolutePath;
103102
var files = new Collection<SelectListItem>();
104103
var searchPattern = "*";
105104
var searchOption = attribute.IncludeSubdirectories is true? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
@@ -129,9 +128,22 @@ string absolutePath
129128
\-----------------------------------------------------------------------------------------------------------------------*/
130129
var foundFiles = Directory.GetFiles(absolutePath, searchPattern, searchOption);
131130

132-
if (!String.IsNullOrEmpty(inheritedValue)) {
133-
files.Add(new("", inheritedValue));
131+
/*------------------------------------------------------------------------------------------------------------------------
132+
| Set label
133+
\-----------------------------------------------------------------------------------------------------------------------*/
134+
if (!String.IsNullOrEmpty(viewModel.InheritedValue)) {
135+
setLabel(viewModel.InheritedValue, "inherited value");
136+
}
137+
else if (!String.IsNullOrEmpty(viewModel.AttributeDescriptor.DefaultValue)) {
138+
setLabel(viewModel.AttributeDescriptor.DefaultValue, "default value");
134139
}
140+
else if (!String.IsNullOrEmpty(viewModel.AttributeDescriptor.ImplicitValue)) {
141+
setLabel(viewModel.AttributeDescriptor.ImplicitValue, "implicit default");
142+
}
143+
else {
144+
setLabel("Select a file…");
145+
}
146+
135147
foreach (var foundFile in foundFiles) {
136148
var fileName = foundFile.Replace(absolutePath, "", StringComparison.OrdinalIgnoreCase);
137149
var fileNameKey = fileName.Replace("." + attribute.Extension, "", StringComparison.OrdinalIgnoreCase);
@@ -143,6 +155,22 @@ string absolutePath
143155
\-----------------------------------------------------------------------------------------------------------------------*/
144156
return files;
145157

158+
/*------------------------------------------------------------------------------------------------------------------------
159+
| Function: Set Label
160+
\-----------------------------------------------------------------------------------------------------------------------*/
161+
void setLabel(string value, string? contextualLabel = null) {
162+
var label = value;
163+
if (contextualLabel is not null) {
164+
label += " (" + contextualLabel + ")";
165+
}
166+
viewModel.Files.Add(
167+
new() {
168+
Value = "",
169+
Text = label
170+
}
171+
);
172+
}
173+
146174
}
147175

148176
} // Class

OnTopic.Editor.AspNetCore.Attributes/FilePathAttribute/FilePathAttributeBindingModel.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

OnTopic.Editor.AspNetCore.Attributes/HtmlAttribute/HtmlAttributeBindingModel.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)