From f7d5e262ac8c6903d71f38f52ae53ab5f65f0769 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 12 Feb 2024 16:50:26 +0000 Subject: 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. --- internal/models/engagement.go | 8 ++++++++ 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}} {{else}} -

NA

+ NA {{end}} Link -- cgit v1.2.3