update sync group draft table shop listing options based on selected shops
This commit is contained in:
+32
-12
@@ -1,3 +1,4 @@
|
||||
{{/* optional props: .Listings = .Accounts.GetSyncGroupListingDrafts */}}
|
||||
{{/* TODO: make the save button disabled based on an api call */}}
|
||||
|
||||
{{- $acctID := .PathParams.acctID }}
|
||||
@@ -7,6 +8,11 @@
|
||||
{{- $selectedShopID := $entry.ShopID }}
|
||||
{{- $selectedListingID := $entry.ListingID }}
|
||||
|
||||
{{- $listings := .Listings }}
|
||||
{{- if not $listings }}
|
||||
{{- $listings = .Accounts.GetSyncGroupListingDrafts $acctID }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
<tr _="
|
||||
init
|
||||
@@ -26,6 +32,7 @@
|
||||
"
|
||||
>
|
||||
<td>
|
||||
{{/* TODO: filter out shops that are already selected */}}
|
||||
{{- $shops := .Accounts.GetShops $acctID -}}
|
||||
<select
|
||||
class="min-w-fit cursor-pointer"
|
||||
@@ -43,6 +50,19 @@
|
||||
>
|
||||
<option disabled {{- if not $selectedShopID }}selected{{- end }}>- Shops -</option>
|
||||
{{- range $shop := $shops }}
|
||||
{{- $shopSelectedInOtherListing := false }}
|
||||
{{- if not (eq $shop.ShopID $selectedShopID ) }}
|
||||
{{- range $listing := $listings }}
|
||||
{{- if eq $listing.ShopID $shop.ShopID }}
|
||||
{{- $shopSelectedInOtherListing = true }}
|
||||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if $shopSelectedInOtherListing }}
|
||||
{{- continue }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- $isSelectedShop := and
|
||||
(eq $selectedShopPlatform $shop.Platform)
|
||||
(eq $selectedShopID $shop.ShopID)
|
||||
@@ -60,8 +80,8 @@
|
||||
<td>
|
||||
{{- $selectedListing := "" }}
|
||||
{{- if $selectedShopID }}
|
||||
{{- $listings := .Accounts.GetListingsForShop $acctID $selectedShopPlatform $selectedShopID }}
|
||||
{{- if $listings }}
|
||||
{{- $shopListings := .Accounts.GetListingsForShop $acctID $selectedShopPlatform $selectedShopID }}
|
||||
{{- if $shopListings }}
|
||||
<select
|
||||
class="min-w-fit cursor-pointer"
|
||||
|
||||
@@ -79,19 +99,19 @@
|
||||
"
|
||||
>
|
||||
<option disabled {{if not $selectedListingID}}selected{{end}}>- Listings -</option>
|
||||
{{- range $i, $listing := $listings }}
|
||||
{{- if eq $selectedListingID $listing.ListingID }}
|
||||
{{ $selectedListing = $listing }}
|
||||
{{- range $i, $shopListing := $shopListings }}
|
||||
{{- if eq $selectedListingID $shopListing.ListingID }}
|
||||
{{ $selectedListing = $shopListing }}
|
||||
{{- end }}
|
||||
<option
|
||||
value="{{$listing.ListingID}}"
|
||||
{{if eq $selectedListingID $listing.ListingID}}selected{{end}}
|
||||
data-name="{{ $listing.Name }}"
|
||||
data-sku="{{ $listing.SKU }}"
|
||||
data-description="{{ $listing.Description }}"
|
||||
data-count="{{ $listing.Count }}"
|
||||
value="{{$shopListing.ListingID}}"
|
||||
{{if eq $selectedListingID $shopListing.ListingID}}selected{{end}}
|
||||
data-name="{{ $shopListing.Name }}"
|
||||
data-sku="{{ $shopListing.SKU }}"
|
||||
data-description="{{ $shopListing.Description }}"
|
||||
data-count="{{ $shopListing.Count }}"
|
||||
>
|
||||
{{ $listing.Name }}
|
||||
{{ $shopListing.Name }}
|
||||
</option>
|
||||
{{- end }}
|
||||
</select>
|
||||
|
||||
+3
-1
@@ -56,7 +56,9 @@
|
||||
>
|
||||
{{- $listings := .Accounts.GetSyncGroupListingDrafts $acctID }}
|
||||
{{- range $listing := $listings }}
|
||||
{{- component (printf "accounts/%d/inventory/sync-groups/draft/listings/%d" $acctID $listing.OrderIndex) }}
|
||||
{{- component (printf "accounts/%d/inventory/sync-groups/draft/listings/%d" $acctID $listing.OrderIndex)
|
||||
"Listings" $listings
|
||||
}}
|
||||
{{- end }}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
|
||||
Reference in New Issue
Block a user