diff options
author | Matthew Lemon <y@yulqen.org> | 2024-02-12 15:47:47 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-02-12 15:47:47 +0000 |
commit | 2648c9dfc3440f4c00a7b234de4687cc8a93a4d0 (patch) | |
tree | 3fbeb43c9a8db234198ed1e8793d496d224e10de /cmd/web/handlers.go | |
parent | 752ee52dcd487253bc1662b1ba157732f73d27cf (diff) |
Operations list shows ESs for each entity
This was about two hours of learning, and getting confused - and it
needs to be refactored. We need to be able to generate the list of EPs
for the Operation also.
At the moment this only prints the object representation. More work to
be done writing a method that gives us the id and textual representation
for the link in the table.
Diffstat (limited to 'cmd/web/handlers.go')
-rw-r--r-- | cmd/web/handlers.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index 0a7be55..6901661 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -18,15 +18,20 @@ func (app *application) listOperations(w http.ResponseWriter, r *http.Request) { return } - var esses []models.EngagementStrategy + var newOps []models.Operation for _, op := range ops { - es, err := app.engagement_strategies.GetForOperation(op.ID) + esses, err := app.engagement_strategies.GetForOperation(op.ID) // TODO: Check what kind of error this is, don't just continue if err != nil { continue } - esses = append(esses, es) + if len(esses) > 0 { + op.EngagementStrategies = esses + newOps = append(newOps, op) + } else { + newOps = append(newOps, op) + } } files := []string{ @@ -42,7 +47,7 @@ func (app *application) listOperations(w http.ResponseWriter, r *http.Request) { } data := operationsTemplateData{ - Operations: ops, + Operations: newOps, } err = ts.ExecuteTemplate(w, "base", data) |