diff options
author | Matthew Lemon <y@yulqen.org> | 2024-02-12 16:50:26 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-02-12 16:50:26 +0000 |
commit | f7d5e262ac8c6903d71f38f52ae53ab5f65f0769 (patch) | |
tree | 07492208aa10832bf7ee5a87e39f6db389e0c63d | |
parent | b64bb5cc7971092e76929a1cbabfafc813a8eb96 (diff) |
Method to format an EngagementStrategy for rendering
The objective is to render a link to the ES in the Operations table.
Only the start year and end year are required for it to make sense.
-rw-r--r-- | internal/models/engagement.go | 8 | ||||
-rw-r--r-- | ui/html/pages/operations/list.tmpl.html | 6 |
2 files changed, 11 insertions, 3 deletions
diff --git a/internal/models/engagement.go b/internal/models/engagement.go index 26b468a..87e0786 100644 --- a/internal/models/engagement.go +++ b/internal/models/engagement.go @@ -2,6 +2,8 @@ package models import ( "database/sql" + "fmt" + "strconv" "time" ) @@ -12,6 +14,12 @@ type EngagementStrategy struct { Operation Operation } +func (es *EngagementStrategy) FormatForTable() string { + startYear := strconv.Itoa(es.ValidFrom.Year()) + endYear := strconv.Itoa(es.ValidTo.Year()) + return fmt.Sprintf("%s-%s", startYear, endYear) +} + type EngagementStrategyModel struct { DB *sql.DB } diff --git a/ui/html/pages/operations/list.tmpl.html b/ui/html/pages/operations/list.tmpl.html index 240ba40..a619ea9 100644 --- a/ui/html/pages/operations/list.tmpl.html +++ b/ui/html/pages/operations/list.tmpl.html @@ -34,14 +34,14 @@ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod {{if .EngagementStrategies}} <ul> {{range .EngagementStrategies}} - <li> - Expires: <a href="#">{{.ValidTo.Format "Mon 2 Jan 2006" }}</a> + <li class="table-list"> + <a href="#">{{.FormatForTable }}</a> </li> {{end}} </ul> {{else}} - <p>NA</p> + NA {{end}} </td> <td><a href="#">Link</a></td> |