Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Canvas module #219

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<ProjectReference Include="..\StatCan.OrchardCore.Security\StatCan.OrchardCore.Security.csproj" PrivateAssets="none" />

<!-- Modules -->
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.Canvas\StatCan.OrchardCore.Canvas.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.CommonTypes\StatCan.OrchardCore.CommonTypes.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.ContentFields\StatCan.OrchardCore.ContentFields.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.DisplayHelpers\StatCan.OrchardCore.DisplayHelpers.csproj" PrivateAssets="none" />
Expand Down
7 changes: 7 additions & 0 deletions src/Modules/StatCan.OrchardCore.Canvas/FeatureIds.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace StatCan.OrchardCore.Canvas
{
public static class FeatureIds
{
public const string Canvas = "StatCan.OrchardCore.Canvas";
}
}
21 changes: 21 additions & 0 deletions src/Modules/StatCan.OrchardCore.Canvas/Manifest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using OrchardCore.Modules.Manifest;
using static StatCan.OrchardCore.Canvas.FeatureIds;

[assembly: Module(
Name = "StatCan Canvas",
Author = "Digital Innovation Team",
Website = "https://digital.statcan.gc.ca",
Version = "1.0.0"
)]

[assembly: Feature(
Id = Canvas,
Name = "StatCan.Canvas - Widgets",
Category = "Content",
Description = "Adds a widget used to create Business and Client Canvas.",
Dependencies = new[]
{
"OrchardCore.Widgets",

}
)]
85 changes: 85 additions & 0 deletions src/Modules/StatCan.OrchardCore.Canvas/Migrations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using OrchardCore.ContentFields.Settings;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.Data.Migration;


namespace StatCan.OrchardCore.Canvas
{
public class Migrations : DataMigration
{
private readonly IContentDefinitionManager _contentDefinitionManager;
public Migrations(IContentDefinitionManager contentDefinitionManager)
{
_contentDefinitionManager = contentDefinitionManager;
}

public int Create()
{
CreateCanvas();
return 1;
}

private void CreateCanvas() {
_contentDefinitionManager.AlterTypeDefinition("Canvas", type => type
.DisplayedAs("Canvas")
.Stereotype("Widget")
.WithPart("Canvas", part => part
.WithPosition("0")
)
);

_contentDefinitionManager.AlterPartDefinition("Canvas", part => part
.WithField("CanvasType", field => field
.OfType("TextField")
.WithDisplayName("CanvasType")
.WithEditor("PredefinedList")
.WithPosition("0")
.WithSettings(new TextFieldSettings
{
Hint = "Choose from the following options",
Required = true,
})
.WithSettings(new TextFieldPredefinedListEditorSettings
{
Options = new ListValueOption[] {
new ListValueOption() {
Name="Business",
Value="business"
},
new ListValueOption() {
Name="Client",
Value="client"
},
new ListValueOption() {
Name="Community",
Value="community"
}
},
})
)
.WithField("Data", field => field
.OfType("TextField")
.WithDisplayName("Data")
.WithEditor("CodeMirror")
.WithPosition("2")
.WithSettings(new TextFieldSettings
{
Hint = "Enter the json for the data.",
Required = true,
})
)
.WithField("Colour", field => field
.OfType("TextField")
.WithDisplayName("Colour")
.WithEditor("Color")
.WithPosition("1")
.WithSettings(new TextFieldSettings
{
Hint = "Select a colour to match the website's theme",
})
)
);
}
}
}
108 changes: 108 additions & 0 deletions src/Modules/StatCan.OrchardCore.Canvas/Recipes/Canvas.recipe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"name": "Canvas",
"displayName": "Canvas",
"description": "Creates a Business or Client Canvas.",
"author": "StatCan Digital Innovation",
"website": "digital.statcan.gc.ca",
"version": "1.0.0",
"issetuprecipe": false,
"categories": [],
"tags": [],
"steps": [
{
"name": "ContentDefinition",
"ContentTypes": [
{
"Name": "Canvas",
"DisplayName": "Canvas",
"Settings": {
"ContentTypeSettings": {
"Creatable": true,
"Listable": true,
"Stereotype": "Widget"
}
},
"ContentTypePartDefinitionRecords": [
{
"PartName": "Canvas",
"Name": "Canvas",
"Settings": {
"ContentTypePartSettings": {
"Position": "0"
}
}
}
]
}
],
"ContentParts": [
{
"Name": "Canvas",
"Settings": {},
"ContentPartFieldDefinitionRecords": [
{
"FieldName": "TextField",
"Name": "CanvasType",
"Settings": {
"ContentPartFieldSettings": {
"DisplayName": "CanvasType",
"Editor": "PredefinedList",
"Position": "0"
},
"TextFieldSettings": {
"Hint": "Choose from the following options",
"Required": true
},
"TextFieldPredefinedListEditorSettings": {
"Options": [
{
"name": "Business",
"value": "business"
},
{
"name": "Client",
"value": "client"
},
{
"name": "Community",
"value": "community"
}
]
}
}
},
{
"FieldName": "TextField",
"Name": "Data",
"Settings": {
"ContentPartFieldSettings": {
"DisplayName": "Data",
"Editor": "CodeMirror",
"Position": "2"
},
"TextFieldSettings": {
"Hint": "Enter the json for the data.",
"Required": true
}
}
},
{
"FieldName": "TextField",
"Name": "Colour",
"Settings": {
"ContentPartFieldSettings": {
"DisplayName": "Colour",
"Editor": "Color",
"Position": "1"
},
"TextFieldSettings": {
"Hint": "Select a colour to match the website's theme"
}
}
}
]
}
]
}
]
}
13 changes: 13 additions & 0 deletions src/Modules/StatCan.OrchardCore.Canvas/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;
using OrchardCore.ResourceManagement;
using OrchardCore.Data.Migration;

namespace StatCan.OrchardCore.Canvas
{
[Feature(FeatureIds.Canvas)]
public class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection serviceCollection) => serviceCollection.AddScoped<IDataMigration, Migrations>();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>$(AspNetCoreTargetFramework)</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**</DefaultItemExcludes>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.ContentManagement" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.Contents" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="$(OrchardCoreVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Lib\StatCan.OrchardCore.Extensions\StatCan.OrchardCore.Extensions.csproj" />
</ItemGroup>

</Project>
Loading