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

Bg/174545 1619 closed created in error #448

Merged
merged 4 commits into from
Sep 22, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ public GroupEditorViewModelValidator(IGroupReadService groupReadService, IEstabl
.Must(x => x.IsValid() || x.IsEmpty())
.WithMessage(x => $"{x.OpenDateLabel} is invalid. Please enter a valid date");

When(x => x.CloseAndMarkAsCreatedInError && x.StatusId == (int) eLookupGroupStatus.Closed, () =>
{
RuleFor(x => x.CloseAndMarkAsCreatedInError)
.Must(x => false)
.WithMessage("Please enter either a closed date or created in error");

RuleFor(x => x.ClosedDate)
.Must(x => false)
.WithMessage("Please enter either a closed date or created in error");
});

When(x => x.CanUserEditClosedDate
&& x.GroupType == eLookupGroupType.MultiacademyTrust
&& x.OriginalStatusId != (int) eLookupGroupStatus.Closed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ public static bool LocalAuthorityIsEditable(GroupEditorViewModel viewModel, IPri

public static bool UserCanCloseAndMarkAsCreatedInError(GroupEditorViewModel viewModel, IPrincipal user)
{
var checkRefreshForCreatedInError = (viewModel.CloseAndMarkAsCreatedInErrorLabel != null) == (viewModel.StatusId.OneOfThese(eLookupGroupStatus.Closed));

return viewModel.GroupType.OneOfThese(eLookupGroupType.MultiacademyTrust,
eLookupGroupType.SingleacademyTrust,
eLookupGroupType.SchoolSponsor,
eLookupGroupType.Federation,
eLookupGroupType.SecureSingleAcademyTrust)
&& !viewModel.StatusId.OneOfThese(eLookupGroupStatus.CreatedInError, eLookupGroupStatus.Closed)
&& !viewModel.StatusId.OneOfThese(eLookupGroupStatus.CreatedInError)
&& checkRefreshForCreatedInError
&& user.InRole(AuthorizedRoles.IsAdmin);
}

Expand Down
20 changes: 10 additions & 10 deletions Web/Edubase.Web.UI/Areas/Groups/Views/Group/EditDetails.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,22 @@
}



@if (Model.CanUserCloseAndMarkAsCreatedInError)
{
// var groupTypeShortName = Model.GroupTypeId == 5 ? Model.GroupTypeName.ToLower() : "trust";

<div class="govuk-form-group">
@FormHelpers.GiasCheckbox("true",
nameof(Model.CloseAndMarkAsCreatedInError),
Model.CloseAndMarkAsCreatedInErrorLabel,
" govuk-!-padding-top-0",
new { id = "close-created-in-error" })
</div>
<div class="govuk-form-group @Html.ValidationCssClassFor(x => x.CloseAndMarkAsCreatedInError)">
@Html.ValidationMessageFor(x => x.CloseAndMarkAsCreatedInError, null, new { @class = "govuk-error-message" })
@FormHelpers.GiasCheckbox("true",
nameof(Model.CloseAndMarkAsCreatedInError),
Model.CloseAndMarkAsCreatedInErrorLabel,
" govuk-!-padding-top-0",
new { id = "CloseAndMarkAsCreatedInError" },
Model.CloseAndMarkAsCreatedInError)
</div>
}

</div>
</div>
</div>

<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
Expand Down
4 changes: 2 additions & 2 deletions Web/Edubase.Web.UI/Helpers/FormHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
Expand Down Expand Up @@ -187,7 +187,7 @@ public static class FormHelpers
checkbox.Attributes["type"] = "checkbox";
checkbox.Attributes["name"] = inputName;
checkbox.Attributes["value"] = inputValue;
checkbox.Attributes["class"] = "govuk-checkboxes__input";
checkbox.Attributes["class"] = "govuk-checkboxes__input govuk-input";

if (isChecked)
{
Expand Down
Loading