Merge pull request #64 from LazyBachelor/LPM-81--Assign-to-me

LPM-81: Assign to me
This commit is contained in:
Robin Olsen
2026-03-18 06:40:04 -07:00
committed by GitHub
3 changed files with 57 additions and 21 deletions

View File

@@ -1,7 +1,5 @@
package components
import "github.com/LazyBachelor/LazyPM/pkg/web/components/base"
type AssigneeFormProps struct {
PatchAction string
Assignee string
@@ -12,12 +10,27 @@ templ AssigneeForm(props AssigneeFormProps) {
hx-patch={ props.PatchAction }
hx-swap="innerHTML"
>
@base.Input(base.InputProps{
Name: "assignee",
Type: "text",
Placeholder: "Enter assingee",
Value: props.Assignee,
})
<button class="btn btn-primary mt-2" type="submit">Set Assignee</button>
<div class="form-control">
<label class="label cursor-pointer justify-start gap-2">
<input
type="checkbox"
name="assign_me"
value="me"
class="checkbox checkbox-primary"
if props.Assignee == "Me" {
checked
}
/>
<span class="label-text">Assign this issue to me</span>
</label>
if props.Assignee != "" {
<p class="text-xs mt-1 opacity-70">
Current assignee: { props.Assignee }
</p>
}
</div>
<button class="btn btn-primary mt-4" type="submit">
Update Assignee
</button>
</form>
}

View File

@@ -8,8 +8,6 @@ package components
import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"
import "github.com/LazyBachelor/LazyPM/pkg/web/components/base"
type AssigneeFormProps struct {
PatchAction string
Assignee string
@@ -43,26 +41,46 @@ func AssigneeForm(props AssigneeFormProps) templ.Component {
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(props.PatchAction)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/web/components/assignee_form.templ`, Line: 12, Col: 30}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/web/components/assignee_form.templ`, Line: 10, Col: 30}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\" hx-swap=\"innerHTML\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\" hx-swap=\"innerHTML\"><div class=\"form-control\"><label class=\"label cursor-pointer justify-start gap-2\"><input type=\"checkbox\" name=\"assign_me\" value=\"me\" class=\"checkbox checkbox-primary\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = base.Input(base.InputProps{
Name: "assignee",
Type: "text",
Placeholder: "Enter assingee",
Value: props.Assignee,
}).Render(ctx, templ_7745c5c3_Buffer)
if props.Assignee == "Me" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, " checked")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "> <span class=\"label-text\">Assign this issue to me</span></label> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<button class=\"btn btn-primary mt-2\" type=\"submit\">Set Assignee</button></form>")
if props.Assignee != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<p class=\"text-xs mt-1 opacity-70\">Current assignee: ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(props.Assignee)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `pkg/web/components/assignee_form.templ`, Line: 28, Col: 39}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</div><button class=\"btn btn-primary mt-4\" type=\"submit\">Update Assignee</button></form>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

View File

@@ -196,7 +196,12 @@ func UpdateIssue(w http.ResponseWriter, r *http.Request) {
func UpdateAssignee(w http.ResponseWriter, r *http.Request) {
issue := r.Context().Value(issueKey).(*models.Issue)
assignee := r.FormValue("assignee")
assignMe := r.FormValue("assign_me")
assignee := ""
if assignMe != "" {
assignee = "Me"
}
if err := App(r).Issues.UpdateIssue(r.Context(), issue.ID, map[string]any{"assignee": assignee}, ""); err != nil {
http.Error(w, "Failed to update assignee", http.StatusInternalServerError)