diff --git a/pkg/web/components/dependencies_list.templ b/pkg/web/components/dependencies_list.templ
new file mode 100644
index 0000000..e47fe84
--- /dev/null
+++ b/pkg/web/components/dependencies_list.templ
@@ -0,0 +1,45 @@
+package components
+
+import (
+ "net/url"
+
+ "github.com/LazyBachelor/LazyPM/internal/models"
+)
+
+type DependenciesListProps struct {
+ ContainerID string
+ IssueID string
+ Deps []*models.Issue
+}
+
+templ DependenciesList(props DependenciesListProps) {
+ if len(props.Deps) == 0 {
+
+ for _, d := range props.Deps {
+ if d != nil {
+
+
+ { d.ID }
+ if d.Title != "" {
+ — { d.Title }
+ }
+
+
+
+ }
+ }
+
+ }
+}
diff --git a/pkg/web/components/dependencies_list_templ.go b/pkg/web/components/dependencies_list_templ.go
new file mode 100644
index 0000000..41fd1a6
--- /dev/null
+++ b/pkg/web/components/dependencies_list_templ.go
@@ -0,0 +1,172 @@
+// Code generated by templ - DO NOT EDIT.
+
+// templ: version: v0.3.1001
+package components
+
+//lint:file-ignore SA4006 This context is only used if a nested component is present.
+
+import "github.com/a-h/templ"
+import templruntime "github.com/a-h/templ/runtime"
+
+import (
+ "net/url"
+
+ "github.com/LazyBachelor/LazyPM/internal/models"
+)
+
+type DependenciesListProps struct {
+ ContainerID string
+ IssueID string
+ Deps []*models.Issue
+}
+
+func DependenciesList(props DependenciesListProps) templ.Component {
+ return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
+ templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
+ if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
+ return templ_7745c5c3_CtxErr
+ }
+ templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
+ if !templ_7745c5c3_IsBuffer {
+ defer func() {
+ templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
+ if templ_7745c5c3_Err == nil {
+ templ_7745c5c3_Err = templ_7745c5c3_BufErr
+ }
+ }()
+ }
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var1 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var1 == nil {
+ templ_7745c5c3_Var1 = templ.NopComponent
+ }
+ ctx = templ.ClearChildren(ctx)
+ if len(props.Deps) == 0 {
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "No dependencies.
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ } else {
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ for _, d := range props.Deps {
+ if d != nil {
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var4 string
+ templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(d.ID)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/web/components/dependencies_list.templ`, Line: 26, Col: 37}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, " ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ if d.Title != "" {
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "— ")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var5 string
+ templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(d.Title)
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/web/components/dependencies_list.templ`, Line: 28, Col: 47}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "
")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ return nil
+ })
+}
+
+var _ = templruntime.GeneratedTemplate
diff --git a/pkg/web/handler/issues.go b/pkg/web/handler/issues.go
index 1ee923a..71ec66f 100644
--- a/pkg/web/handler/issues.go
+++ b/pkg/web/handler/issues.go
@@ -3,11 +3,11 @@ package handler
import (
"context"
"html"
- "net/url"
"net/http"
"strings"
"github.com/LazyBachelor/LazyPM/internal/models"
+ "github.com/LazyBachelor/LazyPM/pkg/web/components"
"github.com/LazyBachelor/LazyPM/pkg/web/routes"
"github.com/go-chi/chi/v5"
)
@@ -244,41 +244,11 @@ func ListDependencies(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Content-Type", "text/html; charset=utf-8")
-
- if len(deps) == 0 {
- _, _ = w.Write([]byte(`No dependencies.
`))
- return
- }
-
- builder := strings.Builder{}
- builder.WriteString(``)
- for _, d := range deps {
- if d == nil {
- continue
- }
- builder.WriteString(`
`)
- builder.WriteString(``)
- builder.WriteString(``)
- builder.WriteString(html.EscapeString(d.ID))
- builder.WriteString(``)
- if d.Title != "" {
- builder.WriteString(` — `)
- builder.WriteString(html.EscapeString(d.Title))
- builder.WriteString(``)
- }
- builder.WriteString(``)
- builder.WriteString(``)
- builder.WriteString(`
`)
- }
- builder.WriteString(`
`)
-
- _, _ = w.Write([]byte(builder.String()))
+ components.DependenciesList(components.DependenciesListProps{
+ ContainerID: containerID,
+ IssueID: issue.ID,
+ Deps: deps,
+ }).Render(r.Context(), w)
}
// Adding a new dependency (issue depends on depends_on_id)