diff --git a/internal/server/api/accounts/router.go b/internal/server/api/accounts/router.go index e6881ac..9541ffc 100644 --- a/internal/server/api/accounts/router.go +++ b/internal/server/api/accounts/router.go @@ -70,14 +70,13 @@ func (s *accountSubrouter) createSyncGroupListingDraft(c *gin.Context) (response ctx := r.Context() acctID := middleware.GetIdentity(ctx).Account.AccountID - orderIndex, err := s.accts.CreateSyncGroupListingDraft(ctx, acctID) - if err != nil { + if _, err := s.accts.CreateSyncGroupListingDraft(ctx, acctID); err != nil { return nil, response.Errorf("failed to create new listing draft: %w", err) } return response.Redirect( http.StatusSeeOther, - fmt.Sprintf("/ui/accounts/%d/inventory/sync-groups/draft/listings/%d", acctID, orderIndex), + fmt.Sprintf("/ui/accounts/%d/inventory/sync-groups/draft/table", acctID), ), nil } @@ -113,7 +112,7 @@ func (s *accountSubrouter) setShopInSyncGroupListingDraft(c *gin.Context) (respo return response.Redirect( http.StatusSeeOther, - fmt.Sprintf("/ui/accounts/%d/inventory/sync-groups/draft/listings/%d", acctID, orderIndex), + fmt.Sprintf("/ui/accounts/%d/inventory/sync-groups/draft/table", acctID), ), nil } @@ -140,7 +139,7 @@ func (s *accountSubrouter) setListingInSyncGroupListingDraft(c *gin.Context) (re return response.Redirect( http.StatusSeeOther, - fmt.Sprintf("/ui/accounts/%d/inventory/sync-groups/draft/listings/%d", acctID, orderIndex), + fmt.Sprintf("/ui/accounts/%d/inventory/sync-groups/draft/table", acctID), ), nil } @@ -159,7 +158,10 @@ func (s *accountSubrouter) deleteSyncGroupListingDraft(c *gin.Context) (response return nil, response.Errorf("failed to delete listing: %w", response.ErrorFromConstant(err)) } - return response.Status(200), nil + return response.Redirect( + http.StatusSeeOther, + fmt.Sprintf("/ui/accounts/%d/inventory/sync-groups/draft/table", acctID), + ), nil } // POST /api/accounts/{acctID}/inventory/sync-groups diff --git a/templates/component_bodies/accounts/{acctID}/inventory/sync-groups/draft/listings/{orderIndex}.html.tmpl b/templates/component_bodies/accounts/{acctID}/inventory/sync-groups/draft/listings/{orderIndex}.html.tmpl index 923381f..5c3e055 100644 --- a/templates/component_bodies/accounts/{acctID}/inventory/sync-groups/draft/listings/{orderIndex}.html.tmpl +++ b/templates/component_bodies/accounts/{acctID}/inventory/sync-groups/draft/listings/{orderIndex}.html.tmpl @@ -38,7 +38,7 @@ platform: event.target.value.replace(/-[^ ]*/, ""), "shop-id": event.target.value.replace(/[^ ]*-/, "") }' - hx-target="closest tr" + hx-target="#accounts-acct-id-inventory-sync-groups-draft-table" hx-swap="outerHTML" _=" on change @@ -73,7 +73,7 @@ hx-vals='js:{ "listing-id": event.target.value, }' - hx-target="closest tr" + hx-target="#accounts-acct-id-inventory-sync-groups-draft-table" hx-swap="outerHTML" _=" @@ -116,9 +116,9 @@ - {{ componentBody "button-dev" + {{ componentBody "button" "HXDelete" (printf "/api/accounts/%d/inventory/sync-groups/draft/listings/%d" $acctID $orderIndex) - "HXTarget" "closest tr" + "HXTarget" "#accounts-acct-id-inventory-sync-groups-draft-table" "HXSwap" "outerHTML" "Text" "Remove" }} diff --git a/templates/component_bodies/accounts/{acctID}/inventory/sync-table-v2.html.tmpl b/templates/component_bodies/accounts/{acctID}/inventory/sync-groups/draft/table.html.tmpl similarity index 94% rename from templates/component_bodies/accounts/{acctID}/inventory/sync-table-v2.html.tmpl rename to templates/component_bodies/accounts/{acctID}/inventory/sync-groups/draft/table.html.tmpl index dabdce9..c5549e6 100644 --- a/templates/component_bodies/accounts/{acctID}/inventory/sync-table-v2.html.tmpl +++ b/templates/component_bodies/accounts/{acctID}/inventory/sync-groups/draft/table.html.tmpl @@ -14,7 +14,7 @@ {{- $stores := $dot.Accounts.GetShops $acctID -}} - +
-{{- range $shop := $shops }} - - -{{- end }} - - diff --git a/templates/component_bodies/accounts/{acctID}/inventory/sync-table/showcase-table.html.tmpl b/templates/component_bodies/accounts/{acctID}/inventory/sync-table/showcase-table.html.tmpl deleted file mode 100644 index 5be172a..0000000 --- a/templates/component_bodies/accounts/{acctID}/inventory/sync-table/showcase-table.html.tmpl +++ /dev/null @@ -1,40 +0,0 @@ -
diff --git a/templates/component_bodies/accounts/{acctID}/inventory/sync-table.html.tmpl b/templates/component_bodies/accounts/{acctID}/inventory/sync-table.html.tmpl deleted file mode 100644 index 88a06ae..0000000 --- a/templates/component_bodies/accounts/{acctID}/inventory/sync-table.html.tmpl +++ /dev/null @@ -1,46 +0,0 @@ -{{- $dot := or .dot . }} - -{{- $dot.Auth.ByMatchingAccountID 2 }} - -{{- $acctID := $dot.Identity.Account.AccountID }} -{{- $stores := $dot.Accounts.GetShops $acctID -}} - - - - - - - {{- range $store := $stores }} - - - {{- end }} - - - - - - {{- componentBody "accounts/{acctID}/inventory/sync-table/new-row" "dot" $dot }} - - - - - {{- range $store := $stores }} - - - {{- end }} - - - - -
- {{ $store.Platform }}: {{ $store.Name }} - - Count - -
- {{ $store.Platform }}: {{ $store.Name }} - - Count - -
- diff --git a/templates/component_bodies/accounts/{acctID}/inventory/sync-table/new-row.html.tmpl b/templates/component_bodies/accounts/{acctID}/inventory/sync-table/new-row.html.tmpl deleted file mode 100644 index 9bba328..0000000 --- a/templates/component_bodies/accounts/{acctID}/inventory/sync-table/new-row.html.tmpl +++ /dev/null @@ -1,55 +0,0 @@ -{{/* TODO: delete when done with the newer draft */}} -{{- $dot := or .dot .}} - -{{- $dot.Auth.ByMatchingAccountID 2 }} - -{{- $acctID := $dot.Identity.Account.AccountID }} -{{- $shops := $dot.Accounts.GetShops $acctID -}} - - -
- - - - -
- - - - - - - - - - - - -
- ID - - Name - - Description - - Count -
- - - - - - - - - - - -
- diff --git a/templates/component_bodies/button-dev.html.tmpl b/templates/component_bodies/button.html.tmpl similarity index 100% rename from templates/component_bodies/button-dev.html.tmpl rename to templates/component_bodies/button.html.tmpl diff --git a/templates/component_bodies/nav_bar.html.tmpl b/templates/component_bodies/nav_bar.html.tmpl deleted file mode 100644 index 6c75f22..0000000 --- a/templates/component_bodies/nav_bar.html.tmpl +++ /dev/null @@ -1,70 +0,0 @@ -{{/* TODO: delete, once not needed */}} - -{{/* "dot" . */}} - - - diff --git a/templates/page_bodies/account-creation.html.tmpl b/templates/page_bodies/account-creation.html.tmpl deleted file mode 100644 index 1e24c6d..0000000 --- a/templates/page_bodies/account-creation.html.tmpl +++ /dev/null @@ -1,14 +0,0 @@ -{{- define "title" }} Inventory++ Create an Account {{ end }} - -{{/* TODO: will need to verify the email address */}} - -
-
- - - -
-
diff --git a/templates/page_bodies/accounts/{acctID}/inventory.html.tmpl b/templates/page_bodies/accounts/{acctID}/inventory.html.tmpl index 35ff880..afd542e 100644 --- a/templates/page_bodies/accounts/{acctID}/inventory.html.tmpl +++ b/templates/page_bodies/accounts/{acctID}/inventory.html.tmpl @@ -17,24 +17,24 @@

(Draft 2)

- {{ componentBody "accounts/{acctID}/inventory/sync-table-v2" "dot" . }} + {{ componentBody "accounts/{acctID}/inventory/sync-groups/draft/table" "dot" . }}
- {{ componentBody "button-dev" + {{ componentBody "button" "HXPost" (printf "/api/accounts/%d/inventory/sync-groups/draft/listings" $acctID) - "HXTarget" "previous table > tbody" - "HXSwap" "beforeend" + "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 in #inventory-table-2 + send rowUpdated to the first 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 */}} - {{ componentBody "button-dev" + {{ componentBody "button" "ID" "create-sync-group-button" "HXPost" (printf "/api/accounts/%d/sync-groups" $acctID) "Class" "mt-[1em] mb-[1em]" @@ -51,24 +51,3 @@ }}
- -
-

- Draft 1 -

- {{ componentBody "accounts/{acctID}/inventory/sync-table" "dot" . }} -
- -
- {{ componentBody "accounts/{acctID}/inventory/sync-table/showcase-table" "dot" . }} -
- -
- {{ componentBody "button-dev" - "HXGet" (printf "/api/accounts/%d/inventory/sync-table/new-row" $acctID) - "HXTarget" "#inventory-table > tbody" - "HXSwap" "beforeend" - "Class" "mt-[1em] mb-[1em]" - "Text" "Add Row" - }} -
diff --git a/templates/page_bodies/conflict.html.tmpl b/templates/page_bodies/conflict.html.tmpl deleted file mode 100644 index 8b0a63b..0000000 --- a/templates/page_bodies/conflict.html.tmpl +++ /dev/null @@ -1,11 +0,0 @@ -{{- define "title" }} Inventory++ Invalid Link {{ end }} - - -
- Invalid Link: {{ .Request.URL.Path }} -
- - -
- Return Home -
diff --git a/templates/page_bodies/login.html.tmpl b/templates/page_bodies/login.html.tmpl deleted file mode 100644 index 7d87238..0000000 --- a/templates/page_bodies/login.html.tmpl +++ /dev/null @@ -1,11 +0,0 @@ -{{/* TODO: delete this page, when certain it's not wanted anymore */}} - -

Log In

- -
- - -
diff --git a/templates/page_bodies/not-found.html.tmpl b/templates/page_bodies/not-found.html.tmpl deleted file mode 100644 index 8c42c62..0000000 --- a/templates/page_bodies/not-found.html.tmpl +++ /dev/null @@ -1,11 +0,0 @@ -{{- define "title" }} Inventory++ Page Not Found {{ end }} - - -
- Page Not Found: {{ .Request.URL.Path }} -
- - -
- Return Home -
diff --git a/templates/page_bodies/sign-up.html.tmpl b/templates/page_bodies/sign-up.html.tmpl deleted file mode 100644 index 6816394..0000000 --- a/templates/page_bodies/sign-up.html.tmpl +++ /dev/null @@ -1,11 +0,0 @@ -{{/* TODO: not used - read for deletion */}} - -

Sign Up

- -
- - -