2018-04-19 15:42:12 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
|
|
|
|
|
|
|
|
|
namespace BTCPayServer.Views
|
|
|
|
|
{
|
|
|
|
|
public static class ViewsRazor
|
|
|
|
|
{
|
|
|
|
|
public const string ACTIVE_PAGE_KEY = "ActivePage";
|
2018-04-19 15:57:23 -05:00
|
|
|
|
public static void SetActivePageAndTitle<T>(this ViewDataDictionary viewData, T activePage, string title = null)
|
2018-04-19 15:42:12 -05:00
|
|
|
|
where T : IConvertible
|
|
|
|
|
{
|
2018-04-19 15:57:23 -05:00
|
|
|
|
viewData["Title"] = title ?? activePage.ToString();
|
2018-04-19 15:42:12 -05:00
|
|
|
|
viewData[ACTIVE_PAGE_KEY] = activePage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string IsActivePage<T>(this ViewDataDictionary viewData, T page)
|
|
|
|
|
where T : IConvertible
|
|
|
|
|
{
|
|
|
|
|
var activePage = (T)viewData[ACTIVE_PAGE_KEY];
|
|
|
|
|
return page.Equals(activePage) ? "active" : null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|