updated draft sync group table buttons upon table change
This commit is contained in:
@@ -2,12 +2,12 @@ module ruben/inventory2
|
|||||||
|
|
||||||
go 1.24.2
|
go 1.24.2
|
||||||
|
|
||||||
// replace github.com/angelbeltran/templater v0.2.2 => ../../github.com/angelbeltran/templater
|
replace github.com/angelbeltran/templater v0.2.3 => ../../github.com/angelbeltran/templater
|
||||||
|
|
||||||
require github.com/jackc/pgx/v5 v5.7.6
|
require github.com/jackc/pgx/v5 v5.7.6
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/angelbeltran/templater v0.2.2
|
github.com/angelbeltran/templater v0.2.3
|
||||||
github.com/coreos/go-oidc/v3 v3.8.0
|
github.com/coreos/go-oidc/v3 v3.8.0
|
||||||
github.com/gin-gonic/gin v1.9.1
|
github.com/gin-gonic/gin v1.9.1
|
||||||
github.com/google/uuid v1.5.0
|
github.com/google/uuid v1.5.0
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9 h1:ez/4by2iGztzR4
|
|||||||
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
|
github.com/alecthomas/units v0.0.0-20231202071711-9a357b53e9c9/go.mod h1:OMCwj8VM1Kc9e19TLln2VL61YJF0x1XFtfdL4JdbSyE=
|
||||||
github.com/angelbeltran/concurry v0.0.0-20260109231127-8e2678d8928c h1:BIa061RHaIVP9TjpIQf0PldVpQmeln/2U1Cf2w8ALNI=
|
github.com/angelbeltran/concurry v0.0.0-20260109231127-8e2678d8928c h1:BIa061RHaIVP9TjpIQf0PldVpQmeln/2U1Cf2w8ALNI=
|
||||||
github.com/angelbeltran/concurry v0.0.0-20260109231127-8e2678d8928c/go.mod h1:Aii6F8lZCJb8Ns0d1FH35bDxNoyiuvwXd5BYJroJnks=
|
github.com/angelbeltran/concurry v0.0.0-20260109231127-8e2678d8928c/go.mod h1:Aii6F8lZCJb8Ns0d1FH35bDxNoyiuvwXd5BYJroJnks=
|
||||||
github.com/angelbeltran/templater v0.2.1 h1:9N2eNRE5/sYUgu7nZrU6VSSrrpKcOTlAw+UeeK3kyhk=
|
|
||||||
github.com/angelbeltran/templater v0.2.1/go.mod h1:ZA0T/ZmXxPi3gFjgp+RwEkcY9Q+JGyMStGw0c1jvgqA=
|
|
||||||
github.com/angelbeltran/templater v0.2.2 h1:SwsX7RrHtpjDvSi87CYqBRJsZFGaIHmGjn/clfqYqq4=
|
|
||||||
github.com/angelbeltran/templater v0.2.2/go.mod h1:ZA0T/ZmXxPi3gFjgp+RwEkcY9Q+JGyMStGw0c1jvgqA=
|
|
||||||
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
|
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
|
||||||
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
|
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
|
||||||
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
|
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ var (
|
|||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Etsy,
|
Platform: Etsy,
|
||||||
ShopID: "1",
|
ShopID: "2",
|
||||||
},
|
},
|
||||||
ListingID: "1",
|
ListingID: "1",
|
||||||
},
|
},
|
||||||
@@ -118,7 +118,7 @@ var (
|
|||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Etsy,
|
Platform: Etsy,
|
||||||
ShopID: "1",
|
ShopID: "2",
|
||||||
},
|
},
|
||||||
ListingID: "2",
|
ListingID: "2",
|
||||||
},
|
},
|
||||||
@@ -134,7 +134,7 @@ var (
|
|||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Etsy,
|
Platform: Etsy,
|
||||||
ShopID: "1",
|
ShopID: "2",
|
||||||
},
|
},
|
||||||
ListingID: "3",
|
ListingID: "3",
|
||||||
},
|
},
|
||||||
@@ -149,8 +149,8 @@ var (
|
|||||||
AccountIDs: AccountIDs{
|
AccountIDs: AccountIDs{
|
||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Tiktok,
|
Platform: Etsy,
|
||||||
ShopID: "4",
|
ShopID: "2",
|
||||||
},
|
},
|
||||||
ListingID: "4",
|
ListingID: "4",
|
||||||
},
|
},
|
||||||
@@ -165,8 +165,8 @@ var (
|
|||||||
AccountIDs: AccountIDs{
|
AccountIDs: AccountIDs{
|
||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Tiktok,
|
Platform: Etsy,
|
||||||
ShopID: "4",
|
ShopID: "2",
|
||||||
},
|
},
|
||||||
ListingID: "5",
|
ListingID: "5",
|
||||||
},
|
},
|
||||||
@@ -181,8 +181,8 @@ var (
|
|||||||
AccountIDs: AccountIDs{
|
AccountIDs: AccountIDs{
|
||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Tiktok,
|
Platform: Etsy,
|
||||||
ShopID: "4",
|
ShopID: "2",
|
||||||
},
|
},
|
||||||
ListingID: "6",
|
ListingID: "6",
|
||||||
},
|
},
|
||||||
@@ -197,8 +197,8 @@ var (
|
|||||||
AccountIDs: AccountIDs{
|
AccountIDs: AccountIDs{
|
||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Wix,
|
Platform: Etsy,
|
||||||
ShopID: "7",
|
ShopID: "5",
|
||||||
},
|
},
|
||||||
ListingID: "7",
|
ListingID: "7",
|
||||||
},
|
},
|
||||||
@@ -213,8 +213,8 @@ var (
|
|||||||
AccountIDs: AccountIDs{
|
AccountIDs: AccountIDs{
|
||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Wix,
|
Platform: Etsy,
|
||||||
ShopID: "7",
|
ShopID: "5",
|
||||||
},
|
},
|
||||||
ListingID: "8",
|
ListingID: "8",
|
||||||
},
|
},
|
||||||
@@ -229,8 +229,8 @@ var (
|
|||||||
AccountIDs: AccountIDs{
|
AccountIDs: AccountIDs{
|
||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Wix,
|
Platform: Etsy,
|
||||||
ShopID: "7",
|
ShopID: "5",
|
||||||
},
|
},
|
||||||
ListingID: "9",
|
ListingID: "9",
|
||||||
},
|
},
|
||||||
@@ -246,7 +246,7 @@ var (
|
|||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Etsy,
|
Platform: Etsy,
|
||||||
ShopID: "2",
|
ShopID: "5",
|
||||||
},
|
},
|
||||||
ListingID: "10",
|
ListingID: "10",
|
||||||
},
|
},
|
||||||
@@ -262,7 +262,7 @@ var (
|
|||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Etsy,
|
Platform: Etsy,
|
||||||
ShopID: "2",
|
ShopID: "5",
|
||||||
},
|
},
|
||||||
ListingID: "11",
|
ListingID: "11",
|
||||||
},
|
},
|
||||||
@@ -278,7 +278,7 @@ var (
|
|||||||
AccountID: 6,
|
AccountID: 6,
|
||||||
},
|
},
|
||||||
Platform: Etsy,
|
Platform: Etsy,
|
||||||
ShopID: "2",
|
ShopID: "5",
|
||||||
},
|
},
|
||||||
ListingID: "12",
|
ListingID: "12",
|
||||||
},
|
},
|
||||||
|
|||||||
+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 }}
|
{{- $acctID := .PathParams.acctID }}
|
||||||
{{- $stores := .Accounts.GetShops $acctID -}}
|
|
||||||
|
|
||||||
|
|
||||||
<table
|
<table
|
||||||
@@ -82,3 +81,22 @@
|
|||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</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
|
||||||
|
`
|
||||||
|
}}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
{{/* .HXGet | .HXPost | .HXDelete, .HXTarget, .HXSwap, .HXVals, ._, .Text, .ID, .Class, .Disabled */}}
|
{{/* .HXGet | .HXPost | .HXDelete, .HXTrigger, .HXTarget, .HXSwap, .HXVals, ._, .Text, .ID, .Class, .Disabled */}}
|
||||||
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="
|
class="
|
||||||
@@ -25,6 +26,9 @@
|
|||||||
{{- else if .HXDelete }}
|
{{- else if .HXDelete }}
|
||||||
hx-delete="{{.HXDelete}}"
|
hx-delete="{{.HXDelete}}"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if .HXTrigger }}
|
||||||
|
hx-trigger="{{.HXTrigger}}"
|
||||||
|
{{- end }}
|
||||||
{{- if .HXTarget }}
|
{{- if .HXTarget }}
|
||||||
hx-target="{{.HXTarget}}"
|
hx-target="{{.HXTarget}}"
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -17,38 +17,10 @@
|
|||||||
<h4>
|
<h4>
|
||||||
(Draft 2)
|
(Draft 2)
|
||||||
</h4>
|
</h4>
|
||||||
{{/* component "accounts/{acctID}/inventory/sync-groups/draft/table" "dot" . */}}
|
{{ component (printf "accounts/%d/inventory/sync-groups/draft/table" $acctID) }}
|
||||||
{{ component (printf "accounts/%d/inventory/sync-groups/draft/table" $acctID) "dot" . }}
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{{ component "button"
|
{{ component (printf "accounts/%d/inventory/sync-groups/draft/table/add-listing-button" $acctID) }}
|
||||||
"HXPost" (printf "/api/accounts/%d/inventory/sync-groups/draft/listings" $acctID)
|
{{ component (printf "accounts/%d/inventory/sync-groups/draft/table/save-sync-group-button" $acctID) }}
|
||||||
"HXTarget" "#accounts-acct-id-inventory-sync-groups-draft-table"
|
|
||||||
"HXSwap" "outerHTML"
|
|
||||||
"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
|
|
||||||
`
|
|
||||||
}}
|
|
||||||
|
|
||||||
{{/* TODO: enable the button when all listings are filled and there are at least two listings */}}
|
|
||||||
{{/* TODO: save the listings as a sync group on click */}}
|
|
||||||
{{ 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" true
|
|
||||||
"_" `
|
|
||||||
on setDisabled(disabled)
|
|
||||||
if disabled then
|
|
||||||
add @disabled to me
|
|
||||||
else
|
|
||||||
remove @disabled from me
|
|
||||||
end
|
|
||||||
`
|
|
||||||
}}
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
Reference in New Issue
Block a user