Skip to content
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 @@ -24,6 +24,7 @@
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.LocalizedText\StatCan.OrchardCore.LocalizedText.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.Matomo\StatCan.OrchardCore.Matomo.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.Scripting\StatCan.OrchardCore.Scripting.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.Tabulator\StatCan.OrchardCore.TableCreator.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.VueForms\StatCan.OrchardCore.VueForms.csproj" PrivateAssets="none" />

<!-- Included OpenSource Extensions -->
Expand Down
7 changes: 7 additions & 0 deletions src/Modules/StatCan.OrchardCore.Tabulator/FeatureIds.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace StatCan.OrchardCore.Tabulator
{
public static class FeatureIds
{
public const string Tabulator = "StatCan.OrchardCore.Tabulator";
}
}
21 changes: 21 additions & 0 deletions src/Modules/StatCan.OrchardCore.Tabulator/Manifest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using OrchardCore.Modules.Manifest;
using static StatCan.OrchardCore.Tabulator.FeatureIds;

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

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

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

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

public int Create()
{
TableCreator();
return 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required ? It is not doing anything

}

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

_contentDefinitionManager.AlterPartDefinition("TableCreator", part => part
.WithField("TableData", field => field
.OfType("TextField")
.WithDisplayName("TableData")
.WithPosition("0")
.WithSettings(new TextFieldSettings
{
Hint = "Enter JSON for Table Data here",
Required = true,
})
)
.WithField("ColumnsData", field => field
.OfType("TextField")
.WithDisplayName("ColumnsData")
.WithPosition("1")
.WithSettings(new TextFieldSettings
{
Hint = "To specify the column headers, enter the JSON for the columns here. If using the AutoColumnizer feature, enter an empty set of quotation marks. Eg. \"\".",
Required = true,
})
)
.WithField("AutoColumnizer", field => field
.OfType("TextField")
.WithDisplayName("AutoColumnizer")
.WithPosition("2")
.WithSettings(new TextFieldSettings
{
Hint = "Enter \"true\" to automatically set the columns as per the TableData. Enter \"false\" to set the columns as per the json in the ColumnsData field.",
})
)
.WithField("PaginationSize", field => field
.OfType("NumericField")
.WithDisplayName("PaginationSize")
.WithPosition("2")
.WithSettings(new NumericFieldSettings
{
Hint = "Enter the number of rows to be displayed per page. For example, entering \"5\" will display 5 rows per page.",
Minimum = 1,
Maximum = 100,
})
)
);
}




}
}
13 changes: 13 additions & 0 deletions src/Modules/StatCan.OrchardCore.Tabulator/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.Tabulator
{
[Feature(FeatureIds.Tabulator)]
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% style name:"styles", src:"https://unpkg.com/tabulator-tables@4.9.3/dist/css/tabulator.min.css" %}
{% script name:"tabulator", src:"https://unpkg.com/tabulator-tables@4.9.3/dist/js/tabulator.min.js", at:"Foot" %}

<div id="tabulator-table" style="display:inline-block;width:100%;"></div>
{% block "script", at: "Foot", depends-on: "tabulator"%}

var table = new Tabulator("#tabulator-table", {
height: "100%",
layout: "fitColumns", //columns will fill the width of the container
pagination: "local", //local pagination
tooltips: true, //displays on hover text

data: {{Model.ContentItem.Content.TableCreator.TableData.Text | raw}},
columns: {{Model.ContentItem.Content.TableCreator.ColumnsData.Text | raw}},
autoColumns: {{Model.ContentItem.Content.TableCreator.AutoColumnizer.Text | raw}},
paginationSize: {{Model.ContentItem.Content.TableCreator.PaginationSize.Value | raw}},
});

{% endblock %}
5 changes: 4 additions & 1 deletion src/Themes/BootstrapTheme/Views/Layout.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout.liquid can be deleted. These are base templates for a theme and they're not needed for a module.

<head>
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">


<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script>
<script src="https://unpkg.com/survey-knockout@1.8.20/survey.ko.min.js"></script>
<link href="https://unpkg.com/survey-knockout@1.8.20/modern.css" type="text/css" rel="stylesheet"/>

{{ "ThemeResources" | shape_new | shape_render }}
{% resources type: "Meta" %}
Expand Down
Loading