updated draft sync group table buttons upon table change
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
{{- $acctID := .PathParams.acctID }}
|
||||
|
||||
|
||||
{{- component "button"
|
||||
"HXPost" (printf "/api/accounts/%d/inventory/sync-groups/draft/listings" $acctID)
|
||||
"HXTarget" "#accounts-acct-id-inventory-sync-groups-draft-table"
|
||||
"HXSwap" "outerHTML"
|
||||
"ID" "sync-groups-draft-table-add-listing-button"
|
||||
"Class" "mt-[1em] mb-[1em]"
|
||||
"Text" "Add Listing"
|
||||
"_" `
|
||||
on click
|
||||
send rowUpdated to the first <tbody/> in #accounts-acct-id-inventory-sync-groups-draft-table
|
||||
`
|
||||
}}
|
||||
+19
-1
@@ -2,7 +2,6 @@
|
||||
|
||||
|
||||
{{- $acctID := .PathParams.acctID }}
|
||||
{{- $stores := .Accounts.GetShops $acctID -}}
|
||||
|
||||
|
||||
<table
|
||||
@@ -82,3 +81,22 @@
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
{{/*
|
||||
<div
|
||||
hidden
|
||||
hx-get="{{ printf "/ui/accounts/%d/inventory/sync-groups/draft/table/add-listing-button" $acctID }}"
|
||||
hx-trigger="{{ (printf "sse:accounts_%d_inventory_sync-groups_draft_listings" $acctID) }}"
|
||||
hx-target="#sync-groups-draft-table-add-listing-button"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
</div>
|
||||
*/}}
|
||||
|
||||
<div
|
||||
hidden
|
||||
hx-get="{{ printf "/ui/accounts/%d/inventory/sync-groups/draft/table/save-sync-group-button" $acctID }}"
|
||||
hx-trigger="{{ (printf "sse:accounts_%d_inventory_sync-groups_draft_listings" $acctID) }}"
|
||||
hx-target="#create-sync-group-button"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
</div>
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
{{/* TODO: save the listings as a sync group on click */}}
|
||||
|
||||
|
||||
{{- $acctID := .PathParams.acctID }}
|
||||
{{- $listings := .Accounts.GetSyncGroupListingDrafts $acctID }}
|
||||
|
||||
{{- $numCompletedListings := 0 }}
|
||||
{{- range $l := $listings }}
|
||||
{{- if and $l.ShopID $l.ListingID }}
|
||||
{{- $numCompletedListings = (addInt $numCompletedListings 1) }}
|
||||
{{- else }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- $enoughListings := gt $numCompletedListings 1 }}
|
||||
{{- $allCompleted := len $listings | eq $numCompletedListings }}
|
||||
|
||||
|
||||
{{ component "button"
|
||||
"ID" "create-sync-group-button"
|
||||
"HXPost" (printf "/api/accounts/%d/sync-groups" $acctID)
|
||||
"Class" "mt-[1em] mb-[1em]"
|
||||
"Text" "Save Sync Group"
|
||||
"Disabled" (or (not $enoughListings) (not $allCompleted))
|
||||
"_" `
|
||||
on setDisabled(disabled)
|
||||
if disabled then
|
||||
add @disabled to me
|
||||
else
|
||||
remove @disabled from me
|
||||
end
|
||||
`
|
||||
}}
|
||||
Reference in New Issue
Block a user