From 23cbe9ec6429de803df1eb3642ab8f6ff4a49a17 Mon Sep 17 00:00:00 2001 From: Jonas Soderholm Date: Sat, 12 May 2018 18:35:26 +0100 Subject: [PATCH 1/6] Added highlightning in admin menu --- .../TagHelpers/ActiveRouteTagHelperShould.cs | 189 ++++++++++++++++++ .../TagHelpers/ActiveRouteTagHelper.cs | 143 +++++++++++++ .../Shared/_AdminNavigationPartial.cshtml | 16 +- AllReadyApp/Web-App/AllReady/appsettings.json | 4 +- 4 files changed, 342 insertions(+), 10 deletions(-) create mode 100644 AllReadyApp/Web-App/AllReady.UnitTest/TagHelpers/ActiveRouteTagHelperShould.cs create mode 100644 AllReadyApp/Web-App/AllReady/TagHelpers/ActiveRouteTagHelper.cs diff --git a/AllReadyApp/Web-App/AllReady.UnitTest/TagHelpers/ActiveRouteTagHelperShould.cs b/AllReadyApp/Web-App/AllReady.UnitTest/TagHelpers/ActiveRouteTagHelperShould.cs new file mode 100644 index 000000000..660259c65 --- /dev/null +++ b/AllReadyApp/Web-App/AllReady.UnitTest/TagHelpers/ActiveRouteTagHelperShould.cs @@ -0,0 +1,189 @@ +using AllReady.TagHelpers; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Razor.TagHelpers; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Xunit; + +namespace AllReady.UnitTest.TagHelpers +{ + public class ActiveRouteTagHelperShould + { + private const string controllerName = "Home"; + private const string actionName = "List"; + private Dictionary routeValue = new Dictionary { { "Id", "2" } }; + private const string page = "/index"; + + private const string notMatchingControllerName = "HomeX"; + private const string notMatchingActionName = "Index"; + private Dictionary notMathingRouteValue = new Dictionary { { "Id", "3" } }; + private const string notMatchingPage = "/index2"; + + private Func> GetEmptyChildContent() + { + TagHelperContent content = new DefaultTagHelperContent(); + return (b, encoder) => Task.FromResult(content); + } + + private TagHelperContext GetContext() + { + return new TagHelperContext(new TagHelperAttributeList(), new Dictionary(), Guid.NewGuid().ToString()); + } + + private TagHelperOutput GetOutput() + { + return new TagHelperOutput("time", new TagHelperAttributeList(), GetEmptyChildContent()); + } + + private ViewContext GetViewContextMVC() + { + var viewContext = new ViewContext(); + viewContext.RouteData = new Microsoft.AspNetCore.Routing.RouteData(); + viewContext.RouteData.Values.Add("Controller", controllerName); + viewContext.RouteData.Values.Add("Action", actionName); + viewContext.RouteData.Values.Add("Id", "2"); + return viewContext; + } + + private ViewContext GetViewContextPage() + { + var viewContext = new ViewContext(); + viewContext.RouteData = new Microsoft.AspNetCore.Routing.RouteData(); + viewContext.RouteData.Values.Add("page", page); + return viewContext; + } + + [Fact] + public void NotHaveClassAttributeIfNoClassPassedInAndIfNoParametersPassedIn() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC() + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(0, output.Attributes.Count); + } + + [Fact] + public void HaveActiveClassAttributeWhenControllerMatch() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = controllerName + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(1, output.Attributes.Count); + Assert.Equal("class", output.Attributes[0].Name); + Assert.Equal("active", output.Attributes[0].Value); + } + + [Fact] + public void NotHaveClassAttributeWhenControllerNotMatching() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = notMatchingControllerName + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(0, output.Attributes.Count); + } + + [Fact] + public void HaveActiveClassAttributeWhenActionMatch() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = controllerName, + Action = actionName + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(1, output.Attributes.Count); + Assert.Equal("class", output.Attributes[0].Name); + Assert.Equal("active", output.Attributes[0].Value); + } + + [Fact] + public void NotHaveClassAttributeWhenActionNotMatching() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = controllerName, + Action = notMatchingActionName + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(0, output.Attributes.Count); + } + + [Fact] + public void HaveActiveClassAttributeWhenRouteDataMatch() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = controllerName, + Action = actionName, + RouteValues = routeValue + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(1, output.Attributes.Count); + Assert.Equal("class", output.Attributes[0].Name); + Assert.Equal("active", output.Attributes[0].Value); + } + + [Fact] + public void NotHaveClassAttributeWhenRouteDataNotMatching() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = controllerName, + Action = actionName, + RouteValues = notMathingRouteValue + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(0, output.Attributes.Count); + } + + [Fact] + public void HaveActiveClassAttributePageMatch() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextPage(), + Page = page + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(1, output.Attributes.Count); + Assert.Equal("class", output.Attributes[0].Name); + Assert.Equal("active", output.Attributes[0].Value); + } + + [Fact] + public void NotHaveClassAttributeWhenPageNotMatching() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextPage(), + Page = notMatchingPage + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(0, output.Attributes.Count); + } + } +} diff --git a/AllReadyApp/Web-App/AllReady/TagHelpers/ActiveRouteTagHelper.cs b/AllReadyApp/Web-App/AllReady/TagHelpers/ActiveRouteTagHelper.cs new file mode 100644 index 000000000..6a9fa89a7 --- /dev/null +++ b/AllReadyApp/Web-App/AllReady/TagHelpers/ActiveRouteTagHelper.cs @@ -0,0 +1,143 @@ +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Razor.TagHelpers; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace AllReady.TagHelpers +{ + [HtmlTargetElement(Attributes = "is-active-route")] + public class ActiveRouteTagHelper : TagHelper + { + private IDictionary _routeValues; + + /// + /// Name of the action method + /// + [HtmlAttributeName("asp-action")] + public string Action { get; set; } + + /// + /// Name of the controller + /// + [HtmlAttributeName("asp-controller")] + public string Controller { get; set; } + + /// + /// Name of the razor page (e.g. /index) + /// + [HtmlAttributeName("asp-page")] + public string Page { get; set; } + + /// + /// Additional route parameters + /// + [HtmlAttributeName("asp-all-route-data", DictionaryAttributePrefix = "asp-route-")] + public IDictionary RouteValues + { + get + { + if (_routeValues == null) + _routeValues = new Dictionary(StringComparer.OrdinalIgnoreCase); + return _routeValues; + } + set + { + _routeValues = value; + } + } + + /// + /// The ViewContext + /// + [HtmlAttributeNotBound] + [ViewContext] + public ViewContext ViewContext { get; set; } + + public override void Process(TagHelperContext context, TagHelperOutput output) + { + base.Process(context, output); + + if (ShouldBeActive()) + { + MakeActive(output); + } + + output.Attributes.RemoveAll("is-active-route"); + } + + private bool ShouldBeActive() + { + if (ViewContext.RouteData.Values.ContainsKey("Controller")) + { + return ShouldBeActieMvc(); + } + else if (ViewContext.RouteData.Values.ContainsKey("page")) + { + return ShouldBeActiveRazorPage(); + } + return true; + } + + private bool ShouldBeActieMvc() + { + if (string.IsNullOrWhiteSpace(Controller) && + string.IsNullOrWhiteSpace(Action) && + !RouteValues.Any(r => !ViewContext.RouteData.Values.ContainsKey(r.Key))) + { + return false; + } + + string currentController = ViewContext.RouteData.Values["Controller"].ToString(); + string currentAction = ViewContext.RouteData.Values["Action"].ToString(); + + if (!string.IsNullOrWhiteSpace(Controller) && Controller.ToLower() != currentController.ToLower()) + { + return false; + } + + if (!string.IsNullOrWhiteSpace(Action) && Action.ToLower() != currentAction.ToLower()) + { + return false; + } + + foreach (var routeValue in RouteValues) + { + if (!ViewContext.RouteData.Values.ContainsKey(routeValue.Key) || + ViewContext.RouteData.Values[routeValue.Key].ToString() != routeValue.Value) + { + return false; + } + } + return true; + } + + private bool ShouldBeActiveRazorPage() + { + string currentPage = ViewContext.RouteData.Values["Page"].ToString(); + + if (string.IsNullOrWhiteSpace(Page) || Page.ToLower() != currentPage.ToLower()) + { + return false; + } + return true; + } + + private void MakeActive(TagHelperOutput output) + { + var classAttr = output.Attributes.FirstOrDefault(a => a.Name == "class"); + if (classAttr == null) + { + classAttr = new TagHelperAttribute("class", "active"); + output.Attributes.Add(classAttr); + } + else if (classAttr.Value == null || classAttr.Value.ToString().IndexOf("active") < 0) + { + output.Attributes.SetAttribute("class", classAttr.Value == null + ? "active" + : classAttr.Value.ToString() + " active"); + } + } + } +} diff --git a/AllReadyApp/Web-App/AllReady/Views/Shared/_AdminNavigationPartial.cshtml b/AllReadyApp/Web-App/AllReady/Views/Shared/_AdminNavigationPartial.cshtml index 845b194c9..b99a3a95f 100644 --- a/AllReadyApp/Web-App/AllReady/Views/Shared/_AdminNavigationPartial.cshtml +++ b/AllReadyApp/Web-App/AllReady/Views/Shared/_AdminNavigationPartial.cshtml @@ -14,21 +14,21 @@ } diff --git a/AllReadyApp/Web-App/AllReady/appsettings.json b/AllReadyApp/Web-App/AllReady/appsettings.json index b717d4530..4be327def 100644 --- a/AllReadyApp/Web-App/AllReady/appsettings.json +++ b/AllReadyApp/Web-App/AllReady/appsettings.json @@ -33,10 +33,10 @@ }, "Data": { "DefaultConnection": { - "ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" + "ConnectionString": "Server=DESKTOP-R93J9OG\\SQLEXPRESS;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" }, "HangfireConnection": { - "ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" + "ConnectionString": "Server=DESKTOP-R93J9OG\\SQLEXPRESS;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" }, "Storage": { "AzureStorage": "[storagekey]", From 651f653ad73aec36a5865fee573cd49394cfae24 Mon Sep 17 00:00:00 2001 From: Jonas Soderholm Date: Sat, 12 May 2018 21:34:47 +0100 Subject: [PATCH 2/6] Hoover highlight color added --- AllReadyApp/Web-App/AllReady/wwwroot/css/site.css | 1 + 1 file changed, 1 insertion(+) diff --git a/AllReadyApp/Web-App/AllReady/wwwroot/css/site.css b/AllReadyApp/Web-App/AllReady/wwwroot/css/site.css index 4f674ef82..483d8b600 100644 --- a/AllReadyApp/Web-App/AllReady/wwwroot/css/site.css +++ b/AllReadyApp/Web-App/AllReady/wwwroot/css/site.css @@ -306,6 +306,7 @@ Navigation .navbar-nav > li > .dropdown-menu > li.active > a { font-weight: bold; + background-color: #cb7333; } .navbar-nav > li > .dropdown-menu > li:hover, From b3d35a17c2d6538c38a2e6a52f1c2914702a6fb7 Mon Sep 17 00:00:00 2001 From: James Chambers Date: Thu, 21 Mar 2019 14:19:53 -0500 Subject: [PATCH 3/6] Just a sample scenario for a campaign --- docs/sample_campaign/data for site.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 docs/sample_campaign/data for site.txt diff --git a/docs/sample_campaign/data for site.txt b/docs/sample_campaign/data for site.txt new file mode 100644 index 000000000..3996a7e69 --- /dev/null +++ b/docs/sample_campaign/data for site.txt @@ -0,0 +1,17 @@ + + + +Flood Preparedness + +Spreading the word about the local risks of flooding + +Be Water Wise, Get Out In Time + +We live in an area where over 10,000 residents live in the flood plain and are at risk of being in the way of flood waters. Flooding can cause property and vehicle damage, put life at risk and put a strain on critical emergency services that could be used elsewhere. + +Help us spread the word about being prepared, having a plan and getting out of the way of the floods safely. + + +https://ourcommunitysite.com/floodpreparedness + +Our Community Flood Preparedness Site From a793eb5269bf1a44a33d0946d571e6ade2a55a6b Mon Sep 17 00:00:00 2001 From: Jonas Soderholm Date: Sat, 12 May 2018 18:35:26 +0100 Subject: [PATCH 4/6] Added highlightning in admin menu --- .../TagHelpers/ActiveRouteTagHelperShould.cs | 189 ++++++++++++++++++ .../TagHelpers/ActiveRouteTagHelper.cs | 143 +++++++++++++ .../Shared/_AdminNavigationPartial.cshtml | 16 +- AllReadyApp/Web-App/AllReady/appsettings.json | 4 +- 4 files changed, 342 insertions(+), 10 deletions(-) create mode 100644 AllReadyApp/Web-App/AllReady.UnitTest/TagHelpers/ActiveRouteTagHelperShould.cs create mode 100644 AllReadyApp/Web-App/AllReady/TagHelpers/ActiveRouteTagHelper.cs diff --git a/AllReadyApp/Web-App/AllReady.UnitTest/TagHelpers/ActiveRouteTagHelperShould.cs b/AllReadyApp/Web-App/AllReady.UnitTest/TagHelpers/ActiveRouteTagHelperShould.cs new file mode 100644 index 000000000..660259c65 --- /dev/null +++ b/AllReadyApp/Web-App/AllReady.UnitTest/TagHelpers/ActiveRouteTagHelperShould.cs @@ -0,0 +1,189 @@ +using AllReady.TagHelpers; +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Razor.TagHelpers; +using System; +using System.Collections.Generic; +using System.Text; +using System.Text.Encodings.Web; +using System.Threading.Tasks; +using Xunit; + +namespace AllReady.UnitTest.TagHelpers +{ + public class ActiveRouteTagHelperShould + { + private const string controllerName = "Home"; + private const string actionName = "List"; + private Dictionary routeValue = new Dictionary { { "Id", "2" } }; + private const string page = "/index"; + + private const string notMatchingControllerName = "HomeX"; + private const string notMatchingActionName = "Index"; + private Dictionary notMathingRouteValue = new Dictionary { { "Id", "3" } }; + private const string notMatchingPage = "/index2"; + + private Func> GetEmptyChildContent() + { + TagHelperContent content = new DefaultTagHelperContent(); + return (b, encoder) => Task.FromResult(content); + } + + private TagHelperContext GetContext() + { + return new TagHelperContext(new TagHelperAttributeList(), new Dictionary(), Guid.NewGuid().ToString()); + } + + private TagHelperOutput GetOutput() + { + return new TagHelperOutput("time", new TagHelperAttributeList(), GetEmptyChildContent()); + } + + private ViewContext GetViewContextMVC() + { + var viewContext = new ViewContext(); + viewContext.RouteData = new Microsoft.AspNetCore.Routing.RouteData(); + viewContext.RouteData.Values.Add("Controller", controllerName); + viewContext.RouteData.Values.Add("Action", actionName); + viewContext.RouteData.Values.Add("Id", "2"); + return viewContext; + } + + private ViewContext GetViewContextPage() + { + var viewContext = new ViewContext(); + viewContext.RouteData = new Microsoft.AspNetCore.Routing.RouteData(); + viewContext.RouteData.Values.Add("page", page); + return viewContext; + } + + [Fact] + public void NotHaveClassAttributeIfNoClassPassedInAndIfNoParametersPassedIn() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC() + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(0, output.Attributes.Count); + } + + [Fact] + public void HaveActiveClassAttributeWhenControllerMatch() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = controllerName + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(1, output.Attributes.Count); + Assert.Equal("class", output.Attributes[0].Name); + Assert.Equal("active", output.Attributes[0].Value); + } + + [Fact] + public void NotHaveClassAttributeWhenControllerNotMatching() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = notMatchingControllerName + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(0, output.Attributes.Count); + } + + [Fact] + public void HaveActiveClassAttributeWhenActionMatch() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = controllerName, + Action = actionName + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(1, output.Attributes.Count); + Assert.Equal("class", output.Attributes[0].Name); + Assert.Equal("active", output.Attributes[0].Value); + } + + [Fact] + public void NotHaveClassAttributeWhenActionNotMatching() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = controllerName, + Action = notMatchingActionName + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(0, output.Attributes.Count); + } + + [Fact] + public void HaveActiveClassAttributeWhenRouteDataMatch() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = controllerName, + Action = actionName, + RouteValues = routeValue + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(1, output.Attributes.Count); + Assert.Equal("class", output.Attributes[0].Name); + Assert.Equal("active", output.Attributes[0].Value); + } + + [Fact] + public void NotHaveClassAttributeWhenRouteDataNotMatching() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextMVC(), + Controller = controllerName, + Action = actionName, + RouteValues = notMathingRouteValue + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(0, output.Attributes.Count); + } + + [Fact] + public void HaveActiveClassAttributePageMatch() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextPage(), + Page = page + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(1, output.Attributes.Count); + Assert.Equal("class", output.Attributes[0].Name); + Assert.Equal("active", output.Attributes[0].Value); + } + + [Fact] + public void NotHaveClassAttributeWhenPageNotMatching() + { + ActiveRouteTagHelper tagHelper = new ActiveRouteTagHelper + { + ViewContext = GetViewContextPage(), + Page = notMatchingPage + }; + var output = GetOutput(); + tagHelper.Process(GetContext(), output); + Assert.Equal(0, output.Attributes.Count); + } + } +} diff --git a/AllReadyApp/Web-App/AllReady/TagHelpers/ActiveRouteTagHelper.cs b/AllReadyApp/Web-App/AllReady/TagHelpers/ActiveRouteTagHelper.cs new file mode 100644 index 000000000..6a9fa89a7 --- /dev/null +++ b/AllReadyApp/Web-App/AllReady/TagHelpers/ActiveRouteTagHelper.cs @@ -0,0 +1,143 @@ +using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.ViewFeatures; +using Microsoft.AspNetCore.Razor.TagHelpers; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace AllReady.TagHelpers +{ + [HtmlTargetElement(Attributes = "is-active-route")] + public class ActiveRouteTagHelper : TagHelper + { + private IDictionary _routeValues; + + /// + /// Name of the action method + /// + [HtmlAttributeName("asp-action")] + public string Action { get; set; } + + /// + /// Name of the controller + /// + [HtmlAttributeName("asp-controller")] + public string Controller { get; set; } + + /// + /// Name of the razor page (e.g. /index) + /// + [HtmlAttributeName("asp-page")] + public string Page { get; set; } + + /// + /// Additional route parameters + /// + [HtmlAttributeName("asp-all-route-data", DictionaryAttributePrefix = "asp-route-")] + public IDictionary RouteValues + { + get + { + if (_routeValues == null) + _routeValues = new Dictionary(StringComparer.OrdinalIgnoreCase); + return _routeValues; + } + set + { + _routeValues = value; + } + } + + /// + /// The ViewContext + /// + [HtmlAttributeNotBound] + [ViewContext] + public ViewContext ViewContext { get; set; } + + public override void Process(TagHelperContext context, TagHelperOutput output) + { + base.Process(context, output); + + if (ShouldBeActive()) + { + MakeActive(output); + } + + output.Attributes.RemoveAll("is-active-route"); + } + + private bool ShouldBeActive() + { + if (ViewContext.RouteData.Values.ContainsKey("Controller")) + { + return ShouldBeActieMvc(); + } + else if (ViewContext.RouteData.Values.ContainsKey("page")) + { + return ShouldBeActiveRazorPage(); + } + return true; + } + + private bool ShouldBeActieMvc() + { + if (string.IsNullOrWhiteSpace(Controller) && + string.IsNullOrWhiteSpace(Action) && + !RouteValues.Any(r => !ViewContext.RouteData.Values.ContainsKey(r.Key))) + { + return false; + } + + string currentController = ViewContext.RouteData.Values["Controller"].ToString(); + string currentAction = ViewContext.RouteData.Values["Action"].ToString(); + + if (!string.IsNullOrWhiteSpace(Controller) && Controller.ToLower() != currentController.ToLower()) + { + return false; + } + + if (!string.IsNullOrWhiteSpace(Action) && Action.ToLower() != currentAction.ToLower()) + { + return false; + } + + foreach (var routeValue in RouteValues) + { + if (!ViewContext.RouteData.Values.ContainsKey(routeValue.Key) || + ViewContext.RouteData.Values[routeValue.Key].ToString() != routeValue.Value) + { + return false; + } + } + return true; + } + + private bool ShouldBeActiveRazorPage() + { + string currentPage = ViewContext.RouteData.Values["Page"].ToString(); + + if (string.IsNullOrWhiteSpace(Page) || Page.ToLower() != currentPage.ToLower()) + { + return false; + } + return true; + } + + private void MakeActive(TagHelperOutput output) + { + var classAttr = output.Attributes.FirstOrDefault(a => a.Name == "class"); + if (classAttr == null) + { + classAttr = new TagHelperAttribute("class", "active"); + output.Attributes.Add(classAttr); + } + else if (classAttr.Value == null || classAttr.Value.ToString().IndexOf("active") < 0) + { + output.Attributes.SetAttribute("class", classAttr.Value == null + ? "active" + : classAttr.Value.ToString() + " active"); + } + } + } +} diff --git a/AllReadyApp/Web-App/AllReady/Views/Shared/_AdminNavigationPartial.cshtml b/AllReadyApp/Web-App/AllReady/Views/Shared/_AdminNavigationPartial.cshtml index 845b194c9..b99a3a95f 100644 --- a/AllReadyApp/Web-App/AllReady/Views/Shared/_AdminNavigationPartial.cshtml +++ b/AllReadyApp/Web-App/AllReady/Views/Shared/_AdminNavigationPartial.cshtml @@ -14,21 +14,21 @@ } diff --git a/AllReadyApp/Web-App/AllReady/appsettings.json b/AllReadyApp/Web-App/AllReady/appsettings.json index b717d4530..4be327def 100644 --- a/AllReadyApp/Web-App/AllReady/appsettings.json +++ b/AllReadyApp/Web-App/AllReady/appsettings.json @@ -33,10 +33,10 @@ }, "Data": { "DefaultConnection": { - "ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" + "ConnectionString": "Server=DESKTOP-R93J9OG\\SQLEXPRESS;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" }, "HangfireConnection": { - "ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" + "ConnectionString": "Server=DESKTOP-R93J9OG\\SQLEXPRESS;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" }, "Storage": { "AzureStorage": "[storagekey]", From c7c26ffff1ee6c20f9a91100ec091fa1a4051292 Mon Sep 17 00:00:00 2001 From: Jonas Soderholm Date: Sat, 12 May 2018 21:34:47 +0100 Subject: [PATCH 5/6] Hoover highlight color added --- AllReadyApp/Web-App/AllReady/wwwroot/css/site.css | 1 + 1 file changed, 1 insertion(+) diff --git a/AllReadyApp/Web-App/AllReady/wwwroot/css/site.css b/AllReadyApp/Web-App/AllReady/wwwroot/css/site.css index 4f674ef82..483d8b600 100644 --- a/AllReadyApp/Web-App/AllReady/wwwroot/css/site.css +++ b/AllReadyApp/Web-App/AllReady/wwwroot/css/site.css @@ -306,6 +306,7 @@ Navigation .navbar-nav > li > .dropdown-menu > li.active > a { font-weight: bold; + background-color: #cb7333; } .navbar-nav > li > .dropdown-menu > li:hover, From cd5b2c98f35ca2cba69e060500afa64e59101664 Mon Sep 17 00:00:00 2001 From: Jonas Soderholm Date: Sun, 14 Apr 2019 13:10:30 +0100 Subject: [PATCH 6/6] Fixed mistake commit in appsettings.json --- AllReadyApp/Web-App/AllReady/appsettings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AllReadyApp/Web-App/AllReady/appsettings.json b/AllReadyApp/Web-App/AllReady/appsettings.json index 4be327def..aa6b46be1 100644 --- a/AllReadyApp/Web-App/AllReady/appsettings.json +++ b/AllReadyApp/Web-App/AllReady/appsettings.json @@ -33,10 +33,10 @@ }, "Data": { "DefaultConnection": { - "ConnectionString": "Server=DESKTOP-R93J9OG\\SQLEXPRESS;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" + "ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" }, "HangfireConnection": { - "ConnectionString": "Server=DESKTOP-R93J9OG\\SQLEXPRESS;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" + "ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=AllReady;Integrated Security=true;MultipleActiveResultsets=true;" }, "Storage": { "AzureStorage": "[storagekey]",