Skip to content

Commit

Permalink
Merge cc3199f into a8df668
Browse files Browse the repository at this point in the history
  • Loading branch information
acsauk authored Jun 4, 2024
2 parents a8df668 + cc3199f commit 2ac869d
Show file tree
Hide file tree
Showing 15 changed files with 269 additions and 406 deletions.
2 changes: 1 addition & 1 deletion docker/mlpa/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ COPY --from=asset-env /app/web/static web/static

ARG TARGETOS TARGETARCH

RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go install github.com/cosmtrek/air@latest && go install github.com/go-delve/delve/cmd/dlv@latest
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go install github.com/air-verse/air@latest && go install github.com/go-delve/delve/cmd/dlv@latest

ENTRYPOINT ["air"]

Expand Down
54 changes: 41 additions & 13 deletions internal/templatefn/fn.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/localize"
"github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore"
"github.com/ministryofjustice/opg-modernising-lpa/internal/page"
"github.com/ministryofjustice/opg-modernising-lpa/internal/place"
)

// Globals contains values that are used in templates and do not change as the
Expand Down Expand Up @@ -51,7 +52,7 @@ func All(globals *Globals) map[string]any {
"details": details,
"inc": inc,
"link": link,
"contains": contains,
"stringContains": strings.Contains,
"tr": tr,
"trFormat": trFormat,
"trFormatHtml": trFormatHtml,
Expand Down Expand Up @@ -79,6 +80,9 @@ func All(globals *Globals) map[string]any {
"notificationBanner": notificationBanner,
"checkboxEq": checkboxEq,
"lpaDecisions": lpaDecisions,
"summaryRow": summaryRow,
"addressSummaryRow": addressSummaryRow,
"optionalSummaryRow": optionalSummaryRow,
}
}

Expand Down Expand Up @@ -184,18 +188,6 @@ func link(app page.AppData, path string) string {
return app.Lang.URL(path)
}

func contains(needle string, list any) bool {
if list == nil {
return false
}

if slist, ok := list.([]string); ok {
return slices.Contains(slist, needle)
}

return false
}

// checkboxEq allows matching in the checkboxes.gohtml template for a value that
// is a list of strings, or a single string (where we are emulating a switch)
func checkboxEq(needle string, in any) bool {
Expand Down Expand Up @@ -496,3 +488,39 @@ func lpaDecisions(app page.AppData, lpa any, canChange bool) lpaDecisionsData {

return data
}

func summaryRow(app page.AppData, label, value, changeLink, fullName string, canChange, summarisingSelf bool) map[string]any {
return map[string]any{
"App": app,
"Label": label,
"Value": value,
"ChangeLink": changeLink,
"FullName": fullName,
"CanChange": canChange,
"SummarisingSelf": summarisingSelf,
}
}

func addressSummaryRow(app page.AppData, label string, address place.Address, changeLink, fullName string, canChange, summarisingSelf bool) map[string]any {
return map[string]any{
"App": app,
"Label": label,
"Address": address,
"ChangeLink": changeLink,
"FullName": fullName,
"CanChange": canChange,
"SummarisingSelf": summarisingSelf,
}
}

func optionalSummaryRow(app page.AppData, label, value, changeLink, fullName string, canChange, summarisingSelf bool) map[string]any {
return map[string]any{
"App": app,
"Label": label,
"Value": value,
"ChangeLink": changeLink,
"FullName": fullName,
"CanChange": canChange,
"SummarisingSelf": summarisingSelf,
}
}
62 changes: 55 additions & 7 deletions internal/templatefn/fn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ministryofjustice/opg-modernising-lpa/internal/localize"
"github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore"
"github.com/ministryofjustice/opg-modernising-lpa/internal/page"
"github.com/ministryofjustice/opg-modernising-lpa/internal/place"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -158,13 +159,6 @@ func TestLink(t *testing.T) {
assert.Equal(t, "/cy/dashboard", link(page.AppData{Lang: localize.Cy}, "/dashboard"))
}

func TestContains(t *testing.T) {
assert.True(t, contains("b", []string{"a", "b", "c"}))
assert.False(t, contains("d", []string{"a", "b", "c"}))

assert.False(t, contains("", nil))
}

func TestCheckboxEq(t *testing.T) {
assert.True(t, checkboxEq("b", []string{"a", "b", "c"}))
assert.False(t, checkboxEq("d", []string{"a", "b", "c"}))
Expand Down Expand Up @@ -560,3 +554,57 @@ func TestLpaDecisionsWithDonorProvidedDetails(t *testing.T) {
CanChange: true,
}, lpaDecisions(app, &actor.DonorProvidedDetails{}, true))
}

func TestSummaryRow(t *testing.T) {
app := page.AppData{SessionID: "abc"}
label := "a-label"
value := "aValue"
changeLink := "a-link.com"
fullName := "Full Name"

assert.Equal(t, map[string]any{
"App": app,
"Label": label,
"Value": value,
"ChangeLink": changeLink,
"FullName": fullName,
"CanChange": true,
"SummarisingSelf": true,
}, summaryRow(app, label, value, changeLink, fullName, true, true))
}

func TestAddressSummaryRow(t *testing.T) {
app := page.AppData{SessionID: "abc"}
label := "a-label"
address := place.Address{Line1: "a"}
changeLink := "a-link.com"
fullName := "Full Name"

assert.Equal(t, map[string]any{
"App": app,
"Label": label,
"Address": address,
"ChangeLink": changeLink,
"FullName": fullName,
"CanChange": true,
"SummarisingSelf": true,
}, addressSummaryRow(app, label, address, changeLink, fullName, true, true))
}

func TestOptionalSummaryRow(t *testing.T) {
app := page.AppData{SessionID: "abc"}
label := "a-label"
value := "aValue"
changeLink := "a-link.com"
fullName := "Full Name"

assert.Equal(t, map[string]any{
"App": app,
"Label": label,
"Value": value,
"ChangeLink": changeLink,
"FullName": fullName,
"CanChange": true,
"SummarisingSelf": true,
}, optionalSummaryRow(app, label, value, changeLink, fullName, true, true))
}
11 changes: 3 additions & 8 deletions lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@
"many": "Rydych wedi ychwanegu {{.PluralCount}} o atwrneiod",
"other": "Rydych wedi ychwanegu {{.PluralCount}} o atwrneiod"
},
"changeNameLinkText": "Newid<span class=\"govuk-visually-hidden\"> enw am {{ .FirstNames }} {{ .LastName }}</span>",
"changeDOBLinkText": "Newid<span class=\"govuk-visually-hidden\"> dyddiad geni am {{ .FirstNames }} {{ .LastName }}</span>",
"changeEmailLinkText": "Newid<span class=\"govuk-visually-hidden\"> e-bost am {{ .FirstNames }} {{ .LastName }}</span>",
"changeAddressLink": "Newid<span class=\"govuk-visually-hidden\"> cyfeiriad am {{ .FirstNames }} {{ .LastName }}</span>",
"doYouWantToAddAnotherAttorney": "Ydych chi eisiau ychwanegu atwrnai gwreiddiol arall?",
"yesToAddAnotherAttorney": "ie i ychwanegu atwrnai arall",
"yesToAddAnotherReplacementAttorney": "ie i ychwanegu atwrnai wrth gefn arall",
Expand Down Expand Up @@ -669,10 +665,8 @@
"whatToDoIfAnyDetailsAreIncorrect": "Beth i’w wneud os yw unrhyw rai o’r manylion a roddwyd amdanoch yn anghywir",
"whatToDoIfAnyDetailsAreIncorrectAttorneyContent": "<p class=\"govuk-body\">Os byddwch yn gweld camgymeriad yn yr enw, y dyddiad geni neu’r cyfeiriad y mae’r rhoddwr wedi’u darparu ar eich cyfer, ni ddylech barhau.</p><p class=\"govuk-body\">Bydd angen i chi roi gwybod i’r rhoddwr fel y bydd yn gallu newid eich manylion.</p><p class=\"govuk-body\">Unwaith y bydd wedi newid eich manylion, bydd angen i chi fewngofnodi eto a chadarnhau bod eich manylion yn gywir.</p>",
"anyErrorsInYourDetailsCanDelay": "Gall unrhyw gamgymeriadau yn eich manylion achosi oedi cyn prosesu’r LPA.",
"changeDateOfBirthLink": "Newid<span class=\"govuk-visually-hidden\"> dyddiad geni</span>",
"mobileNumber": "Rhif ffôn symudol",
"telephoneNumber": "Rhif ffôn",
"changeTelephoneNumberLink": "Newid<span class=\"govuk-visually-hidden\"> y rhif ffôn</span>",
"anyErrorsInYourDetailsCanMakeLpaDifficultToUse": "Os bydd unrhyw wallau yn eich manylion, gall hynny ei gwneud yn anodd defnyddio’r LPA. Mae’n bosibl na fydd sefydliadau’n derbyn yr LPA os nad yw’ch manylion yn cyfateb i’ch data adnabod.",
"youHaveUnsavedChanges": "Rydych wedi gwneud newidiadau sydd heb eu cadw",
"unsavedChangesDialogContent": "I gadw’r rhain, ewch yn ôl i’r dudalen a dewis <span class=\"govuk-body govuk-!-font-weight-bold\">Cadw a pharhau</span>.",
Expand Down Expand Up @@ -950,7 +944,6 @@
"yourHomeAddressWillNotBeShown": "Ni fydd cyfeiriad eich cartref yn cael ei ddangos i’r rhoddwr ac ni fydd yn ymddangos ar yr LPA ar ôl ei chwblhau.",
"selectYourHomeAddress": "Dewis eich cyfeiriad cartref",
"yourHomeAddress": "Eich cyfeiriad cartref",
"changeHomeAddressLink": "Newid eich<span class=\"govuk-visually-hidden\"> cyfeiriad cartref</span>",
"homeAddress": "Cyfeiriad cartref",
"goToDashboard": "I’r dangosfwrdd",
"printThisPage": "Argraffu’r dudalen hon",
Expand Down Expand Up @@ -1202,5 +1195,7 @@
"weHaveContactedDonorToLetThemKnowYourDecision": "Welsh {{ .DonorFullName }} Welsh",
"reportAConcernContent": "<h2 class=\"govuk-heading-m\">Welsh</h2> <p class=\"govuk-body\">Welsh:</p> <ul class=\"govuk-list govuk-list--bullet\"> <li>Welsh: 0115 934 2777</li> <li>Welsh: <a class=\"govuk-link\" href=\"mailto:[email protected]\">[email protected]</a> </li> </ul> <p class=\"govuk-body\">Welsh <a class=\"govuk-link\" href=\"#\">Welsh</a> Welsh</p>",
"yourAddress": "Welsh",
"yourAddressWarning": "Welsh"
"yourAddressWarning": "Welsh",
"enter": "Welsh",
"forFullName": "Welsh {{ .FullName }}"
}
11 changes: 3 additions & 8 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@
"one": "You have added {{.PluralCount}} original attorney",
"other": "You have added {{.PluralCount}} attorneys"
},
"changeNameLinkText": "Change<span class=\"govuk-visually-hidden\"> name for {{ .FirstNames }} {{ .LastName }}</span>",
"changeDOBLinkText": "Change<span class=\"govuk-visually-hidden\"> date of birth for {{ .FirstNames }} {{ .LastName }}</span>",
"changeEmailLinkText": "Change<span class=\"govuk-visually-hidden\"> email for {{ .FirstNames }} {{ .LastName }}</span>",
"changeAddressLink": "Change<span class=\"govuk-visually-hidden\"> address for {{ .FirstNames }} {{ .LastName }}</span>",
"doYouWantToAddAnotherAttorney": "Do you want to add another original attorney?",
"yesToAddAnotherAttorney": "yes to add another attorney",
"yesToAddAnotherReplacementAttorney": "yes to add another replacement attorney",
Expand Down Expand Up @@ -621,10 +617,8 @@
"whatToDoIfAnyDetailsAreIncorrectCertificateProviderContentProfessional": "<p class=\"govuk-body\">If you notice a mistake in the name, work address or mobile number the donor provided for you, you’ll need to let the donor know so they can change your details.</p><p class=\"govuk-body\">Once the donor has changed your details, you’ll need to log back in again and confirm your details are correct.</p><p class=\"govuk-body\">You should not complete the ‘Confirm your identity’ task until all of your information is correct.</p>",
"whatToDoIfAnyDetailsAreIncorrectAttorneyContent": "<p class=\"govuk-body\">If you notice a mistake in the name, date of birth or address the donor provided for you, you should not continue.</p><p class=\"govuk-body\">You’ll need to let the donor know so they can change your details.</p><p class=\"govuk-body\">Once they’ve changed your details, you’ll need to log back in again and confirm your details are correct.</p>",
"anyErrorsInYourDetailsCanDelay": "Any errors in your details can cause delays in processing the LPA.",
"changeDateOfBirthLink": "Change<span class=\"govuk-visually-hidden\"> date of birth</span>",
"mobileNumber": "Mobile number",
"telephoneNumber": "Telephone number",
"changeTelephoneNumberLink": "Change<span class=\"govuk-visually-hidden\"> telephone number</span>",
"anyErrorsInYourDetailsCanMakeLpaDifficultToUse": "Any errors in your details can make the LPA difficult to use. Organisations might not accept the LPA if your details do not match your ID.",
"youHaveUnsavedChanges": "You have unsaved changes",
"unsavedChangesDialogContent": "To save, go back to the page and select <span class=\"govuk-body govuk-!-font-weight-bold\">Save and continue</span>.",
Expand Down Expand Up @@ -897,7 +891,6 @@
"yourHomeAddressWillNotBeShown": "Your home address will not be shown to the donor or appear on the completed LPA.",
"selectYourHomeAddress": "Select your home address",
"yourHomeAddress": "Your home address",
"changeHomeAddressLink": "Change<span class=\"govuk-visually-hidden\"> home address</span>",
"homeAddress": "Home address",
"goToDashboard": "Go to dashboard",
"printThisPage": "Print this page",
Expand Down Expand Up @@ -1134,5 +1127,7 @@
"weHaveContactedDonorToLetThemKnowYourDecision": "We have contacted {{ .DonorFullName }} to let them know of your decision to not be their certificate provider",
"reportAConcernContent": "<h2 class=\"govuk-heading-m\">Report a concern</h2> <p class=\"govuk-body\">If you have concerns about this LPA you can contact our safeguarding team:</p> <ul class=\"govuk-list govuk-list--bullet\"> <li>call: 0115 934 2777</li> <li>email: <a class=\"govuk-link\" href=\"mailto:[email protected]\">[email protected]</a> </li> </ul> <p class=\"govuk-body\">You can also <a class=\"govuk-link\" href=\"#\">report a concern</a> using our online form.</p>",
"yourAddress": "Your address",
"yourAddressWarning": "You should only enter your address. You cannot make an LPA for someone else using your account."
"yourAddressWarning": "You should only enter your address. You cannot make an LPA for someone else using your account.",
"enter": "Enter",
"forFullName": "for {{ .FullName }}"
}
61 changes: 17 additions & 44 deletions web/template/attorney/confirm_your_details.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,62 +15,35 @@

<h2 class="govuk-heading-m">{{ tr .App "detailsYouHaveGivenUs" }}</h2>
<dl class="govuk-summary-list">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">{{ tr .App "telephoneNumber" }}</dt>
<dd class="govuk-summary-list__value">{{ formatPhone .AttorneyProvidedDetails.Mobile }}</dd>
<dd class="govuk-summary-list__actions">
<a class="govuk-link" href="{{ link .App (global.Paths.Attorney.MobileNumber.Format .Lpa.LpaID) }}">{{ trHtml .App "changeTelephoneNumberLink" }}</a>
</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">{{ tr .App "preferredContactLanguage" }}</dt>
<dd class="govuk-summary-list__value">{{ if not .AttorneyProvidedDetails.ContactLanguagePreference.Empty }}{{ tr .App .AttorneyProvidedDetails.ContactLanguagePreference.String }}{{ end }}</dd>
<dd class="govuk-summary-list__actions">
<a class="govuk-link govuk-link--no-visited-state" href="{{ link .App (global.Paths.Attorney.YourPreferredLanguage.Format .App.LpaID) }}?from={{.App.Page}}">
{{ tr .App "change" }}<span class="govuk-visually-hidden"> {{ tr .App "preferredContactLanguage" }}</span>
</a>
</dd>
</div>
{{ $attorneyFullName := .Attorney.FullName }}
{{ if .TrustCorporation.Name }}{{ $attorneyFullName = .TrustCorporation.Name }}{{ end }}

{{ $mobileChangeLink := printf "%s?from=%s#f-date-of-birth" (link .App (global.Paths.Attorney.MobileNumber.Format .Lpa.LpaID)) .App.Page }}
{{ template "summary-row" (summaryRow .App "telephoneNumber" (formatPhone .AttorneyProvidedDetails.Mobile) $mobileChangeLink $attorneyFullName true true ) }}

{{ $contactLanguage := "" }}
{{ if not .AttorneyProvidedDetails.ContactLanguagePreference.Empty }} {{ $contactLanguage = tr .App .AttorneyProvidedDetails.ContactLanguagePreference.String }} {{ end }}
{{ $contactLanguageChangeLink := printf "%s#f-language-preference" (link .App (global.Paths.Attorney.YourPreferredLanguage.Format .Lpa.LpaID)) }}
{{ template "summary-row" (summaryRow .App "preferredContactLanguage" $contactLanguage $contactLanguageChangeLink $attorneyFullName true true ) }}
</dl>

{{ if .TrustCorporation.Name }}
<h2 class="govuk-heading-m">{{ tr .App "detailsTheDonorHasGivenAboutYourCompany" }}</h2>
<dl class="govuk-summary-list">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">{{ tr .App "companyName" }}</dt>
<dd class="govuk-summary-list__value">{{ .TrustCorporation.Name }}</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">{{ tr .App "companyNumber" }}</dt>
<dd class="govuk-summary-list__value">{{ .TrustCorporation.CompanyNumber }}</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">{{ tr .App "companyEmailAddress" }}</dt>
<dd class="govuk-summary-list__value">{{ .TrustCorporation.Email }}</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">{{ tr .App "address" }}</dt>
<dd class="govuk-summary-list__value">{{ template "address-lines" .TrustCorporation.Address }}</dd>
</div>
{{ template "summary-row" (summaryRow .App "companyName" .TrustCorporation.Name "" $attorneyFullName false true ) }}
{{ template "summary-row" (summaryRow .App "companyNumber" .TrustCorporation.CompanyNumber "" $attorneyFullName false true ) }}
{{ template "summary-row" (summaryRow .App "companyEmailAddress" .TrustCorporation.Email "" $attorneyFullName false true ) }}
{{ template "address-summary-row" (addressSummaryRow .App "address" .TrustCorporation.Address "" $attorneyFullName false true ) }}
</dl>

{{ template "details" (details . "whatToDoIfAnyDetailsAboutCompanyAreIncorrect" "whatToDoIfAnyDetailsAboutCompanyAreIncorrectAttorneyContent" false) }}
{{ template "warning" (content .App "ifTheDetailsYouProvideAreNotCorrect") }}
{{ else }}
<h2 class="govuk-heading-m govuk-!-margin-top-8">{{ tr .App "detailsTheDonorHasGivenAboutYou" }}</h2>
<dl class="govuk-summary-list">
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">{{ tr .App "name" }}</dt>
<dd class="govuk-summary-list__value">{{ .Attorney.FullName }}</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">{{ tr .App "dateOfBirth" }}</dt>
<dd class="govuk-summary-list__value">{{ formatDate .App .Attorney.DateOfBirth }}</dd>
</div>
<div class="govuk-summary-list__row">
<dt class="govuk-summary-list__key">{{ tr .App "address" }}</dt>
<dd class="govuk-summary-list__value">{{ template "address-lines" .Attorney.Address }}</dd>
</div>
{{ template "summary-row" (summaryRow .App "name" .Attorney.FullName "" $attorneyFullName false true ) }}
{{ template "summary-row" (summaryRow .App "dateOfBirth" (formatDate .App .Attorney.DateOfBirth) "" $attorneyFullName false true ) }}
{{ template "address-summary-row" (addressSummaryRow .App "address" .Attorney.Address "" $attorneyFullName false true ) }}
</dl>

{{ template "details" (details . "whatToDoIfAnyDetailsAreIncorrect" "whatToDoIfAnyDetailsAreIncorrectAttorneyContent" false) }}
Expand Down
Loading

0 comments on commit 2ac869d

Please sign in to comment.