Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove optionalSummaryRow template fn
Browse files Browse the repository at this point in the history
hawx committed Jul 22, 2024
1 parent 68ad4c5 commit 63fda81
Showing 6 changed files with 10 additions and 41 deletions.
13 changes: 0 additions & 13 deletions internal/templatefn/fn.go
Original file line number Diff line number Diff line change
@@ -83,7 +83,6 @@ func All(globals *Globals) map[string]any {
"checkboxEq": checkboxEq,
"lpaDecisions": lpaDecisions,
"summaryRow": summaryRow,
"optionalSummaryRow": optionalSummaryRow,
}
}

@@ -511,15 +510,3 @@ func summaryRow(app page.AppData, label string, value any, changeLink, fullName
"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,
}
}
18 changes: 0 additions & 18 deletions internal/templatefn/fn_test.go
Original file line number Diff line number Diff line change
@@ -587,21 +587,3 @@ func TestSummaryRow(t *testing.T) {
"SummarisingSelf": true,
}, summaryRow(app, label, value, 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))
}
4 changes: 2 additions & 2 deletions web/template/layout/attorney-summary.gohtml
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
{{ template "summary-row" (summaryRow $.App "companyNumber" .TrustCorporation.CompanyNumber $companyNumberChangeLink .TrustCorporation.Name $.CanChange (eq $.App.AttorneyUID .TrustCorporation.UID)) }}

{{ $companyEmailAddressChangeLink := printf "%s#f-email" (link .App .Link.TrustCorporation) }}
{{ template "optional-summary-row" (optionalSummaryRow $.App "companyEmailAddress" .TrustCorporation.Email $companyEmailAddressChangeLink .TrustCorporation.Name $.CanChange (eq $.App.AttorneyUID .TrustCorporation.UID)) }}
{{ template "optional-summary-row" (summaryRow $.App "companyEmailAddress" .TrustCorporation.Email $companyEmailAddressChangeLink .TrustCorporation.Name $.CanChange (eq $.App.AttorneyUID .TrustCorporation.UID)) }}

{{ $companyAddressChangeLink := printf "%s#f-address-line-1" (link .App .Link.TrustCorporationAddress) }}
{{ template "address-summary-row" (summaryRow $.App "address" .TrustCorporation.Address $companyAddressChangeLink .TrustCorporation.Name $.CanChange (eq $.App.AttorneyUID .TrustCorporation.UID)) }}
@@ -60,7 +60,7 @@
{{ template "summary-row" (summaryRow $.App "dateOfBirth" (formatDate $.App .DateOfBirth) $dobChangeLink .FullName $.CanChange (eq $.App.AttorneyUID .UID)) }}

{{ $emailChangeLink := printf "%s&id=%s#f-email" (link $.App $.Link.Attorney) .UID }}
{{ template "optional-summary-row" (optionalSummaryRow $.App "email" .Email $emailChangeLink .FullName $.CanChange (eq $.App.AttorneyUID .UID)) }}
{{ template "optional-summary-row" (summaryRow $.App "email" .Email $emailChangeLink .FullName $.CanChange (eq $.App.AttorneyUID .UID)) }}

{{ $addressChangeLink := printf "%s&id=%s#f-address-line-1" (link $.App $.Link.AttorneyAddress) .UID }}
{{ template "address-summary-row" (summaryRow $.App "address" .Address $addressChangeLink .FullName $.CanChange (eq $.App.AttorneyUID .UID)) }}
2 changes: 1 addition & 1 deletion web/template/layout/certificate-provider-details.gohtml
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
{{ template "summary-row" (summaryRow $.App "contactPreference" $contactValue $carryOutByLink .Lpa.CertificateProvider.FullName .CanChange $.App.IsCertificateProvider ) }}

{{ $emailChangeLink := printf "%s#f-email" $carryOutByLink }}
{{ template "optional-summary-row" (optionalSummaryRow $.App "email" .Lpa.CertificateProvider.Email $emailChangeLink .Lpa.CertificateProvider.FullName .CanChange $.App.IsCertificateProvider ) }}
{{ template "optional-summary-row" (summaryRow $.App "email" .Lpa.CertificateProvider.Email $emailChangeLink .Lpa.CertificateProvider.FullName .CanChange $.App.IsCertificateProvider ) }}

{{ $addressChangeLink := printf "%s#f-address-line-1" $addressLink }}
{{ $addressLabel := tr .App "address" }}
12 changes: 6 additions & 6 deletions web/template/layout/contextual-lpa.gohtml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
(fromLink $.App global.Paths.YourDetails "#f-first-names")
.FullName $canChange $isDonor) }}

{{ template "optional-summary-row" (optionalSummaryRow $.App "otherNamesYouAreKnownBy"
{{ template "optional-summary-row" (summaryRow $.App "otherNamesYouAreKnownBy"
.OtherNames
(fromLink $.App global.Paths.YourDetails "#f-other-names")
.FullName $canChange $isDonor) }}
@@ -83,7 +83,7 @@
(fromLink $.App global.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole "")
.FullName $canChange false ) }}

{{ template "optional-summary-row" (optionalSummaryRow $.App "email"
{{ template "optional-summary-row" (summaryRow $.App "email"
.Email
(fromLink $.App global.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole "#f-email")
.FullName $canChange false ) }}
@@ -122,7 +122,7 @@
(fromLinkActor $.App global.Paths.ChooseAttorneys .UID "#f-date-of-birth")
.FullName $canChange false) }}

{{ template "optional-summary-row" (optionalSummaryRow $.App "email"
{{ template "optional-summary-row" (summaryRow $.App "email"
.Email
(fromLinkActor $.App global.Paths.ChooseAttorneys .UID "#f-email")
.FullName $canChange false) }}
@@ -162,7 +162,7 @@
(fromLink $.App global.Paths.EnterTrustCorporation "#f-company-number")
.Name $canChange false) }}

{{ template "optional-summary-row" (optionalSummaryRow $.App "companyEmailAddress"
{{ template "optional-summary-row" (summaryRow $.App "companyEmailAddress"
.Email
(fromLink $.App global.Paths.EnterTrustCorporation "#f-email")
.Name $canChange false) }}
@@ -202,7 +202,7 @@
(fromLinkActor $.App global.Paths.ChooseReplacementAttorneys .UID "#f-date-of-birth")
.FullName $canChange false) }}

{{ template "optional-summary-row" (optionalSummaryRow $.App "email"
{{ template "optional-summary-row" (summaryRow $.App "email"
.Email
(fromLinkActor $.App global.Paths.ChooseReplacementAttorneys .UID "#f-email")
.FullName $canChange false) }}
@@ -242,7 +242,7 @@
(fromLink $.App global.Paths.EnterReplacementTrustCorporation "#f-company-number")
.Name $canChange false) }}

{{ template "optional-summary-row" (optionalSummaryRow $.App "companyEmailAddress"
{{ template "optional-summary-row" (summaryRow $.App "companyEmailAddress"
.Email
(fromLink $.App global.Paths.EnterReplacementTrustCorporation "#f-email")
.Name $canChange false) }}
2 changes: 1 addition & 1 deletion web/template/layout/donor-details.gohtml
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
{{ template "summary-row" (summaryRow $.App "name" .Lpa.Donor.FullName $nameChangeLink .Lpa.Donor.FullName .CanChange $.App.IsDonor) }}

{{ $otherNameChangeLink := printf "%s?from=%s#f-other-names" (link .App (global.Paths.YourDetails.Format .App.LpaID)) .App.Page }}
{{ template "optional-summary-row" (optionalSummaryRow $.App "otherNamesYouAreKnownBy" .Lpa.Donor.OtherNames $otherNameChangeLink .Lpa.Donor.FullName .CanChange $.App.IsDonor) }}
{{ template "optional-summary-row" (summaryRow $.App "otherNamesYouAreKnownBy" .Lpa.Donor.OtherNames $otherNameChangeLink .Lpa.Donor.FullName .CanChange $.App.IsDonor) }}

{{ $dateOfBirthChangeLink := printf "%s?from=%s#f-date-of-birth" (link .App (global.Paths.YourDetails.Format .App.LpaID)) .App.Page }}
{{ template "summary-row" (summaryRow $.App "dateOfBirth" (formatDate $.App .Lpa.Donor.DateOfBirth) $dateOfBirthChangeLink .Lpa.Donor.FullName .CanChange $.App.IsDonor) }}

0 comments on commit 63fda81

Please sign in to comment.