Skip to content

Commit

Permalink
MLPAB-1255 Remove in some other way logic for step in page (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Oct 18, 2023
1 parent b4f1c27 commit 41c83a9
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 84 deletions.
12 changes: 5 additions & 7 deletions internal/page/donor/how_should_replacement_attorneys_step_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ import (
)

type howShouldReplacementAttorneysStepInData struct {
App page.AppData
Errors validation.List
AllowSomeOtherWay bool
Form *howShouldReplacementAttorneysStepInForm
Options page.ReplacementAttorneysStepInOptions
App page.AppData
Errors validation.List
Form *howShouldReplacementAttorneysStepInForm
Options page.ReplacementAttorneysStepInOptions
}

func HowShouldReplacementAttorneysStepIn(tmpl template.Template, donorStore DonorStore) Handler {
return func(appData page.AppData, w http.ResponseWriter, r *http.Request, lpa *page.Lpa) error {
data := &howShouldReplacementAttorneysStepInData{
App: appData,
AllowSomeOtherWay: lpa.ReplacementAttorneys.Len() == 1,
App: appData,
Form: &howShouldReplacementAttorneysStepInForm{
WhenToStepIn: lpa.HowShouldReplacementAttorneysStepIn,
OtherDetails: lpa.HowShouldReplacementAttorneysStepInDetails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,25 @@ import (
)

func TestGetHowShouldReplacementAttorneysStepIn(t *testing.T) {
testcases := map[string]struct {
attorneys actor.Attorneys
allowSomeOtherWay bool
}{
"single": {
attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}},
allowSomeOtherWay: true,
},
"multiple": {
attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}, {}}},
allowSomeOtherWay: false,
},
}

for name, tc := range testcases {
t.Run(name, func(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/", nil)
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/", nil)

template := newMockTemplate(t)
template.
On("Execute", w, &howShouldReplacementAttorneysStepInData{
App: testAppData,
AllowSomeOtherWay: tc.allowSomeOtherWay,
Form: &howShouldReplacementAttorneysStepInForm{},
Options: page.ReplacementAttorneysStepInValues,
}).
Return(nil)
template := newMockTemplate(t)
template.
On("Execute", w, &howShouldReplacementAttorneysStepInData{
App: testAppData,
Form: &howShouldReplacementAttorneysStepInForm{},
Options: page.ReplacementAttorneysStepInValues,
}).
Return(nil)

err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &page.Lpa{
ReplacementAttorneys: tc.attorneys,
})
resp := w.Result()
err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &page.Lpa{
ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}},
})
resp := w.Result()

assert.Nil(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
})
}
assert.Nil(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
}

func TestGetHowShouldReplacementAttorneysStepInFromStore(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@
"howYourReplacementAttorneysShouldStepIn": "Sut dylai eich atwrneiod wrth gefn gamu i mewn",
"howShouldYourReplacementAttorneysStepIn": "Sut dylai eich atwrneiod wrth gefn gamu i mewn?",
"howShouldReplacementAttorneysStepInDetailSomeOtherWay": "<p class=\"govuk-body\">Gallwch ddewis pryd fydd eich atwrneiod wrth gefn yn camu i mewn ac ym mha drefn.</p><p class=\"govuk-body\">Mae’r rhan fwyaf o roddwyr yn dewis i’w holl atwrneiod wrth gefn gamu i mewn ar yr un pryd, hynny yw, cyn gynted ag y bydd <span class=\"govuk-!-font-weight-bold\">un</span> o’u hatwrneiod gwreiddiol yn methu â gweithredu mwyach. Serch hynny, os byddai’n well gennych i’ch atwrneiod wrth gefn gamu i mewn yn hwyrach neu mewn trefn benodol, dewiswch un o’r 2 opsiwn arall.</p>",
"howShouldReplacementAttorneysStepInDetail": "<p class=\"govuk-body\">Gallwch ddewis pryd fydd eich atwrneiod wrth gefn yn camu i mewn ac ym mha drefn.</p><p class=\"govuk-body\">Mae’r rhan fwyaf o roddwyr yn dewis i’w holl atwrneiod wrth gefn gamu i mewn ar yr un pryd, hynny yw, cyn gynted ag y bydd un o’u hatwrneiod gwreiddiol yn methu â gweithredu mwyach. Serch hynny, os byddai’n well gennych i’ch atwrneiod wrth gefn gamu i mewn yn hwyrach neu mewn trefn benodol, dewiswch un o’r 2 opsiwn arall.</p>",
"whenOneCanNoLongerAct": "Cyn gynted ag y bydd un o’ch atwrneiod gwreiddiol yn methu â gweithredu mwyach, dylai eich holl atwrneiod wrth gefn gamu i mewn ar yr un pryd. Byddant yn gallu gwneud penderfyniadau ar y cyd ac yn unigol.",
"whenNoneCanNoLongerAct": "Pan na all unrhyw un o’ch atwrneiod gwreiddiol weithredu, bydd eich holl atwrneiod wrth gefn yn camu i mewn ar yr un pryd. Gallwch ddewis sut maen nhw’n gwneud penderfyniadau ar y dudalen nesaf.",
"otherWay": "Mewn rhyw ffordd arall",
Expand Down
1 change: 0 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@
"howYourReplacementAttorneysShouldStepIn": "How your replacement attorneys should step in",
"howShouldYourReplacementAttorneysStepIn": "How should your replacement attorneys step in?",
"howShouldReplacementAttorneysStepInDetailSomeOtherWay": "<p class=\"govuk-body\">You can choose when your replacement attorneys step in and in what order.</p><p class=\"govuk-body\">Most donors choose for all their replacement attorneys to step in at the same time, as soon as <span class=\"govuk-!-font-weight-bold\">one</span> of their original attorneys can no longer act. However, if you would prefer your replacement attorneys to step in later or in a specific order, select one of the other 2 options.</p>",
"howShouldReplacementAttorneysStepInDetail": "<p class=\"govuk-body\">You can choose when your replacement attorneys step in and in what order.</p><p class=\"govuk-body\">Most donors choose for all their replacement attorneys to step in at the same time, as soon as <span class=\"govuk-!-font-weight-bold\">one</span> of their original attorneys can no longer act. However, if you would prefer your replacement attorneys to step in later or in a specific order, select the second option.</p>",
"whenOneCanNoLongerAct": "As soon as <span class=\"govuk-!-font-weight-bold\">one</span> of your original attorneys can no longer act, all your replacement attorneys should step in at the same time. They will be able to make decisions jointly and severally.",
"whenNoneCanNoLongerAct": "When <span class=\"govuk-!-font-weight-bold\">none</span> of your original attorneys can act, all your replacement attorneys will step in at the same time. You can choose how they make decisions on the next page.",
"otherWay": "In some other way",
Expand Down
40 changes: 21 additions & 19 deletions web/template/fixtures.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,28 @@
</fieldset>
</div>

<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend">Progress</legend>
<div class="govuk-form-group">
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend">Progress</legend>

{{ template "radios" (items . "progress" nil
(item "provideYourDetails" "provideYourDetails")
(item "chooseYourAttorneys" "chooseYourAttorneys")
(item "chooseYourReplacementAttorneys" "chooseYourReplacementAttorneys")
(item "Choose when the LPA can be used / Life-sustaining treatment" "chooseWhenTheLpaCanBeUsed")
(item "addRestrictionsToTheLpa" "addRestrictionsToTheLpa")
(item "chooseYourCertificateProvider" "chooseYourCertificateProvider")
(item "peopleToNotifyAboutYourLpa" "peopleToNotifyAboutYourLpa")
(item "checkAndSendToYourCertificateProvider" "checkAndSendToYourCertificateProvider")
(item "payForTheLpa" "payForTheLpa")
(item "confirmYourIdentityAndSignTheLpa" "confirmYourIdentityAndSignTheLpa")
(item "signedByCertificateProvider" "signedByCertificateProvider")
(item "signedByAttorneys" "signedByAttorneys")
(item "submitted" "submitted")
(item "registered" "registered")
) }}
</fieldset>
{{ template "radios" (items . "progress" nil
(item "provideYourDetails" "provideYourDetails")
(item "chooseYourAttorneys" "chooseYourAttorneys")
(item "chooseYourReplacementAttorneys" "chooseYourReplacementAttorneys")
(item "Choose when the LPA can be used / Life-sustaining treatment" "chooseWhenTheLpaCanBeUsed")
(item "addRestrictionsToTheLpa" "addRestrictionsToTheLpa")
(item "chooseYourCertificateProvider" "chooseYourCertificateProvider")
(item "peopleToNotifyAboutYourLpa" "peopleToNotifyAboutYourLpa")
(item "checkAndSendToYourCertificateProvider" "checkAndSendToYourCertificateProvider")
(item "payForTheLpa" "payForTheLpa")
(item "confirmYourIdentityAndSignTheLpa" "confirmYourIdentityAndSign")
(item "signedByCertificateProvider" "Signed by certificate provider")
(item "signedByAttorneys" "Signed by attorneys")
(item "submitted" "Submitted")
(item "registered" "registered")
) }}
</fieldset>
</div>

<button type="submit" class="govuk-button" data-module="govuk-button" name="journey" value="donor">Start</button>

Expand Down
36 changes: 15 additions & 21 deletions web/template/how_should_replacement_attorneys_step_in.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">{{ tr .App "whenYourReplacementAttorneysStepIn" }}</h1>

{{ if .AllowSomeOtherWay }}
{{ trHtml .App "howShouldReplacementAttorneysStepInDetailSomeOtherWay" }}
{{ else }}
{{ trHtml .App "howShouldReplacementAttorneysStepInDetail" }}
{{ end }}
{{ trHtml .App "howShouldReplacementAttorneysStepInDetailSomeOtherWay" }}

<form novalidate method="post">
<div class="govuk-form-group {{ if .Errors.Has "when-to-step-in" }}govuk-form-group--error{{ end }}">
Expand All @@ -35,25 +31,23 @@
{{ trHtml .App "whenNoneCanNoLongerAct" }}
</label>
</div>
{{ if .AllowSomeOtherWay }}
<div class="govuk-radios__item">
<input class="govuk-radios__input" id="f-when-to-step-in-3" name="when-to-step-in" type="radio" value="{{ .Options.AnotherWay.String }}" aria-describedby="when-to-step-in-3-item-hint" aria-controls="when-to-step-in-3-conditional-div" {{ if or (eq .Options.AnotherWay .Form.WhenToStepIn) (.Errors.Has "other-details") }}checked{{ end }}>
<label class="govuk-label govuk-radios__label" for="f-when-to-step-in-3">
{{ tr .App "otherWay" }}
</label>
<div class="govuk-radios__item">
<input class="govuk-radios__input" id="f-when-to-step-in-3" name="when-to-step-in" type="radio" value="{{ .Options.AnotherWay.String }}" aria-describedby="when-to-step-in-3-item-hint" aria-controls="when-to-step-in-3-conditional-div" {{ if or (eq .Options.AnotherWay .Form.WhenToStepIn) (.Errors.Has "other-details") }}checked{{ end }}>
<label class="govuk-label govuk-radios__label" for="f-when-to-step-in-3">
{{ tr .App "otherWay" }}
</label>

<div class="govuk-radios__conditional" id="when-to-step-in-3-conditional-div">
<div class="govuk-form-group {{ if .Errors.Has "other-details" }}govuk-form-group--error{{ end }}">
<p class="govuk-body">{{ tr .App "otherWayHint" }}</p>
<label class="govuk-label" for="f-other-details">
{{ tr .App "details" }}
</label>
{{ template "error-message" (errorMessage . "other-details") }}
<textarea class="govuk-textarea {{ if .Errors.Has "other-details" }}govuk-input--error{{ end }}" id="f-other-details" name="other-details" rows="10">{{ .Form.OtherDetails }}</textarea>
</div>
<div class="govuk-radios__conditional" id="when-to-step-in-3-conditional-div">
<div class="govuk-form-group {{ if .Errors.Has "other-details" }}govuk-form-group--error{{ end }}">
<p class="govuk-body">{{ tr .App "otherWayHint" }}</p>
<label class="govuk-label" for="f-other-details">
{{ tr .App "details" }}
</label>
{{ template "error-message" (errorMessage . "other-details") }}
<textarea class="govuk-textarea {{ if .Errors.Has "other-details" }}govuk-input--error{{ end }}" id="f-other-details" name="other-details" rows="10">{{ .Form.OtherDetails }}</textarea>
</div>
</div>
{{ end }}
</div>
</div>
</fieldset>
</div>
Expand Down

0 comments on commit 41c83a9

Please sign in to comment.