Skip to content

Commit

Permalink
Merge branch 'release/5.1.0' into master
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JeremyCaney committed Apr 12, 2021
2 parents 4d0e5a4 + c96b750 commit 3b468d3
Show file tree
Hide file tree
Showing 91 changed files with 12,535 additions and 16,064 deletions.
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<RepositoryType>git</RepositoryType>
<NeutralLanguage>en</NeutralLanguage>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageIcon>Icon.png</PackageIcon>
Expand Down
6 changes: 2 additions & 4 deletions OnTopic.Editor.AspNetCore.All/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# OnTopic Editor Metapackage
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.

[![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)
[![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/)
[![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)
![NuGet Deployment Status](https://rmsprodscussu1.vsrm.visualstudio.com/A09668467-721c-4517-8d2e-aedbe2a7d67f/_apis/public/Release/badge/bd7f03e0-6fcf-4ec6-939d-4e995668d40f/2/2)

Expand All @@ -23,6 +23,4 @@ Installation can be performed by providing a `<PackageReference /`> to the `OnTo
<PackageReference Include="OnTopic.Editor.AspNetCore.All" Version="5.0.0" />
</ItemGroup>
</Project>
```

> *Note:* This package is currently only available on Ignia's private **NuGet** repository. For access, please contact [Ignia](http://www.ignia.com/).
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
| Project Topics Library
\=============================================================================================================================*/
using System;
using System.Diagnostics.CodeAnalysis;
using OnTopic.Editor.AspNetCore.Models;
using OnTopic.Editor.AspNetCore.Models.Metadata;

Expand Down Expand Up @@ -44,10 +45,7 @@ public BooleanAttributeViewModel(
/// Determines whether the value is explicitly set to true.
/// </summary>
public bool? IsTrue() {
if (
(Value?.Equals("1", StringComparison.OrdinalIgnoreCase)?? false) ||
(Value?.Equals("true", StringComparison.OrdinalIgnoreCase)?? false)
) {
if (IsBoolean(Value, out var value) && value.Value) {
return true;
}
return null;
Expand All @@ -60,15 +58,72 @@ public BooleanAttributeViewModel(
/// Determines whether value is explicitly set to false.
/// </summary>
public bool? IsFalse() {
if (IsBoolean(Value, out var value) && !value.Value) {
return true;
}
return null;
}

/*==========================================================================================================================
| IS BOOLEAN?
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determines if the <paramref name="input"/> is a <see cref="Boolean"/>. If it is, converts it to a <see cref="Boolean"
/// /> via the <paramref name="value"/>.
/// </summary>
public static bool IsBoolean(string? input, [NotNullWhen(true)] out bool? value) {
value = null;
if (String.IsNullOrEmpty(input)) {
return false;
}
if (
(Value?.Equals("0", StringComparison.OrdinalIgnoreCase) ?? false) ||
(Value?.Equals("false", StringComparison.OrdinalIgnoreCase) ?? false)
input.Equals("1", StringComparison.OrdinalIgnoreCase) ||
input.Equals("true", StringComparison.OrdinalIgnoreCase)
) {
return false;
value = true;
return true;
}
return null;
if (
input.Equals("0", StringComparison.OrdinalIgnoreCase) ||
input.Equals("false", StringComparison.OrdinalIgnoreCase)
) {
value = false;
return true;
}
return false;
}

/*==========================================================================================================================
| IS VALUE INFERRED?
\-------------------------------------------------------------------------------------------------------------------------*/
/// <summary>
/// Determines whether the value is explicitly set to .
/// </summary>
public bool IsValueInferred([NotNullWhen(true)] out bool? value, out string? source) {

/*------------------------------------------------------------------------------------------------------------------------
| Determine source
\-----------------------------------------------------------------------------------------------------------------------*/
source = null;

if (IsBoolean(AttributeDescriptor.DefaultValue, out value)) {
if (!IsBoolean(Value, out _)) {
source = "default value";
}
}
else if (IsBoolean(AttributeDescriptor.ImplicitValue, out value)) {
source = "implicit value";
}
else if (IsBoolean(InheritedValue, out value)) {
source = "inherited value";
}

/*------------------------------------------------------------------------------------------------------------------------
| Handle default
\-----------------------------------------------------------------------------------------------------------------------*/
return source is not null;

}

} // Class
} // Namespace

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
\=============================================================================================================================*/
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Mvc.Rendering;
using OnTopic.Editor.AspNetCore.Models;
using OnTopic.Editor.AspNetCore.Models.Metadata;
Expand Down Expand Up @@ -62,8 +61,8 @@ public FileListAttributeViewModel(
/// While the <i>relative</i> file path can be retrieved from <see cref="FileListAttributeDescriptorViewModel.Path"
/// />, that doesn't include the base path of the web application. The <see cref="AbsolutePath"/> addresses this.
/// </remarks>
[Required, NotNull, DisallowNull]
public string? AbsolutePath { get; set; }
[Required]
public string AbsolutePath { get; set; } = default!;

} // Class
} // Namespace
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ string htmlFieldPrefix
/*------------------------------------------------------------------------------------------------------------------------
| Establish view model
\-----------------------------------------------------------------------------------------------------------------------*/
var model = new FileListAttributeViewModel(currentTopic, attribute);
var model = new FileListAttributeViewModel(currentTopic, attribute) {
AbsolutePath = _webHostEnvironment.ContentRootPath + attribute.Path
};

/*------------------------------------------------------------------------------------------------------------------------
| Set model values
\-----------------------------------------------------------------------------------------------------------------------*/
foreach (var file in GetFiles(model.InheritedValue, attribute, model.AbsolutePath)) {
foreach (var file in GetFiles(model)) {
model.Files.Add(file);
};
model.AbsolutePath = _webHostEnvironment.ContentRootPath + attribute.Path;

/*------------------------------------------------------------------------------------------------------------------------
| Return view with view model
Expand All @@ -86,20 +87,18 @@ string htmlFieldPrefix
/// <summary>
/// Retrieves a collection of files in a directory, given the provided <see cref="Path"/>.
/// </summary>
public static Collection<SelectListItem> GetFiles(
string? inheritedValue,
FileListAttributeDescriptorViewModel attribute,
string absolutePath
) {
public static Collection<SelectListItem> GetFiles(FileListAttributeViewModel viewModel) {

/*------------------------------------------------------------------------------------------------------------------------
| Validate parameters
\-----------------------------------------------------------------------------------------------------------------------*/
Contract.Requires(attribute, nameof(attribute));
Contract.Requires(viewModel, nameof(viewModel));

/*------------------------------------------------------------------------------------------------------------------------
| INSTANTIATE OBJECTS
\-----------------------------------------------------------------------------------------------------------------------*/
var attribute = viewModel.AttributeDescriptor;
var absolutePath = viewModel.AbsolutePath;
var files = new Collection<SelectListItem>();
var searchPattern = "*";
var searchOption = attribute.IncludeSubdirectories is true? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
Expand Down Expand Up @@ -129,9 +128,22 @@ string absolutePath
\-----------------------------------------------------------------------------------------------------------------------*/
var foundFiles = Directory.GetFiles(absolutePath, searchPattern, searchOption);

if (!String.IsNullOrEmpty(inheritedValue)) {
files.Add(new("", inheritedValue));
/*------------------------------------------------------------------------------------------------------------------------
| Set label
\-----------------------------------------------------------------------------------------------------------------------*/
if (!String.IsNullOrEmpty(viewModel.InheritedValue)) {
setLabel(viewModel.InheritedValue, "inherited value");
}
else if (!String.IsNullOrEmpty(viewModel.AttributeDescriptor.DefaultValue)) {
setLabel(viewModel.AttributeDescriptor.DefaultValue, "default value");
}
else if (!String.IsNullOrEmpty(viewModel.AttributeDescriptor.ImplicitValue)) {
setLabel(viewModel.AttributeDescriptor.ImplicitValue, "implicit default");
}
else {
setLabel("Select a file…");
}

foreach (var foundFile in foundFiles) {
var fileName = foundFile.Replace(absolutePath, "", StringComparison.OrdinalIgnoreCase);
var fileNameKey = fileName.Replace("." + attribute.Extension, "", StringComparison.OrdinalIgnoreCase);
Expand All @@ -143,6 +155,22 @@ string absolutePath
\-----------------------------------------------------------------------------------------------------------------------*/
return files;

/*------------------------------------------------------------------------------------------------------------------------
| Function: Set Label
\-----------------------------------------------------------------------------------------------------------------------*/
void setLabel(string value, string? contextualLabel = null) {
var label = value;
if (contextualLabel is not null) {
label += " (" + contextualLabel + ")";
}
viewModel.Files.Add(
new() {
Value = "",
Text = label
}
);
}

}

} // Class
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 3b468d3

Please sign in to comment.