Skip to content
Merged
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
2 changes: 1 addition & 1 deletion LearningHub.Nhs.WebUI/Views/Bookmark/Rename.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
autocomplete="off"
css-class=""
required="true"
required-client-side-error-message="<a href='#Title'>You must enter a bookmark name</a>" />
required-client-side-error-message="You must enter a bookmark name" />
</div>
</div>
</div>
Expand Down
222 changes: 114 additions & 108 deletions LearningHub.Nhs.WebUI/Views/Bookmark/Toggle.cshtml
Original file line number Diff line number Diff line change
@@ -1,136 +1,142 @@
@using System.Text.RegularExpressions
@model LearningHub.Nhs.WebUI.Models.Bookmark.EditBookmarkViewModel
@{
var bookmarkType = (Model.BookmarkTypeId == 1) ? "Folder" : "Bookmark";
var titleAction = Model.Bookmarked ? "Delete" : "Add";
var buttonAction = Model.Bookmarked ? "Delete" : "Continue";
var bookmarkType = (Model.BookmarkTypeId == 1) ? "Folder" : "Bookmark";
var titleAction = Model.Bookmarked ? "Delete" : "Add";
var buttonAction = Model.Bookmarked ? "Delete" : "Continue";

ViewData["Title"] = $"{titleAction} {bookmarkType}";
ViewData["Title"] = $"{titleAction} {bookmarkType}";

// Prepare the parameters for the back-link component.
var backToText = "Back to: ";
var returnUrl = ViewBag.ReturnUrl.ToLower();
var controller = string.Empty;
var action = string.Empty;
var routeParams = new Dictionary<string, string?>();
// Prepare the parameters for the back-link component.
var backToText = "Back to: ";
var returnUrl = ViewBag.ReturnUrl.ToLower();
var controller = string.Empty;
var action = string.Empty;
var routeParams = new Dictionary<string, string?>();

if (returnUrl == "/")
if (returnUrl == "/")
{
backToText += "Learning Hub";
controller = "home";
action = "index";
}
else if (returnUrl.Contains("/bookmark"))
{
backToText += "My bookmarks";
controller = "bookmark";
action = "index";
}
else
{
var resourceMatches = Regex.Matches(returnUrl, @"^/resource/([0-9]+)(/item)?$");
var catalogueMatches = Regex.Matches(returnUrl, @"^/catalogue/(\w+)$");

if (resourceMatches.Count > 0)
{
backToText += "Learning Hub";
controller = "home";
action = "index";
backToText += "Learning Resource";
controller = "resource";
action = "Index";
routeParams = new Dictionary<string, string?> { { "resourceReferenceId", resourceMatches[0].Groups[1].Value } };
}
else if (returnUrl == "/bookmark")
else if (catalogueMatches.Count > 0)
{
backToText += "My bookmarks";
controller = "bookmark";
action = "index";
backToText += "Catalogue";
controller = "catalogue";
action = "Index";
routeParams = new Dictionary<string, string?> { { "reference", catalogueMatches[0].Groups[1].Value } };
}
else
{
var resourceMatches = Regex.Matches(returnUrl, @"^/resource/([0-9]+)(/item)?$");
var catalogueMatches = Regex.Matches(returnUrl, @"^/catalogue/(\w+)$");

if (resourceMatches.Count > 0)
{
backToText += "Learning Resource";
controller = "resource";
action = "Index";
routeParams = new Dictionary<string, string?> { { "resourceReferenceId", resourceMatches[0].Groups[1].Value } };
}
else if (catalogueMatches.Count > 0)
{
backToText += "Catalogue";
controller = "catalogue";
action = "Index";
routeParams = new Dictionary<string, string?> { { "reference", catalogueMatches[0].Groups[1].Value } };
}
backToText += "Learning Hub";
controller = "home";
action = "index";
}
}
}

@section styles{
<link rel="stylesheet" type="text/css" href="~/css/nhsuk/pages/bookmark.css" asp-append-version="true" />
<link rel="stylesheet" type="text/css" href="~/css/nhsuk/pages/bookmark.css" asp-append-version="true" />
}

<div class="bg-white">
<div class="nhsuk-width-container app-width-container nhsuk-u-padding-bottom-9">
<vc:back-link asp-controller="@controller" asp-action="@action" asp-all-route-data="@routeParams" link-text="@backToText" />
<div class="nhsuk-width-container app-width-container nhsuk-u-padding-bottom-9">
<vc:back-link asp-controller="@controller" asp-action="@action" asp-all-route-data="@routeParams" link-text="@backToText" />

<form asp-controller="Bookmark" asp-action="BookmarkToggle" asp-route-returnUrl="@ViewBag.ReturnUrl" method="post">
<form asp-controller="Bookmark" asp-action="BookmarkToggle" asp-route-returnUrl="@ViewBag.ReturnUrl" method="post">

<vc:error-summary order-of-property-names="@(new[] { nameof(Model.Title) })" />
<vc:error-summary order-of-property-names="@(new[] { nameof(Model.Title) })" />

@if (Model.Bookmarked)
{
@if (Model.BookmarkTypeId == 1)
{
<h1>Are you sure you want to delete this folder?</h1>
<div class="nhsuk-inset-text">
<p>All bookmarks contained within the folder will also be deleted. To save any bookmarks move them out of the folder.</p>
</div>

<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
<div class="nhsuk-form-group">
<label class="nhsuk-label nhsuk-u-font-weight-bold nhsuk-u-margin-bottom-4">Folder</label>
<div class="grey-bottom-border-panel">
<p class="nhsuk-u-margin-bottom-4">@Model.Title</p>
</div>
</div>
</div>
</div>
}
else
{
<h1>Are you sure you want to remove this bookmark?</h1>
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
<div class="nhsuk-form-group">
<label class="nhsuk-label nhsuk-u-font-weight-bold nhsuk-u-margin-bottom-4">Bookmark</label>
<div class="grey-bottom-border-panel">
<p class="nhsuk-u-margin-bottom-4">@Model.Title</p>
</div>
</div>
</div>
</div>
}
}
else
{
<h1>Add @(Model.BookmarkTypeId == 1 ? "a folder" : "bookmark")</h1>
@if (Model.Bookmarked)
{
@if (Model.BookmarkTypeId == 1)
{
<h1>Are you sure you want to delete this folder?</h1>
<div class="nhsuk-inset-text">
<p>All bookmarks contained within the folder will also be deleted. To save any bookmarks move them out of the folder.</p>
</div>

<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
<div class="nhsuk-form-group">
<vc:text-input asp-for="Title"
label="Enter a @(bookmarkType.ToLower()) name"
populate-with-current-value="true"
type="text"
spell-check="false"
hint-text=""
autocomplete="off"
css-class=""
required="true"
required-client-side-error-message="@(Model.BookmarkTypeId == 1 ? "<a href='#Title'>You must enter a folder name</a>" : "<a href='#Title'>You must enter a bookmark name</a>")" />
</div>
</div>
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
<div class="nhsuk-form-group">
<label class="nhsuk-label nhsuk-u-font-weight-bold nhsuk-u-margin-bottom-4">Folder</label>
<div class="grey-bottom-border-panel">
<p class="nhsuk-u-margin-bottom-4">@Model.Title</p>
</div>
}

<div class="button-panel">
<button type="submit" class="nhsuk-button nhsuk-u-margin-bottom-0">@buttonAction</button>
<div class="nhsuk-u-margin-left-5 nhsuk-u-font-size-19">
<a class="cancel-link" href="@ViewBag.ReturnUrl">Cancel</a>
</div>
</div>
</div>
}
else
{
<h1>Are you sure you want to remove this bookmark?</h1>
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
<div class="nhsuk-form-group">
<label class="nhsuk-label nhsuk-u-font-weight-bold nhsuk-u-margin-bottom-4">Bookmark</label>
<div class="grey-bottom-border-panel">
<p class="nhsuk-u-margin-bottom-4">@Model.Title</p>
</div>
</div>
</div>
</div>
}
}
else
{
<h1>Add @(Model.BookmarkTypeId == 1 ? "a folder" : "bookmark")</h1>

<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
<div class="nhsuk-form-group">
<vc:text-input asp-for="Title"
label="Enter a @(bookmarkType.ToLower()) name"
populate-with-current-value="true"
type="text"
spell-check="false"
hint-text=""
autocomplete="off"
css-class=""
required="true"
required-client-side-error-message="@(Model.BookmarkTypeId == 1 ? "You must enter a folder name" : "You must enter a bookmark name")" />
</div>
</div>
</div>
}

<div class="button-panel">
<button type="submit" class="nhsuk-button nhsuk-u-margin-bottom-0">@buttonAction</button>
<div class="nhsuk-u-margin-left-5 nhsuk-u-font-size-19">
<a class="cancel-link" href="@ViewBag.ReturnUrl">Cancel</a>
</div>
</div>

<input type="hidden" asp-for="Id" />
<input type="hidden" asp-for="Title" data-val="false" />
<input type="hidden" asp-for="BookmarkTypeId" data-val="false" />
<input type="hidden" asp-for="Link" />
<input type="hidden" asp-for="Rri" />
<input type="hidden" asp-for="NodeId" />
<input type="hidden" asp-for="Bookmarked" data-val="false" />
</form>
</div>
<input type="hidden" asp-for="Id" />
<input type="hidden" asp-for="Title" data-val="false" />
<input type="hidden" asp-for="BookmarkTypeId" data-val="false" />
<input type="hidden" asp-for="Link" />
<input type="hidden" asp-for="Rri" />
<input type="hidden" asp-for="NodeId" />
<input type="hidden" asp-for="Bookmarked" data-val="false" />
</form>
</div>
</div>