diff --git a/handlers/candidaterecords/candidate_records.go b/handlers/candidaterecords/candidate_records.go
index 1caa8318..68dbd2fe 100644
--- a/handlers/candidaterecords/candidate_records.go
+++ b/handlers/candidaterecords/candidate_records.go
@@ -94,10 +94,19 @@ func RejectCandidateRecord(w http.ResponseWriter, r *http.Request) {
f := flash.SimpleFlash().
WithLevel("success").
WithBody("
Candidate record was successfully deleted.
")
+ c.Flash = append(c.Flash, *f)
- c.PersistFlash(w, *f)
+ rec, err = c.Repo.GetCandidateRecord(r.Context(), rec.ID)
+ if err != nil {
+ c.HandleError(w, r, err)
+ return
+ }
- w.Header().Set("HX-Redirect", c.URLTo("candidate_records").String())
+ views.Cat(
+ candidaterecordviews.ListItem(c, rec),
+ views.CloseModal(),
+ views.Replace("#flash-messages", views.FlashMessages(c)),
+ ).Render(r.Context(), w)
}
func ImportCandidateRecord(w http.ResponseWriter, r *http.Request) {
diff --git a/views/candidaterecord/confirm_hide.templ b/views/candidaterecord/confirm_hide.templ
index 40e0c072..536284e5 100644
--- a/views/candidaterecord/confirm_hide.templ
+++ b/views/candidaterecord/confirm_hide.templ
@@ -1,6 +1,7 @@
package candidaterecordviews
import (
+ "fmt"
"github.com/ugent-library/biblio-backoffice/ctx"
"github.com/ugent-library/biblio-backoffice/models"
)
@@ -27,7 +28,8 @@ templ ConfirmHide(c *ctx.Ctx, rec *models.CandidateRecord) {
diff --git a/views/candidaterecord/confirm_hide_templ.go b/views/candidaterecord/confirm_hide_templ.go
index 4fce1de4..88309416 100644
--- a/views/candidaterecord/confirm_hide_templ.go
+++ b/views/candidaterecord/confirm_hide_templ.go
@@ -9,6 +9,7 @@ import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
import (
+ "fmt"
"github.com/ugent-library/biblio-backoffice/ctx"
"github.com/ugent-library/biblio-backoffice/models"
)
@@ -38,13 +39,26 @@ func ConfirmHide(c *ctx.Ctx, rec *models.CandidateRecord) templ.Component {
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(c.PathTo("reject_candidate_record", "id", rec.ID).String())
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/confirm_hide.templ`, Line: 29, Col: 74}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/confirm_hide.templ`, Line: 30, Col: 74}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap=\"none\">Yes, reject suggestion")
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-target=\"")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ var templ_7745c5c3_Var3 string
+ templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("#candidate-record-%s", rec.ID))
+ if templ_7745c5c3_Err != nil {
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `candidaterecord/confirm_hide.templ`, Line: 31, Col: 62}
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" hx-swap=\"outerHTML\">Yes, reject suggestion")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
diff --git a/views/replace.templ b/views/replace.templ
index 6cea022c..0941c020 100644
--- a/views/replace.templ
+++ b/views/replace.templ
@@ -9,14 +9,14 @@ templ Replace(selector string, component templ.Component) {
}
templ ReplaceModal(component templ.Component) {
-
- @component
-
+ @Replace("#modal", component)
}
-templ CloseModalAndReplace(selector string, component templ.Component) {
+templ CloseModal() {
-
- @component
-
+}
+
+templ CloseModalAndReplace(selector string, component templ.Component) {
+ @CloseModal()
+ @Replace(selector, component)
}
diff --git a/views/replace_templ.go b/views/replace_templ.go
index 2858412d..34463be0 100644
--- a/views/replace_templ.go
+++ b/views/replace_templ.go
@@ -75,15 +75,7 @@ func ReplaceModal(component templ.Component) templ.Component {
templ_7745c5c3_Var3 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- templ_7745c5c3_Err = component.Render(ctx, templ_7745c5c3_Buffer)
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
")
+ templ_7745c5c3_Err = Replace("#modal", component).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -91,7 +83,7 @@ func ReplaceModal(component templ.Component) templ.Component {
})
}
-func CloseModalAndReplace(selector string, component templ.Component) templ.Component {
+func CloseModal() 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
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
@@ -109,28 +101,37 @@ func CloseModalAndReplace(selector string, component templ.Component) templ.Comp
templ_7745c5c3_Var4 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- var templ_7745c5c3_Var5 string
- templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("innerHTML:%s", selector))
- if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `replace.templ`, Line: 19, Col: 57}
- }
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
+ return templ_7745c5c3_Err
+ })
+}
+
+func CloseModalAndReplace(selector string, component templ.Component) 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
+ 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
+ }
+ }()
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">")
- if templ_7745c5c3_Err != nil {
- return templ_7745c5c3_Err
+ ctx = templ.InitializeContext(ctx)
+ templ_7745c5c3_Var5 := templ.GetChildren(ctx)
+ if templ_7745c5c3_Var5 == nil {
+ templ_7745c5c3_Var5 = templ.NopComponent
}
- templ_7745c5c3_Err = component.Render(ctx, templ_7745c5c3_Buffer)
+ ctx = templ.ClearChildren(ctx)
+ templ_7745c5c3_Err = CloseModal().Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("")
+ templ_7745c5c3_Err = Replace(selector, component).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}