Skip to content

Commit

Permalink
Merge pull request #1141 from k7hpn/fix/bootstrap-5
Browse files Browse the repository at this point in the history
Improve Event indexes
  • Loading branch information
k7hpn authored Oct 23, 2024
2 parents 6044294 + 13ec95c commit 8112c1e
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 200 deletions.
35 changes: 27 additions & 8 deletions src/GRA.Controllers/MissionControl/EventsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public async Task<IActionResult> Create(int? id,
{
var site = await GetCurrentSiteAsync();
var siteUrl = await _siteLookupService.GetSiteLinkAsync(site.Id);
viewModel.BadgeMakerUrl = GetBadgeMakerUrl(siteUrl.ToString(),
viewModel.BadgeMakerUrl = GetBadgeMakerUrl(siteUrl.ToString(),
site.FromEmailAddress);
viewModel.UseBadgeMaker = await _siteLookupService.GetSiteSettingBoolAsync(site.Id,
SiteSettingKey.Badges.EnableBadgeMaker);
Expand Down Expand Up @@ -1121,7 +1121,11 @@ public async Task<IActionResult> Import(Microsoft.AspNetCore.Http.IFormFile even
}

public async Task<IActionResult> Index(string search,
int? systemId, int? branchId, bool? mine, int? programId, int page = 1)
int? systemId,
int? branchId,
bool? mine,
int? programId,
int page = 1)
{
var site = await GetCurrentSiteAsync();
if (!string.IsNullOrEmpty(site.ExternalEventListUrl))
Expand Down Expand Up @@ -1176,6 +1180,7 @@ public async Task<IActionResult> Locations(int page = 1)

var viewModel = new LocationsListViewModel
{
CanManageLocations = UserHasPermission(Permission.ManageLocations),
Locations = locationList.Data,
PaginateModel = paginateModel,
};
Expand Down Expand Up @@ -1232,7 +1237,11 @@ public async Task<JsonResult> SetLocationGeolocation(int id)
}

public async Task<IActionResult> StreamingEvents(string search,
int? systemId, int? branchId, bool? mine, int? programId, int page = 1)
int? systemId,
int? branchId,
bool? mine,
int? programId,
int page = 1)
{
var site = await GetCurrentSiteAsync();
if (!string.IsNullOrEmpty(site.ExternalEventListUrl))
Expand Down Expand Up @@ -1266,8 +1275,13 @@ var viewModel
}
}

private async Task<EventsListViewModel> GetEventList(int? eventType, string search,
int? systemId, int? branchId, bool? mine, int? programId, int page = 1)
private async Task<EventsListViewModel> GetEventList(int? eventType,
string search,
int? systemId,
int? branchId,
bool? mine,
int? programId,
int page = 1)
{
var filter = new EventFilter(page)
{
Expand Down Expand Up @@ -1366,18 +1380,23 @@ private async Task<EventsListViewModel> GetEventList(int? eventType, string sear
.ThenBy(_ => _.Name);
viewModel.ActiveNav = "All";
}

if (programId.HasValue)
{
if (programId.Value > 0)
{
viewModel.ProgramName =
(await _siteService.GetProgramByIdAsync(programId.Value)).Name;
var program = await _siteService.GetProgramByIdAsync(programId.Value);
viewModel.ProgramName = $"Limited to {program.Name}";
}
else
{
viewModel.ProgramName = "Not Limited";
viewModel.ProgramName = "Not Limited to a Program";
}
}
else
{
viewModel.ProgramName = "All Programs";
}

return viewModel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,35 @@ namespace GRA.Controllers.ViewModel.MissionControl.Events
{
public class EventsListViewModel
{
public IEnumerable<Event> Events { get; set; }
public PaginateViewModel PaginateModel { get; set; }
public string Search { get; set; }
public int? SystemId { get; set; }
public int? BranchId { get; set; }
public int? ProgramId { get; set; }
public bool? Mine { get; set; }
public string ActionTarget
{
get
{
return CommunityExperience
? nameof(EventsController.CommunityExperiences)
: Streaming
? nameof(EventsController.StreamingEvents)
: nameof(EventsController.Index);
}
}

public string ActiveNav { get; set; }
public string SystemName { get; set; }
public int? BranchId { get; set; }
public IEnumerable<Branch> BranchList { get; set; }
public string BranchName { get; set; }
public string ProgramName { get; set; }
public bool CanManageLocations { get; set; }
public bool CommunityExperience { get; set; }
public IEnumerable<Event> Events { get; set; }
public bool? Mine { get; set; }
public PaginateViewModel PaginateModel { get; set; }
public int? ProgramId { get; set; }
public IEnumerable<Program> ProgramList { get; set; }
public string ProgramName { get; set; }
public bool RequireSecretCode { get; set; }
public string Search { get; set; }
public bool Streaming { get; set; }

public IEnumerable<Branch> BranchList { get; set; }
public IEnumerable<GRA.Domain.Model.System> SystemList { get; set; }
public IEnumerable<Program> ProgramList { get; set; }
public int? SystemId { get; set; }
public IEnumerable<Domain.Model.System> SystemList { get; set; }
public string SystemName { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ namespace GRA.Controllers.ViewModel.MissionControl.Events
{
public class LocationsListViewModel
{
public IEnumerable<GRA.Domain.Model.Location> Locations { get; set; }
public PaginateViewModel PaginateModel { get; set; }
public bool CanManageLocations { get; set; }
public string GoogleMapsAPIKey { get; set; }
public GRA.Domain.Model.Location Location { get; set; }
public IEnumerable<Domain.Model.Location> Locations { get; set; }
public PaginateViewModel PaginateModel { get; set; }
public bool ShowGeolocation { get; set; }
public string GoogleMapsAPIKey { get; set; }
}
}
25 changes: 13 additions & 12 deletions src/GRA.Domain.Model/Location.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@ namespace GRA.Domain.Model
{
public class Location : Abstract.BaseDomainEntity
{
public int SiteId { get; set; }

[Required]
[MaxLength(255)]
public string Name { get; set; }

[MaxLength(255)]
public string Url { get; set; }

[Required]
[MaxLength(255)]
public string Address { get; set; }

[MaxLength(50)]
public string Telephone { get; set; }
public int EventCount { get; set; }

[MaxLength(50)]
public string Geolocation { get; set; }

public int EventCount { get; set; }
[MaxLength(255)]
[Required]
public string Name { get; set; }

public int SiteId { get; set; }

[MaxLength(50)]
public string Telephone { get; set; }

[Display(Name = "Link to this location")]
[MaxLength(255)]
public string Url { get; set; }
}
}
142 changes: 88 additions & 54 deletions src/GRA.Web/Areas/MissionControl/Views/Events/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,85 +1,106 @@
@model GRA.Controllers.ViewModel.MissionControl.Events.EventsListViewModel

<div class="row my-4">
<div class="col-12 mb-2">
<ul class="nav nav-pills flex-column flex-sm-row">
<li class="nav-item">
<a ActiveBy routeKey="Action"
value="Index"
asp-action="Index" class="nav-link">Events</a></li>
<li class="nav-item">
<a ActiveBy routeKey="Action"
value="CommunityExperiences"
asp-action="CommunityExperiences" class="nav-link">Community Experiences</a>
</li>
@if (Model.CanManageLocations)
{
<li ActiveBy routeKey="Action"
value="Locations"><a asp-action="Locations" class="nav-link">Locations</a></li>
}
<li class="nav-item">
<a ActiveBy routeKey="Action"
value="StreamingEvents" asp-action="StreamingEvents" class="nav-link">Streaming Events</a></li>
</ul>
</div>
</div>
@await Html.PartialAsync("_EventsPartial")

<div class="row my-4">
<div class="col-12 mb-2">
<div class="col-12">
<ul class="nav nav-pills flex-column flex-sm-row">
<li class="nav-item"><a asp-route-Search="@Model.Search" asp-route-ProgramId="@Model.ProgramId" class="nav-link @(Model.ActiveNav == "All" ? "active" : "")">All</a></li>
<li class="nav-item">
<a class="dropdown-toggle nav-link @(Model.ActiveNav == "System" ? "active" : "")" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
<a class="nav-link @(Model.ActiveNav == "All" ? "active" : "")"
asp-route-ProgramId="@Model.ProgramId"
asp-route-Search="@Model.Search">All</a>
</li>
<li class="nav-item dropdown">
<a class="dropdown-toggle nav-link @(Model.ActiveNav == "System" ? "active" : "")"
data-bs-toggle="dropdown"
href="#"
role="button"
aria-haspopup="true"
aria-expanded="false">
@(Model.SystemName ?? "System") <span class="caret"></span>
</a>
<ul class="dropdown-menu">
@foreach (var system in Model.SystemList)
{
<li><a asp-route-Search="@Model.Search" asp-route-SystemId="@system.Id" asp-route-ProgramId="@Model.ProgramId">@system.Name</a></li>
<li>
<a class="dropdown-item"
asp-route-ProgramId="@Model.ProgramId"
asp-route-Search="@Model.Search"
asp-route-SystemId="@system.Id">@system.Name</a>
</li>
}
</ul>
</li>
<li class="nav-item">
<a class="dropdown-toggle nav-link @(Model.ActiveNav == "Branch" ? "active" : "")" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
@(Model.BranchName ?? "Branch") <span class="caret"></span>
<li class="nav-item dropdown">
<a class="dropdown-toggle nav-link @(Model.ActiveNav == "Branch" ? "active" : "")"
data-bs-toggle="dropdown"
href="#" role="button"
aria-haspopup="true"
aria-expanded="false">
@(Model.BranchName ?? "Branch") <span class="caret"></span>
</a>
<ul class="dropdown-menu">
@foreach (var branch in Model.BranchList)
{
<li><a asp-route-Search="@Model.Search" asp-route-BranchId="@branch.Id" asp-route-ProgramId="@Model.ProgramId">@branch.Name</a></li>
<li>
<a class="dropdown-item"
asp-route-BranchId="@branch.Id"
asp-route-ProgramId="@Model.ProgramId"
asp-route-Search="@Model.Search">@branch.Name</a>
</li>
}
</ul>
</li>
<li class="nav-item"><a asp-route-Search="@Model.Search" asp-route-ProgramId="@Model.ProgramId" asp-route-Mine="True" class="nav-link @(Model.ActiveNav == "Mine" ? "active" : "")">Mine</a></li>
</ul>
</div>
</div>

<div class="row my-4">
<div class="col-12">
<span class="dropdown-label">Limited to Program:</span>
<ul class="nav" style="display: inline-table;">
<li>
<a class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
@(Model.ProgramName ?? "Show All") <span class="caret"></span>
<li class="nav-item">
<a asp-route-Search="@Model.Search"
asp-route-Mine="True"
asp-route-ProgramId="@Model.ProgramId"
class="nav-link @(Model.ActiveNav == "Mine" ? "active" : "")">Mine</a>
</li>
<li class="nav-item d-none d-sm-block"><a class="nav-link disabled">|</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle"
data-bs-toggle="dropdown"
href="#"
role="button"
aria-haspopup="true"
aria-expanded="false">
Limitations: @(Model.ProgramName) <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a asp-route-Search="@Model.Search" asp-route-SystemId="@Model.SystemId" asp-route-BranchId="@Model.BranchId" asp-route-Mine="@Model.Mine">Show All</a></li>
<li><a asp-route-Search="@Model.Search" asp-route-SystemId="@Model.SystemId" asp-route-BranchId="@Model.BranchId" asp-route-Mine="@Model.Mine" asp-route-ProgramId="0">Not Limited</a></li>
<li>
<a asp-route-BranchId="@Model.BranchId"
asp-route-Mine="@Model.Mine"
asp-route-Search="@Model.Search"
asp-route-SystemId="@Model.SystemId"
class="dropdown-item">Show All</a>
</li>
<li>
<a asp-route-BranchId="@Model.BranchId"
asp-route-Mine="@Model.Mine"
asp-route-ProgramId="0"
asp-route-Search="@Model.Search"
asp-route-SystemId="@Model.SystemId"
class="dropdown-item">Not Limited</a>
</li>
@foreach (var program in Model.ProgramList)
{
<li><a asp-route-Search="@Model.Search" asp-route-ProgramId="@program.Id" asp-route-SystemId="@Model.SystemId" asp-route-BranchId="@Model.BranchId" asp-route-Mine="@Model.Mine">@program.Name</a></li>
<li>
<a asp-route-BranchId="@Model.BranchId"
asp-route-Mine="@Model.Mine"
asp-route-ProgramId="@program.Id"
asp-route-Search="@Model.Search"
asp-route-SystemId="@Model.SystemId"
class="dropdown-item">@program.Name</a>
</li>
}
</ul>
</li>
</ul>
</div>
</div>

<form asp-controller="Events"
asp-action="@(Model.CommunityExperience ? "CommunityExperiences" : Model.Streaming ? "StreamingEvents" : "Index")"
method="get"
role="form">
<form asp-controller="Events" asp-action="@Model.ActionTarget" method="get" role="form">
@if (Model.SystemId.HasValue)
{
<input asp-for="SystemId" type="hidden" />
Expand All @@ -97,12 +118,25 @@
<input asp-for="ProgramId" type="hidden" />
}
<div class="row my-4">
<div class="col-8">
<div class="col-12 col-sm-2">
<label class="col-form-label fs-5">Search:</label>
</div>
<div class="col-12 col-sm-10">
<input asp-for="Search" class="form-control" />
</div>
<div class="col-4">
<input type="submit" value="Search" class="btn btn-outline-primary" style="margin-right: 8px;" />
<a asp-action="Index" asp-route-SystemId="@Model.SystemId" asp-route-BranchId="@Model.BranchId" asp-route-ProgramId="@Model.ProgramId" asp-route-Mine="@Model.Mine" class="btn btn-outline-secondary">Clear</a>
</div>
<div class="row my-4">
<div class="col-sm-6 col-lg-8 d-none d-sm-block">&nbsp;</div>
<div class="col-12 col-sm-3 col-lg-2 d-grid my-1">
<a asp-action="Index"
asp-route-BranchId="@Model.BranchId"
asp-route-Mine="@Model.Mine"
asp-route-ProgramId="@Model.ProgramId"
asp-route-SystemId="@Model.SystemId"
class="btn btn-outline-secondary">Clear</a>
</div>
<div class="col-12 col-sm-3 col-lg-2 d-grid my-1">
<button type="submit" class="btn btn-outline-primary">Search</button>
</div>
</div>
</form>
Expand Down
Loading

0 comments on commit 8112c1e

Please sign in to comment.