updated templater library; added accordion component
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
{{/* Templates: */}}
|
||||
{{/* details-header */}}
|
||||
{{/* details-body */}}
|
||||
|
||||
{{/* Props: */}}
|
||||
{{/*
|
||||
Open: bool
|
||||
GroupName: for doing 'open' css state styles
|
||||
|
||||
Class, Style,
|
||||
SummaryClass, SummaryStyle
|
||||
*/}}
|
||||
{{/* TODO: find a way to not have to hardcode the tailwind classes for the group-open styles */}}
|
||||
{{/* TODO: rename this component to 'accordion' */}}
|
||||
|
||||
|
||||
{{- $groupSuffix := "" }}
|
||||
{{- if .GroupName }}
|
||||
{{- $groupSuffix = printf "/%s" .GroupName }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
<details
|
||||
class="
|
||||
group{{$groupSuffix}}
|
||||
|
||||
flex
|
||||
flex-col
|
||||
items-stretch
|
||||
|
||||
rounded-lg
|
||||
open:bg-card
|
||||
|
||||
details-content:flex
|
||||
details-content:flex-col
|
||||
details-content:items-center
|
||||
details-content:px-[1em]
|
||||
|
||||
open:details-content:p-[1em]
|
||||
|
||||
details-content:opacity-[0]
|
||||
open:details-content:opacity-[1]
|
||||
|
||||
details-content:transform-[translate(0px,-2em)]
|
||||
open:details-content:transform-[translate(0px,0px)]
|
||||
|
||||
details-content:transition-[opacity_transform]
|
||||
|
||||
{{.Class}}
|
||||
"
|
||||
style="{{.Style}}"
|
||||
{{if .Open}}open{{end}}
|
||||
hx-preserve
|
||||
>
|
||||
{{/* TODO: old border style - delete when sure
|
||||
details-content:border-transparent
|
||||
open:details-content:border-dotted
|
||||
open:details-content:border-x-[0px]
|
||||
open:details-content:border-x-transparent
|
||||
open:details-content:border-b-[0px]
|
||||
open:details-content:border-b-transparent
|
||||
open:details-content:border-t-background
|
||||
open:details-content:border-t-[0.25rem]
|
||||
details-content:outline-transparent
|
||||
*/}}
|
||||
|
||||
<summary
|
||||
class="
|
||||
flex
|
||||
items-center
|
||||
justify-center
|
||||
gap-[1em]
|
||||
|
||||
w-full
|
||||
p-[1em]
|
||||
bg-accent
|
||||
rounded-lg
|
||||
|
||||
list-none
|
||||
cursor-pointer
|
||||
|
||||
after:content-['+']
|
||||
after:absolute
|
||||
after:right-[0.5em]
|
||||
after:font-bold
|
||||
after:text-[2em]
|
||||
after:leading-[1em]
|
||||
group-open{{$groupSuffix}}:after:content-['-']
|
||||
|
||||
{{.SummaryClass}}
|
||||
"
|
||||
style="contain: layout; {{.SummaryStyle}}"
|
||||
>
|
||||
{{ slot "accordion-header" }}
|
||||
</summary>
|
||||
|
||||
{{ slot "accordion-body" }}
|
||||
</details>
|
||||
+2
-1
@@ -7,7 +7,8 @@
|
||||
"HXSwap" "none"
|
||||
"HXSelect" "#accounts-acct-id-inventory-sync-groups-mock-draft-table"
|
||||
"ID" "sync-groups-mock-draft-table-add-listing-button"
|
||||
"Class" "mt-[1em] mb-[1em]"
|
||||
"Class" ""
|
||||
"Style" ""
|
||||
"Text" "Add Listing"
|
||||
"_" `
|
||||
on click
|
||||
|
||||
+11
-4
@@ -2,17 +2,23 @@
|
||||
|
||||
|
||||
{{- $acctID := .PathParams.acctID }}
|
||||
{{- $listings := .Accounts.GetMockSyncGroupListingDrafts $acctID }}
|
||||
|
||||
|
||||
<table
|
||||
id="accounts-acct-id-inventory-sync-groups-mock-draft-table"
|
||||
class="max-w-full overflow-x-auto"
|
||||
class="
|
||||
max-w-full overflow-x-auto
|
||||
|
||||
grid-table-6
|
||||
max-h-[50vh]
|
||||
"
|
||||
hx-get="{{ printf "/ui/accounts/%d/inventory/sync-groups/mock/draft/table" $acctID }}"
|
||||
hx-trigger="sse:{{ printf "accounts_%d_inventory_sync-groups_mock_draft" $acctID }},sse:{{ printf "accounts_%d_inventory_sync-groups_mock_draft_listings" $acctID }}"
|
||||
hx-select="#accounts-acct-id-inventory-sync-groups-mock-draft-table"
|
||||
hx-swap="morph:outerHTML"
|
||||
>
|
||||
<thead>
|
||||
<thead class="sticky top-0">
|
||||
<tr>
|
||||
<th>
|
||||
Shop
|
||||
@@ -58,14 +64,14 @@
|
||||
send setDisabled(disabled: not allRowsFilledOut or numRows < 2) to #create-mock-sync-group-button
|
||||
"
|
||||
>
|
||||
{{- $listings := .Accounts.GetMockSyncGroupListingDrafts $acctID }}
|
||||
{{- range $listing := $listings }}
|
||||
{{- component (printf "accounts/%d/inventory/sync-groups/mock/draft/listings/%d" $acctID $listing.OrderIndex)
|
||||
"Listings" $listings
|
||||
}}
|
||||
{{- end }}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
{{- if gt (len $listings) 5 }}
|
||||
<tfoot class="sticky bottom-0 outline-1 outline-(--table-tfoot)">
|
||||
<tr>
|
||||
<th>
|
||||
Shop
|
||||
@@ -87,6 +93,7 @@
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
{{- end }}
|
||||
</table>
|
||||
|
||||
{{/*
|
||||
|
||||
+2
-1
@@ -18,8 +18,9 @@
|
||||
|
||||
{{ component "button"
|
||||
"ID" "create-mock-sync-group-button"
|
||||
"Class" "mt-[1em] mb-[1em]"
|
||||
"Text" "Save Sync Group"
|
||||
"Class" ""
|
||||
"Style" ""
|
||||
"Disabled" (or (not $enoughListings) (not $allCompleted))
|
||||
"_" `
|
||||
on setDisabled(disabled)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
disabled:bg-accent-secondary
|
||||
disabled:cursor-not-allowed
|
||||
disabled:no-underline
|
||||
{{.Class}}
|
||||
{{if .Class}}{{.Class}}{{end}}
|
||||
"
|
||||
{{- if .ID }}
|
||||
id="{{.ID}}"
|
||||
|
||||
@@ -6,207 +6,138 @@
|
||||
|
||||
{{- define "title" }} Manage Mock Inventory ⋅ Inventory++ {{ end }}
|
||||
|
||||
{{- define "header-accordion-header" }}
|
||||
<h2 class="inline-block">
|
||||
New Sync Group
|
||||
</h2>
|
||||
{{- end }}
|
||||
|
||||
{{- define "header-accordion-body" }}
|
||||
{{- $acctID := .Identity.Account.AccountID }}
|
||||
{{ component (printf "accounts/%d/inventory/sync-groups/mock/draft/table" $acctID) }}
|
||||
|
||||
<form
|
||||
hx-post="{{ (printf "/api/accounts/%d/inventory/sync-groups/mock" $acctID) }}"
|
||||
>
|
||||
<label class="block text-center mt-[1em]">
|
||||
Name:
|
||||
<input
|
||||
type="text"
|
||||
name="name"
|
||||
class="bg-accent p-[0.25em] rounded-sm"
|
||||
placeholder="New Sync Group"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div class="flex justify-center gap-[0.5em] mt-[1em]">
|
||||
{{ component (printf "accounts/%d/inventory/sync-groups/mock/draft/table/add-listing-button" $acctID) }}
|
||||
{{ component (printf "accounts/%d/inventory/sync-groups/mock/draft/table/save-sync-group-button" $acctID) }}
|
||||
</div>
|
||||
</form>
|
||||
{{- end }}
|
||||
|
||||
{{- define "sync-group-accordion-header" }}
|
||||
<h3 class="text-center">
|
||||
{{ .Group.Name }}
|
||||
</h3>
|
||||
{{- end }}
|
||||
|
||||
{{- define "sync-group-accordion-body" }}
|
||||
{{- $acctID := .Identity.Account.AccountID }}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Name
|
||||
</th>
|
||||
<th>
|
||||
SKU
|
||||
</th>
|
||||
<th>
|
||||
Description
|
||||
</th>
|
||||
<th>
|
||||
Count
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{- $dot := . }}
|
||||
{{- range $listing := .Group.Listings }}
|
||||
<tr>
|
||||
{{- $val := $dot.Accounts.GetMockListing $acctID $listing.Platform $listing.ShopID $listing.ListingID }}
|
||||
<td>
|
||||
{{ $val.Name }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $val.SKU }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $val.Description }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $val.Count }}
|
||||
</td>
|
||||
</tr>
|
||||
{{- end }}
|
||||
</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"
|
||||
}}
|
||||
{{- end }}
|
||||
|
||||
|
||||
<section
|
||||
id="new-mock-sync-group"
|
||||
class="py-[2em] flex flex-col items-center"
|
||||
class="
|
||||
flex flex-col items-stretch
|
||||
|
||||
py-[1em]
|
||||
"
|
||||
hx-swap-oob="true"
|
||||
>
|
||||
<details
|
||||
class="
|
||||
group
|
||||
{{ component "accordion"
|
||||
"Open" true
|
||||
"Class" `
|
||||
mx-[1em]
|
||||
mb-[1em]
|
||||
`
|
||||
"#accordion-header" "header-accordion-header"
|
||||
"#accordion-body" "header-accordion-body"
|
||||
}}
|
||||
|
||||
flex
|
||||
flex-col
|
||||
items-center
|
||||
|
||||
{{/* TODO: make custom class for all this */}}
|
||||
details-content:opacity-[0]
|
||||
open:details-content:opacity-[1]
|
||||
|
||||
details-content:transform-[translate(0px,-2em)]
|
||||
open:details-content:transform-[translate(0px,0px)]
|
||||
|
||||
details-content:border-transparent
|
||||
open:details-content:border-dotted
|
||||
open:details-content:border-x-[0px]
|
||||
open:details-content:border-x-transparent
|
||||
open:details-content:border-b-[0px]
|
||||
open:details-content:border-b-transparent
|
||||
open:details-content:border-t-background
|
||||
open:details-content:border-t-[0.25rem]
|
||||
details-content:outline-transparent
|
||||
|
||||
details-content:transition-[opacity_transform]
|
||||
"
|
||||
hx-preserve
|
||||
>
|
||||
|
||||
<summary
|
||||
class="
|
||||
flex
|
||||
items-center
|
||||
gap-[1em]
|
||||
list-none
|
||||
p-[1em]
|
||||
mb-[1em]
|
||||
cursor-pointer
|
||||
bg-accent
|
||||
rounded-lg
|
||||
|
||||
after:content-['+']
|
||||
group-open:after:content-['-']
|
||||
after:font-bold
|
||||
after:text-[2em]
|
||||
after:leading-[1em]
|
||||
"
|
||||
>
|
||||
<h2 class="inline-block">
|
||||
New Sync Group
|
||||
</h2>
|
||||
</summary>
|
||||
|
||||
{{ component (printf "accounts/%d/inventory/sync-groups/mock/draft/table" $acctID) }}
|
||||
|
||||
<form
|
||||
hx-post="{{ (printf "/api/accounts/%d/inventory/sync-groups/mock" $acctID) }}"
|
||||
>
|
||||
<label class="block text-center mt-[1em]">
|
||||
Name:
|
||||
<input
|
||||
type="text"
|
||||
name="name"
|
||||
class="bg-accent p-[0.25em] rounded-sm"
|
||||
placeholder="New Sync Group"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div class="flex justify-center gap-[0.5em]">
|
||||
{{ component (printf "accounts/%d/inventory/sync-groups/mock/draft/table/add-listing-button" $acctID) }}
|
||||
{{ component (printf "accounts/%d/inventory/sync-groups/mock/draft/table/save-sync-group-button" $acctID) }}
|
||||
</div>
|
||||
</form>
|
||||
</details>
|
||||
|
||||
|
||||
{{- $dot := . }}
|
||||
<ul
|
||||
id="existing-mock-sync-groups-list"
|
||||
class="my-[1em] flex flex-col gap-[1em]"
|
||||
class="flex flex-col gap-[1em]"
|
||||
hx-get="{{ printf "/ui/accounts/%d/inventory/mock" $acctID }}"
|
||||
hx-select="#existing-mock-sync-groups-list"
|
||||
hx-swap="morph"
|
||||
hx-trigger="{{ printf "sse:accounts_%d_inventory_sync-groups_mock,sse:accounts_%d_inventory_mock" $acctID }}"
|
||||
|
||||
hx-trigger="{{ printf "sse:accounts_%d_inventory_sync-groups_mock,sse:accounts_%d_inventory_mock" $acctID $acctID }}"
|
||||
>
|
||||
|
||||
{{- range $grp := .Accounts.ListMockSyncGroups $acctID }}
|
||||
<li
|
||||
id="sync-group-{{$grp.SyncGroupID}}"
|
||||
class="bg-card rounded-lg mx-[1em] p-[1em]"
|
||||
class="
|
||||
mx-[1em]
|
||||
"
|
||||
>
|
||||
<details
|
||||
class="
|
||||
group
|
||||
|
||||
flex
|
||||
flex-col
|
||||
items-center
|
||||
|
||||
details-content:flex
|
||||
details-content:flex-col
|
||||
details-content:items-center
|
||||
|
||||
{{/* TODO: make custom class for all this */}}
|
||||
details-content:opacity-[0]
|
||||
open:details-content:opacity-[1]
|
||||
|
||||
details-content:transform-[translate(0px,-2em)]
|
||||
open:details-content:transform-[translate(0px,0px)]
|
||||
|
||||
details-content:border-transparent
|
||||
open:details-content:border-dotted
|
||||
open:details-content:border-x-[0px]
|
||||
open:details-content:border-x-transparent
|
||||
open:details-content:border-b-[0px]
|
||||
open:details-content:border-b-transparent
|
||||
open:details-content:border-t-background
|
||||
open:details-content:border-t-[0.25rem]
|
||||
details-content:outline-transparent
|
||||
|
||||
details-content:transition-[opacity_transform]
|
||||
"
|
||||
>
|
||||
<summary
|
||||
class="
|
||||
flex
|
||||
items-center
|
||||
gap-[1em]
|
||||
list-none
|
||||
p-[1em]
|
||||
group-open:mb-[1em]
|
||||
cursor-pointer
|
||||
bg-accent
|
||||
rounded-lg
|
||||
|
||||
after:content-['+']
|
||||
group-open:after:content-['-']
|
||||
after:font-bold
|
||||
after:text-[2em]
|
||||
after:leading-[1em]
|
||||
"
|
||||
>
|
||||
<h3>
|
||||
Name: {{ $grp.Name }}
|
||||
</h3>
|
||||
</summary>
|
||||
|
||||
<table class="mt-[1em]">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Name
|
||||
</th>
|
||||
<th>
|
||||
SKU
|
||||
</th>
|
||||
<th>
|
||||
Description
|
||||
</th>
|
||||
<th>
|
||||
Count
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{- range $listing := $grp.Listings }}
|
||||
<tr>
|
||||
{{- $val := $dot.Accounts.GetMockListing $acctID $listing.Platform $listing.ShopID $listing.ListingID }}
|
||||
<td>
|
||||
{{ $val.Name }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $val.SKU }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $val.Description }}
|
||||
</td>
|
||||
<td>
|
||||
{{ $val.Count }}
|
||||
</td>
|
||||
</tr>
|
||||
{{- end }}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{- component "button"
|
||||
"Class" "mt-[1em]"
|
||||
"Text" "Delete Group"
|
||||
"HXDelete" (printf "/api/accounts/%d/inventory/sync-groups/mock/%d" $acctID $grp.SyncGroupID)
|
||||
"HXSwap" "none"
|
||||
}}
|
||||
</details>
|
||||
{{ component "accordion"
|
||||
"GroupName" "sync-group"
|
||||
"Group" $grp
|
||||
"#accordion-header" "sync-group-accordion-header"
|
||||
"#accordion-body" "sync-group-accordion-body"
|
||||
}}
|
||||
</li>
|
||||
{{- end }}
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user