added Edit Group button to mock sync group accordion

This commit is contained in:
2026-02-17 18:29:34 -07:00
parent d04a57beec
commit 7ef4638daa
5 changed files with 175 additions and 13 deletions
@@ -2,6 +2,10 @@
{{- $syncGroupID := .PathParams.syncGroupID }}
{{- $acctID := .PathParams.acctID }}
{{- $open := false }}
{{- if .Request }}
{{- $open = eq (.Request.URL.Query.Get "open") "true" }}
{{- end }}
{{- $grp := .SyncGroup }}
{{- if not $grp }}
@@ -9,11 +13,15 @@
{{- end }}
{{- $id := (printf "sync-group-%d" $syncGroupID) }}
<li
id="sync-group-{{$grp.SyncGroupID}}"
class="
mx-[1em]
"
id="{{$id}}"
class="mx-[1em]"
hx-get="{{ printf "/ui/accounts/%d/inventory/sync-groups/mock/%d/list-item" $acctID $syncGroupID }}"
hx-trigger="{{ printf "sse:accounts_%d_inventory_sync-groups_mock_%d" $acctID $syncGroupID }}"
hx-swap="morph:outerHTML"
hx-select="#{{$id}}"
hx-vals="js:{open: this.getElementsByTagName('details')[0].open}"
>
{{- define "sync-group-accordion-header" }}
<h3 class="text-center">
@@ -23,6 +31,7 @@
{{- define "sync-group-accordion-body" }}
{{- $acctID := .Identity.Account.AccountID }}
{{- $syncGroupID := .Group.SyncGroupID }}
<table>
<thead>
<tr>
@@ -62,16 +71,30 @@
</tbody>
</table>
{{- component "button"
"Class" "mt-[1em]"
"Text" "Delete Group"
"HXDelete" (printf "/api/accounts/%d/inventory/sync-groups/mock/%d" $acctID .Group.SyncGroupID)
"HXSwap" "none"
}}
<div>
{{- $isBeingEditing := .Accounts.MockSyncGroupIsBeingEdited $acctID $syncGroupID }}
{{- if not $isBeingEditing }}
{{- component "button"
"Class" "mt-[1em]"
"Text" "Edit Group"
"HXPut" (printf "/api/accounts/%d/inventory/sync-groups/mock/editing" $acctID)
"HXVals" (printf `js:{"syncGroupID":%d}` $syncGroupID)
"HXSwap" "none"
}}
{{- end }}
{{- component "button"
"Class" "mt-[1em]"
"Text" "Delete Group"
"HXDelete" (printf "/api/accounts/%d/inventory/sync-groups/mock/%d" $acctID $syncGroupID)
"HXSwap" "none"
}}
</div>
{{- end }}
{{ component "accordion"
"Name" "sync-group-page"
"Name" "sync-group-page"
"Open" $open
"GroupName" "sync-group"
"Group" $grp
"Smooth" false
+5 -2
View File
@@ -1,4 +1,4 @@
{{/* .HXGet | .HXPost | .HXDelete, .HXTrigger, .HXTarget, .HXSelect, .HXSwap, .HXVals, ._, .Text, .ID, .Class, .Disabled */}}
{{/* .HXGet | .HXPost | .HXPut | .HXDelete, .HXTrigger, .HXTarget, .HXSelect, .HXSwap, .HXVals, ._, .Text, .ID, .Class, .Disabled */}}
<button
@@ -23,6 +23,8 @@
hx-get="{{.HXGet}}"
{{- else if .HXPost }}
hx-post="{{.HXPost}}"
{{- else if .HXPut }}
hx-put="{{.HXPut}}"
{{- else if .HXDelete }}
hx-delete="{{.HXDelete}}"
{{- end }}
@@ -39,7 +41,8 @@
hx-swap="{{.HXSwap}}"
{{- end }}
{{- if .HXVals }}
hx-vals='{{.HXVals}}'
{{/*hx-vals='{{.HXVals}}'*/}}
{{rawHTMLAttr (printf "hx-vals='%s'" .HXVals)}}
{{- end }}
{{- if .Disabled}}
disabled