From 3a18c25b3c8316cb902c2d65475338a75d27b799 Mon Sep 17 00:00:00 2001 From: William Petit Date: Sat, 22 Feb 2025 19:30:27 +0100 Subject: [PATCH] fix: save preferred project in local storage --- .../http/handler/webui/issue/component/issue_page.templ | 7 +++---- .../http/handler/webui/issue/component/issue_page_templ.go | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/internal/http/handler/webui/issue/component/issue_page.templ b/internal/http/handler/webui/issue/component/issue_page.templ index 37c3d7c..f775a18 100644 --- a/internal/http/handler/webui/issue/component/issue_page.templ +++ b/internal/http/handler/webui/issue/component/issue_page.templ @@ -84,7 +84,7 @@ templ IssuePage(vmodel IssuePageVModel) { }
-
+

Résumé de la demande

@common.FormSelect( vmodel.SummaryForm, "issue-project", "project", "Projet", @@ -93,7 +93,6 @@ templ IssuePage(vmodel IssuePageVModel) { "hx-get", string(common.CurrentURL(ctx, common.WithoutValues("project", "*"))), "hx-target", "body", "hx-push-url", "true", - "hx-on:htmx:beforeSend", "onProjectChange(event)", ), ) @common.FormTextarea( @@ -142,8 +141,8 @@ templ IssuePage(vmodel IssuePageVModel) { sessionStorage.setItem(`summary-${projectId}`, summary); } - function onProjectChange(evt) { - const projectId = evt.currentTarget.value; + function savePreferredProject() { + const projectId = document.getElementById("issue-project").value; localStorage.setItem(`preferred-project`, projectId); } diff --git a/internal/http/handler/webui/issue/component/issue_page_templ.go b/internal/http/handler/webui/issue/component/issue_page_templ.go index 91aff84..fc69119 100644 --- a/internal/http/handler/webui/issue/component/issue_page_templ.go +++ b/internal/http/handler/webui/issue/component/issue_page_templ.go @@ -147,7 +147,7 @@ func IssuePage(vmodel IssuePageVModel) templ.Component { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "

Résumé de la demande

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "\" method=\"put\" hx-disabled-elt=\"#summary-form textarea, #summary-form select, #summary-form button\" hx-on:htmx:before-send=\"savePreferredProject()\" hx-indicator=\"#generation-progress\">

Résumé de la demande

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -167,7 +167,6 @@ func IssuePage(vmodel IssuePageVModel) templ.Component { "hx-get", string(common.CurrentURL(ctx, common.WithoutValues("project", "*"))), "hx-target", "body", "hx-push-url", "true", - "hx-on:htmx:beforeSend", "onProjectChange(event)", ), ).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { @@ -203,7 +202,7 @@ func IssuePage(vmodel IssuePageVModel) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }