Skip to content

Commit

Permalink
Add ISiteContext.Position for sort order of tenant lists (e.g. in nav…
Browse files Browse the repository at this point in the history
…igation)
  • Loading branch information
axunonb committed Aug 18, 2023
1 parent 0e9b9ef commit 8ef6a2e
Show file tree
Hide file tree
Showing 14 changed files with 767 additions and 666 deletions.
323 changes: 163 additions & 160 deletions League.Demo/Configuration/Tenant.Default.Development.config

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions League.Demo/Configuration/Tenant.Default.Production.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<!-- May only be true for a single tenant in a tenant store. -->
<IsDefault>True</IsDefault>
<SiteContext>
<!-- The position of the tenant within tenant lists (e.g. navigation). -->
<Position>0</Position>
<!-- The Url segment used to identify the site. May be empty for the default tenant. -->
<UrlSegmentValue></UrlSegmentValue>
<!-- The folder name used for a tenant. This name must be set. -->
Expand All @@ -25,7 +27,7 @@
<!-- The email address of a recipient. -->
<Address>[email protected]</Address>
</ContactFrom>
<!-- "From" mailbox address for the contact form -->
<!-- "To" mailbox address for the contact form -->
<ContactTo>
<!-- The display name of a recipient. -->
<DisplayName>Volleyball-Liga</DisplayName>
Expand Down Expand Up @@ -57,7 +59,7 @@
<!-- Notifications sent before and after matches. -->
<MatchNotifications>
<!-- Number of days before the next match will be announced. 0 for none, negative number days. -->
<DaysBeforeNextmatch>-10</DaysBeforeNextmatch>
<DaysBeforeNextMatch>-10</DaysBeforeNextMatch>
<!-- Number of days to remind 1st time for missing match results. 0 for none, positive number of days. -->
<DaysForMatchResultReminder1>3</DaysForMatchResultReminder1>
<!-- Number of days to remind 2nd time for missing match results. 0 for none, positive number of days. -->
Expand Down
323 changes: 163 additions & 160 deletions League.Demo/Configuration/Tenant.OtherOrg.Development.config

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions League.Demo/Configuration/Tenant.OtherOrg.Production.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<!-- May only be true for a single tenant in a tenant store. -->
<IsDefault>False</IsDefault>
<SiteContext>
<!-- The position of the tenant within tenant lists (e.g. navigation). -->
<Position>2</Position>
<!-- The Url segment used to identify the site. May be empty for the default tenant. -->
<UrlSegmentValue>otherorg</UrlSegmentValue>
<!-- The folder name used for a tenant. This name must be set. -->
Expand All @@ -25,7 +27,7 @@
<!-- The email address of a recipient. -->
<Address>[email protected]</Address>
</ContactFrom>
<!-- "From" mailbox address for the contact form -->
<!-- "To" mailbox address for the contact form -->
<ContactTo>
<!-- The display name of a recipient. -->
<DisplayName>OtherOrganization</DisplayName>
Expand Down Expand Up @@ -57,7 +59,7 @@
<!-- Notifications sent before and after matches. -->
<MatchNotifications>
<!-- Number of days before the next match will be announced. 0 for none, negative number days. -->
<DaysBeforeNextmatch>-10</DaysBeforeNextmatch>
<DaysBeforeNextMatch>-10</DaysBeforeNextMatch>
<!-- Number of days to remind 1st time for missing match results. 0 for none, positive number of days. -->
<DaysForMatchResultReminder1>3</DaysForMatchResultReminder1>
<!-- Number of days to remind 2nd time for missing match results. 0 for none, positive number of days. -->
Expand Down
323 changes: 163 additions & 160 deletions League.Demo/Configuration/Tenant.TestOrg.Development.config

Large diffs are not rendered by default.

323 changes: 163 additions & 160 deletions League.Demo/Configuration/Tenant.TestOrg.Production.config

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions League.Demo/Seed/Insert-Initial-Data.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* Data for the 'dbo.IdentityRole' table (Records 1 - 2) */

SET IDENTITY_INSERT dbo.IdentityRole ON;
GO
INSERT INTO dbo.IdentityRole (Id, Name)
VALUES
(1, N'SystemManager'),
(2, N'TournamentManager')
GO
SET IDENTITY_INSERT dbo.IdentityRole OFF;
GO

/* Data for the 'dbo.MatchRule' table (Records 1 - 1) */

SET IDENTITY_INSERT dbo.MatchRule ON;
GO
INSERT INTO dbo.MatchRule (Id, Name, NumOfSets, BestOf, PointsMatchWon, PointsMatchLost, PointsMatchWonAfterTieBreak, PointsMatchLostAfterTieBreak, PointsMatchTie, RankComparer, CreatedOn, ModifiedOn)
VALUES
(1, N'3 sets to win, tie-break rule', 3, 1, 3, 0, 2, 1, 0, 1, GETDATE(), GETDATE())
SET IDENTITY_INSERT dbo.MatchRule OFF;
GO

/* Data for the 'dbo.SetRule' table (Records 1 - 1) */

SET IDENTITY_INSERT dbo.SetRule ON;
GO
INSERT INTO dbo.SetRule (Id, Name, NumOfPointsToWinRegular, NumOfPointsToWinTiebreak, PointsDiffToWinRegular, PointsDiffToWinTiebreak, PointsSetLost, PointsSetTie, PointsSetWon, MaxTimeouts, MaxSubstitutions, CreatedOn, ModifiedOn)
VALUES
(1, N'Indoor set rule', 25, 15, 2, 2, 0, 0, 1, 2, 6, GETDATE(), GETDATE()),
(1, N'Beach set rule', 21, 15, 2, 2, 0, 0, 1, 2, 0, GETDATE(), GETDATE())
GO
SET IDENTITY_INSERT dbo.SetRule OFF;
GO

/* Data for the 'dbo.RoundType' table (Records 1 - 1) */

SET IDENTITY_INSERT dbo.RoundType ON;
GO
INSERT INTO dbo.RoundType (Id, Name, Description, CreatedOn, ModifiedOn)
VALUES
(1, N'Female', N'Female teams', GETDATE(), GETDATE()),
(2, N'Male', N'Male teams', GETDATE(), GETDATE()),
(3, N'Mixed', N'Mixed teams', GETDATE(), GETDATE())
GO
SET IDENTITY_INSERT dbo.RoundType OFF;
GO


/* Data for the 'dbo.User' table (Records 1 - 1) */

SET IDENTITY_INSERT dbo.[User] ON;
GO
INSERT INTO dbo.[User] (Id, Guid, UserName, PasswordHash, Email, EmailConfirmedOn, PhoneNumber, PhoneNumberConfirmedOn, LastLoginOn, AccessFailedCount, LockoutEndDateUtc, Gender, Title, FirstName, MiddleName, LastName, Nickname, PhoneNumber2, Email2, Birthday, Remarks, CreatedOn, ModifiedOn)
VALUES
(1, N'49afc1e5-d439-40d7-bb13-ce994a825069', N'sysadmin', NULL, N'[email protected]', '20230817', N'', NULL, NULL, 0, NULL, N'm', N'', N'admin', N'', N'admin', N'', N'', N'', NULL, NULL, '20230817', '20230817')
GO
SET IDENTITY_INSERT dbo.[User] OFF;
GO

/* Data for the 'dbo.IdentityUserRole' table (Records 1 - 1) */

SET IDENTITY_INSERT dbo.IdentityUserRole ON;
GO
INSERT INTO dbo.IdentityUserRole (Id, UserId, RoleId)
VALUES
(1, 1, 1)
GO
SET IDENTITY_INSERT dbo.IdentityUserRole OFF;
GO
1 change: 1 addition & 0 deletions League.Demo/Views/Home/Overview.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ViewData.Description(Localizer["Leagues using volleyball-league.demo"].Value);
var tenants = TenantStore.GetTenants().Values
.Where(tc => !string.IsNullOrEmpty(tc.Identifier) && !tc.SiteContext.HideInMenu && !tc.IsDefault)
.OrderBy(tc => tc.SiteContext.Position)
.ToList();
}
<div>
Expand Down
4 changes: 2 additions & 2 deletions League/ApiControllers/Cron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ private void QueueJobs(DateTime referenceDateUtc)
{
var smt = _sendMailTask.CreateNewInstance();

if (_tenantContext.SiteContext.MatchNotifications.DaysBeforeNextmatch != DoNotExecute)
if (_tenantContext.SiteContext.MatchNotifications.DaysBeforeNextMatch != DoNotExecute)
{
smt.SetMessageCreator(new AnnounceNextMatchCreator
{
Parameters =
{
CultureInfo = CultureInfo.DefaultThreadCurrentUICulture ?? CultureInfo.CurrentCulture,
ReferenceDateUtc =
referenceDateUtc.AddDays(_tenantContext.SiteContext.MatchNotifications.DaysBeforeNextmatch * -1),
referenceDateUtc.AddDays(_tenantContext.SiteContext.MatchNotifications.DaysBeforeNextMatch * -1),
IcsCalendarBaseUrl = TenantLink.ActionLink(nameof(Calendar), nameof(Match), null,
scheme: TenantLink.HttpContext.Request.Scheme) ?? string.Empty
}
Expand Down
2 changes: 1 addition & 1 deletion League/Components/MainNavigationComponentModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class NavigationNode
/// </summary>
public string IconCssClass { get; set; } = string.Empty;
/// <summary>
/// The css class to use the menu entry.
/// The css class to use for the menu entry.
/// </summary>
public string CssClass { get; set; } = string.Empty;
/// <summary>
Expand Down
12 changes: 9 additions & 3 deletions League/Components/MainNavigationNodeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,14 @@ protected virtual async Task CreateStandardNavigationNodes()

leagues.ChildNodes.Add(new MainNavigationComponentModel.NavigationNode
{Text = Localizer["Home"], Url = "/welcome", Key = "League_Welcome"});

foreach (var tenant in TenantStore.GetTenants().Values)

leagues.ChildNodes.Add(new MainNavigationComponentModel.NavigationNode
{ Text = Localizer["League Overview"], Url = "/overview", Key = "League_Overview" });

leagues.ChildNodes.Add(new MainNavigationComponentModel.NavigationNode
{ Text = "Separator", Key = "League_Separator" });

foreach (var tenant in TenantStore.GetTenants().Values.OrderBy(t => t.SiteContext.Position))
{
if (!string.IsNullOrEmpty(tenant.Identifier) && !tenant.SiteContext.HideInMenu)
{
Expand All @@ -145,7 +151,7 @@ protected virtual async Task CreateStandardNavigationNodes()
});
}
}
leagues.ChildNodes.Add(new MainNavigationComponentModel.NavigationNode { Text = Localizer["League Overview"], Url = "/overview", Key = "LeagueOverview" });

#endregion

#region ** Team Infos **
Expand Down
13 changes: 7 additions & 6 deletions League/Views/Shared/NavigationNodeChildDropdownPartial.cshtml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
@using League.Components
@model (League.Components.MainNavigationComponentModel MainNav, League.Components.MainNavigationComponentModel.NavigationNode Node)
@if (Model.MainNav != null && Model.Node.HasVisibleChildNodes())
@if (Model.Node.HasVisibleChildNodes())
{
<ul class="dropdown-menu shadow@(ViewData["dropdown-menu-end"])" style="margin-top: -0.3rem">
@foreach (var childNode in Model.Node.ChildNodes)
{
if (!childNode.ShouldShow())
if (childNode.Text == "Separator")
{
<li>
<hr class="dropdown-divider">
</li>
continue;
}

if (childNode.Text == "Separator")
if (!childNode.ShouldShow())
{
<li>
<span class="dropdown-divider"></span>
</li>
continue;
}

if (childNode.HasVisibleChildNodes())
{
<li>
Expand Down
11 changes: 7 additions & 4 deletions TournamentManager/TournamentManager/MultiTenancy/ISiteContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#nullable enable

namespace TournamentManager.MultiTenancy;
namespace TournamentManager.MultiTenancy;

public interface ISiteContext
{
Expand All @@ -9,6 +7,11 @@ public interface ISiteContext
/// </summary>
ITenant? Tenant { get; set; }

/// <summary>
/// Determines the position, for the <see cref="ITenant"/> within tenant lists (e.g. navigation).
/// </summary>
int Position { get; set; }

/// <summary>
/// The value of the Url segment used to identify the site. May be NULL or empty string.
/// </summary>
Expand Down Expand Up @@ -44,4 +47,4 @@ public interface ISiteContext
/// Notifications sent before and after matches.
/// </summary>
MatchNotifications MatchNotifications { get; set; }
}
}
17 changes: 11 additions & 6 deletions TournamentManager/TournamentManager/MultiTenancy/SiteContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#nullable enable
namespace TournamentManager.MultiTenancy;
namespace TournamentManager.MultiTenancy;

/// <summary>
/// Provides site-specific data.
Expand All @@ -12,6 +11,12 @@ public class SiteContext : ISiteContext
[YAXLib.Attributes.YAXDontSerialize]
public ITenant? Tenant { get; set; }

/// <summary>
/// Determines the position, for the <see cref="ITenant"/> within tenant lists (e.g. navigation).
/// </summary>
[YAXLib.Attributes.YAXComment("The position of the tenant within tenant lists (e.g. navigation).")]
public int Position { get; set; }

/// <summary>
/// The value of the Url segment used to identify the site. May be empty for the default tenant.
/// </summary>
Expand Down Expand Up @@ -60,12 +65,12 @@ public class Email
/// <summary>
/// "From" mailbox address for the contact form
/// </summary>
[YAXLib.Attributes.YAXComment("")]
[YAXLib.Attributes.YAXComment("\"From\" mailbox address for the contact form\"")]
public MailAddress ContactFrom { get; set; } = new();
/// <summary>
/// "To" mailbox address for the contact form
/// </summary>
[YAXLib.Attributes.YAXComment("\"From\" mailbox address for the contact form")]
[YAXLib.Attributes.YAXComment("\"To\" mailbox address for the contact form")]
public MailAddress ContactTo { get; set; } = new();
/// <summary>
/// General "To" mailbox address for emails generated programmatically
Expand Down Expand Up @@ -111,7 +116,7 @@ public class MatchNotifications
/// Number of days before the next match will be announced. 0 for none, negative number days.
/// </summary>
[YAXLib.Attributes.YAXComment("Number of days before the next match will be announced. 0 for none, negative number days.")]
public int DaysBeforeNextmatch { get; set; } = 0;
public int DaysBeforeNextMatch { get; set; } = 0;

/// <summary>
/// Number of days to remind 1st time for missing match results. 0 for none, positive number of days.
Expand All @@ -124,4 +129,4 @@ public class MatchNotifications
/// </summary>
[YAXLib.Attributes.YAXComment("Number of days to remind 2nd time for missing match results. 0 for none, positive number of days.")]
public int DaysForMatchResultReminder2 { get; set; } = 0;
}
}

0 comments on commit 8ef6a2e

Please sign in to comment.