From cf05d989a03e2dd266f8c25c3c5b4197505c9d7f Mon Sep 17 00:00:00 2001 From: Ivan Lieckens Date: Thu, 28 Nov 2024 16:04:37 +0100 Subject: [PATCH 1/3] Maxed textareas to 2000 characters --- .../Models/Apply/ApplicationFormModel.cs | 8 ++++++- .../ContributionsStep.cshtml | 2 ++ .../ObjectivesStep.cshtml | 5 +++- .../Views/Shared/_Layout.cshtml | 2 +- .../wwwroot/js/mvp-site.es5.js | 13 +++++++++++ .../wwwroot/js/mvp-site.es5.min.js | 2 +- .../MvpSite.Rendering/wwwroot/js/mvp-site.js | 14 +++++++++++ .../sass/components/selections/_form.scss | 4 ++++ .../MvpSite.Rendering/wwwroot/style/main.css | 23 ++++++++++++++++++- .../wwwroot/style/main.min.css | 2 +- 10 files changed, 69 insertions(+), 6 deletions(-) diff --git a/headapps/MvpSite/MvpSite.Rendering/Models/Apply/ApplicationFormModel.cs b/headapps/MvpSite/MvpSite.Rendering/Models/Apply/ApplicationFormModel.cs index eb963dbb..52e977fe 100644 --- a/headapps/MvpSite/MvpSite.Rendering/Models/Apply/ApplicationFormModel.cs +++ b/headapps/MvpSite/MvpSite.Rendering/Models/Apply/ApplicationFormModel.cs @@ -1,10 +1,13 @@ -using Mvp.Selections.Domain; +using System.ComponentModel.DataAnnotations; +using Mvp.Selections.Domain; using Sitecore.AspNetCore.SDK.LayoutService.Client.Response.Model.Fields; namespace MvpSite.Rendering.Models.Apply; public class ApplicationFormModel : BaseModel { + public const int LargeTextFieldLength = 2000; + public Application? CurrentApplication { get; set; } public Selection? CurrentSelection { get; set; } @@ -63,10 +66,12 @@ public class ApplicationFormModel : BaseModel public TextField? EligibilityLabel { get; set; } + [StringLength(LargeTextFieldLength)] public string? Eligibility { get; set; } public TextField? ObjectivesLabel { get; set; } + [StringLength(LargeTextFieldLength)] public string? Objectives { get; set; } public TextField? MentorsLabel { get; set; } @@ -83,6 +88,7 @@ public class ApplicationFormModel : BaseModel public TextField? ContributionDescriptionLabel { get; set; } + [StringLength(LargeTextFieldLength)] public string? ContributionDescription { get; set; } public TextField? ContributionLinkLabel { get; set; } diff --git a/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/ApplyApplicationForm/ContributionsStep.cshtml b/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/ApplyApplicationForm/ContributionsStep.cshtml index 38da20ad..82343603 100644 --- a/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/ApplyApplicationForm/ContributionsStep.cshtml +++ b/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/ApplyApplicationForm/ContributionsStep.cshtml @@ -1,4 +1,5 @@ @using Mvp.Selections.Domain +@using MvpSite.Rendering.Models.Apply @model MvpSite.Rendering.Models.Apply.ApplicationFormModel
@@ -56,6 +57,7 @@ @(Model.IsEditing ? Html.Raw(Model.ContributionDescriptionLabel?.EditableMarkup) : Model.ContributionDescriptionLabel?.Value) + @(Model.ContributionDescription?.Length.ToString() ?? "0") / @ApplicationFormModel.LargeTextFieldLength
diff --git a/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/ApplyApplicationForm/ObjectivesStep.cshtml b/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/ApplyApplicationForm/ObjectivesStep.cshtml index 1b659402..010030c9 100644 --- a/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/ApplyApplicationForm/ObjectivesStep.cshtml +++ b/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/ApplyApplicationForm/ObjectivesStep.cshtml @@ -1,4 +1,5 @@ -@model MvpSite.Rendering.Models.Apply.ApplicationFormModel +@using MvpSite.Rendering.Models.Apply +@model MvpSite.Rendering.Models.Apply.ApplicationFormModel
@@ -22,6 +23,7 @@ * + @(Model.Eligibility?.Length.ToString() ?? "0") / @ApplicationFormModel.LargeTextFieldLength
* + @(Model.Objectives?.Length.ToString() ?? "0") / @ApplicationFormModel.LargeTextFieldLength

diff --git a/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/AdminScoreCards/Default.cshtml b/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/AdminScoreCards/Default.cshtml index 85b02802..85477745 100644 --- a/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/AdminScoreCards/Default.cshtml +++ b/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/AdminScoreCards/Default.cshtml @@ -58,7 +58,7 @@ @if (!string.IsNullOrWhiteSpace(card.Applicant?.ImageUri?.ToString())) { - @card.Applicant.Name + @card.Applicant.Name } else { diff --git a/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/SitecoreComponent/MainNav.cshtml b/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/SitecoreComponent/MainNav.cshtml index 64862285..2707e022 100644 --- a/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/SitecoreComponent/MainNav.cshtml +++ b/headapps/MvpSite/MvpSite.Rendering/Views/Shared/Components/SitecoreComponent/MainNav.cshtml @@ -14,27 +14,28 @@ + \ No newline at end of file From 72fa4ba7d4efa00a136d81e8aa2618955f60e2f2 Mon Sep 17 00:00:00 2001 From: Ivan Lieckens Date: Fri, 29 Nov 2024 09:28:15 +0100 Subject: [PATCH 3/3] Fix deleting fields by submitting --- .../ViewComponents/Apply/ApplicationFormViewComponent.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/headapps/MvpSite/MvpSite.Rendering/ViewComponents/Apply/ApplicationFormViewComponent.cs b/headapps/MvpSite/MvpSite.Rendering/ViewComponents/Apply/ApplicationFormViewComponent.cs index 2031eb08..49f33221 100644 --- a/headapps/MvpSite/MvpSite.Rendering/ViewComponents/Apply/ApplicationFormViewComponent.cs +++ b/headapps/MvpSite/MvpSite.Rendering/ViewComponents/Apply/ApplicationFormViewComponent.cs @@ -544,13 +544,10 @@ private async Task ExecuteConfirmationStep(ApplicationFormModel model) { model.NextStep = ApplicationStep.Confirmation; } - else if (model.IsNavigation.HasValue && !model.IsNavigation.Value && model.UnderstandsReviewConsent && model is { UnderstandsProgramAgreement: true, IsComplete: true }) + else if (model.IsNavigation.HasValue && !model.IsNavigation.Value && model.UnderstandsReviewConsent && model is { UnderstandsProgramAgreement: true, IsComplete: true, CurrentApplication: not null }) { - Application updateApplication = new(model.CurrentApplication!.Id) - { - Status = ApplicationStatus.Submitted - }; - Response applicationResponse = await Client.UpdateApplicationAsync(updateApplication); + model.CurrentApplication.Status = ApplicationStatus.Submitted; + Response applicationResponse = await Client.UpdateApplicationAsync(model.CurrentApplication); if (applicationResponse is { StatusCode: HttpStatusCode.OK, Result: not null }) { model.CurrentApplication = applicationResponse.Result;