Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HEEDLS-416 Add details to admin cards #461

Merged
merged 6 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ resharper_place_constructor_initializer_on_same_line = true
resharper_wrap_before_declaration_rpar = true
resharper_wrap_before_invocation_rpar = true
resharper_csharp_instance_members_qualify_members = none
resharper_dl_tag_contains_non_dt_or_dd_elements_highlighting = none

[*.{cs}]
indent_size = 4
Expand Down
51 changes: 51 additions & 0 deletions DigitalLearningSolutions.Web/Helpers/FilterableTagHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
namespace DigitalLearningSolutions.Web.Helpers
{
using System.Collections.Generic;
using DigitalLearningSolutions.Data.Models.User;

public static class FilterableTagHelper
{
public static IEnumerable<(string, string)> GetCurrentTagsForAdminUser(AdminUser adminUser)
stellake marked this conversation as resolved.
Show resolved Hide resolved
{
var tags = new List<(string, string)>();

// TODO: Either change these when HEEDLS-532 is merged first or change them on HEEDLS-532 if HEEDLS-416 is merged first to the AdminFilterOptions
if (adminUser.IsLocked)
{
tags.Add(("Locked", nameof(AdminUser.IsLocked) + "|true"));
}

if (adminUser.IsCentreAdmin)
{
tags.Add(("Centre administrator", nameof(AdminUser.IsCentreAdmin) + "|true"));
}

if (adminUser.IsSupervisor)
{
tags.Add(("Supervisor", nameof(AdminUser.IsSupervisor) + "|true"));
}

if (adminUser.IsTrainer)
{
tags.Add(("Trainer", nameof(AdminUser.IsTrainer) + "|true"));
}

if (adminUser.IsContentCreator)
{
tags.Add(("Content Creator license", nameof(AdminUser.IsContentCreator) + "|true"));
}

if (adminUser.IsCmsAdministrator)
{
tags.Add(("CMS administrator", nameof(AdminUser.IsCmsAdministrator) + "|true"));
}

if (adminUser.IsContentManager)
{
tags.Add(("CMS manager", nameof(AdminUser.IsContentManager) + "|true"));
}

return tags;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
namespace DigitalLearningSolutions.Web.ViewModels.TrackingSystem.Centre.Administrator
{
using System.Collections.Generic;
using DigitalLearningSolutions.Data.Models.User;
using DigitalLearningSolutions.Web.Helpers;

public class SearchableAdminViewModel
{
public SearchableAdminViewModel(AdminUser adminUser)
{
Id = adminUser.Id;
Name = adminUser.SearchableName;
CategoryName = adminUser.CategoryName;
CategoryName = adminUser.CategoryName ?? "All";
EmailAddress = adminUser.EmailAddress;
IsLocked = adminUser.IsLocked;
Tags = FilterableTagHelper.GetCurrentTagsForAdminUser(adminUser);
}

public int Id { get; set; }

public string Name { get; set; }

public string? CategoryName { get; set; }
public string CategoryName { get; set; }

public string? EmailAddress { get; set; }

public bool IsLocked { get; set; }

public IEnumerable<(string, string)> Tags { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,64 @@
<div class="searchable-element nhsuk-panel" id="@Model.Id-card">
<details class="nhsuk-details nhsuk-expander nhsuk-u-margin-bottom-0">
<summary class="nhsuk-details__summary nhsuk-u-padding-top-0 nhsuk-u-padding-left-0">
<span class="nhsuk-details__summary-text searchable-element-title" id="@Model.Id-name" name="name" role="heading" aria-level="2">
<span class="nhsuk-details__summary-text searchable-element-title" id="@Model.Id-name" name="name">
@Model.Name
</span>
</summary>
<div class="nhsuk-details__text">

<div class="nhsuk-grid-row">
<div class="tags">
@if (!Model.IsLocked) {
<div class="tag nhsuk-u-font-size-14" value="@("IsLocked|false")" hidden>
Not locked
</div>
}
DanBloxham-sw marked this conversation as resolved.
Show resolved Hide resolved
@foreach (var (displayText, filter) in Model.Tags) {
<div class="tag nhsuk-u-font-size-14" value="@filter">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should leave adding these values until we determine that they're needed for JS to keep the MRs more concise and relevant to the ticket and to avoid forgetting to remove the code if the JS version approach ends up being different.. 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(unless you think it will be more work than worth it as I don't feel particularly strongly)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any point removing them now I've already added them until I find they aren't needed. I think they'll be used given the approximate plan I have for the JS filtering

@displayText
</div>
}
DanBloxham-sw marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
<div class="nhsuk-grid-row">
<dl class="nhsuk-summary-list">
<div class="nhsuk-summary-list__row">
<dt class="nhsuk-summary-list__key">
Email:
</dt>
<dd class="nhsuk-summary-list__value">
@Model.EmailAddress
</dd>
</div>
<div class="nhsuk-summary-list__row">
<dt class="nhsuk-summary-list__key">
Course category:
stellake marked this conversation as resolved.
Show resolved Hide resolved
</dt>
<dd class="nhsuk-summary-list__value" name="CategoryName|@Model.CategoryName">
@Model.CategoryName
</dd>
</div>
</dl>
</div>
@if (Model.IsLocked) {
<div class="nhsuk-grid-row">
<p class="nhsuk-body-m">This account is currently locked out</p>
</div>
}
<div class="nhsuk-grid-row">
@if (Model.IsLocked) {
<a class="nhsuk-button left-button-mobile-margin-bottom nhsuk-u-margin-right-2 nhsuk-u-margin-bottom-1" role="button">
Unlock account
</a>
} else {
<a class="nhsuk-button left-button-mobile-margin-bottom nhsuk-u-margin-right-2 nhsuk-u-margin-bottom-1" role="button">
Manage Roles
</a>
}
<a class="nhsuk-button delete-button nhsuk-button--secondary nhsuk-u-margin-bottom-1" role="button">
stellake marked this conversation as resolved.
Show resolved Hide resolved
Deactivate admin account
</a>
</div>
</div>
</details>
</div>