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

Tenant List #217

Open
wants to merge 20 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 @@ -27,6 +27,7 @@
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.Matomo\StatCan.OrchardCore.Matomo.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.OpenAPI\StatCan.OrchardCore.OpenAPI.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.Scripting\StatCan.OrchardCore.Scripting.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.Tenant\StatCan.OrchardCore.Tenant.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.Scheduling\StatCan.OrchardCore.Scheduling.csproj" PrivateAssets="none" />
<ProjectReference Include="..\..\Modules\StatCan.OrchardCore.VueForms\StatCan.OrchardCore.VueForms.csproj" PrivateAssets="none" />

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

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

[assembly: Feature(
Id = Tenant,
Name = "StatCan.Tenant - Widgets",
Category = "Content",
Description = "Adds a widget used to display a List of Tenant and its information",
Dependencies = new[]
{
"OrchardCore.Lists",
"OrchardCore.Widgets"
}
)]
83 changes: 83 additions & 0 deletions src/Modules/StatCan.OrchardCore.Tenant/Migrations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using OrchardCore.Autoroute.Models;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.Data.Migration;
using OrchardCore.Lists.Models;
using OrchardCore.Title.Models;

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

public int Create()
{
_contentDefinitionManager.AlterTypeDefinition("Tenant", type => type
.DisplayedAs("Tenant")
.WithPart("Tenant", part => part
.WithPosition("1")
)
.WithPart("TitlePart", part => part
.WithPosition("0")
.WithSettings(new TitlePartSettings
{
Options = TitlePartOptions.GeneratedHidden,
Pattern = "{{ Model.ContentItem.Content.Tenant.Name.Text }}",
})
)
);

_contentDefinitionManager.AlterPartDefinition("Tenant", part => part
.WithField("Poster", field => field
.OfType("MediaField")
.WithDisplayName("Poster")
.WithPosition("0")
)
.WithField("Name", field => field
.OfType("TextField")
.WithDisplayName("Name")
.WithPosition("1")
)
.WithField("Description", field => field
.OfType("TextField")
.WithDisplayName("Short Description")
.WithPosition("2")
)
);

_contentDefinitionManager.AlterTypeDefinition("TenantPage", type => type
.DisplayedAs("Tenant Page")
.Creatable()
.Listable()
.Draftable()
.Versionable()
.Securable()
.WithPart("TenantPage", part => part
.WithPosition("0")
)
.WithPart("ListPart", part => part
.WithPosition("2")
.WithSettings(new ListPartSettings
{
PageSize = 10,
ContainedContentTypes = new[] { "Tenant" },
})
)
.WithPart("AutoroutePart", part => part
.WithPosition("1")
.WithSettings(new AutoroutePartSettings
{
AllowCustomPath = true,
})
)
);

return 1;
}
}
}
13 changes: 13 additions & 0 deletions src/Modules/StatCan.OrchardCore.Tenant/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.Tenant
{
[Feature(FeatureIds.Tenant)]
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,26 @@
<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.Autoroute" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.ContentManagement" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.Contents" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.Lists" Version="$(OrchardCoreVersion)" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="$(OrchardCoreVersion)" />
</ItemGroup>

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

</Project>
36 changes: 36 additions & 0 deletions src/Modules/StatCan.OrchardCore.Tenant/Views/Content-Tenant.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% assign nameLength = Model.ContentItem.Content.Tenant.Link.Text | size %}
{% assign photo = Model.ContentItem.Content.Tenant.Poster.Paths.first | raw %}
{% assign colors = "red pink purple deep-purple indigo blue light-blue cyan teal green light-green lime yellow amber orange deep-orange brown" | split: " " %}
{% assign numColors = colors | size %}
{% assign avatarColorNum = nameLength | modulo: numColors %}
{% assign avatarColor = colors[avatarColorNum] %}
<v-list-item
href="{{ Model.ContentItem.Content.Tenant.Link.Url }}"
color="{{avatarColor}}"
dense
>
<v-list-item-icon>
{% if photo != empty %}
<v-avatar
color="primary"
size="32"
>
<img src="{{ photo | asset_url | resize_url: width:64, height:64, mode:'crop', anchor:anchor }}" />
</v-avatar>
{% else %}
<v-avatar
color="{{ avatarColor }}"
dark
size="32"
>
<span class="white--text text-h6">{{ Model.ContentItem.Content.Tenant.Link.Text | slice: 0 | capitalize }}</span>
</v-avatar>
{% endif %}
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ Model.ContentItem.Content.Tenant.Link.Text }}</v-list-item-title>
<v-list-item-subtitle>{{ Model.ContentItem.Content.Tenant.Description.Text }}</v-list-item-subtitle>
</v-list-item-content>
<v-list-item-action>
</v-list-item-action>
</v-list-item>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<v-list rounded>
{% for item in Model.Content.ListPart.ContentItems %}
{{ item | shape_build_display | shape_render }}
{% endfor %}
</v-list>

{% assign previousText = "Newer Tenants" | t %}
{% assign nextText = "Older Tenants" | t %}
{% assign previousClass = "previous" | t %}
{% assign nextClass = "next" | t %}

{% shape_pager Model.Content.ListPart.Pager previous_text: previousText, next_text: nextText,
previous_class: previousClass, next_class: nextClass %}

{{ Model.Content.ListPart.Pager | shape_render }}
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 @@

<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/[email protected]/survey.ko.min.js"></script>
<link href="https://unpkg.com/[email protected]/modern.css" type="text/css" rel="stylesheet"/>

{{ "ThemeResources" | shape_new | shape_render }}
{% resources type: "Meta" %}
Expand Down
68 changes: 66 additions & 2 deletions src/Themes/VuetifyTheme/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.