mock shop page: can set count
This commit is contained in:
@@ -322,7 +322,6 @@ func (db *Store) CreateMockListing(ctx context.Context, listing MockListing) (Mo
|
|||||||
return listing, nil
|
return listing, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateMockListing updates a mock listing, but not it's count
|
|
||||||
func (db *Store) UpdateMockListing(ctx context.Context, listing MockListing) error {
|
func (db *Store) UpdateMockListing(ctx context.Context, listing MockListing) error {
|
||||||
_, listingTableName, err := getMockShopAndListingsTableNames(listing.Platform)
|
_, listingTableName, err := getMockShopAndListingsTableNames(listing.Platform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -338,7 +337,8 @@ func (db *Store) UpdateMockListing(ctx context.Context, listing MockListing) err
|
|||||||
SET
|
SET
|
||||||
sku = @sku,
|
sku = @sku,
|
||||||
name = @name,
|
name = @name,
|
||||||
description = @description
|
description = @description,
|
||||||
|
"count" = @count
|
||||||
WHERE
|
WHERE
|
||||||
account_id = @account_id
|
account_id = @account_id
|
||||||
AND shop_id = @shop_id
|
AND shop_id = @shop_id
|
||||||
@@ -353,6 +353,7 @@ func (db *Store) UpdateMockListing(ctx context.Context, listing MockListing) err
|
|||||||
"sku": listing.SKU,
|
"sku": listing.SKU,
|
||||||
"name": listing.Name,
|
"name": listing.Name,
|
||||||
"description": listing.Description,
|
"description": listing.Description,
|
||||||
|
"count": listing.Count,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -365,6 +366,7 @@ func (db *Store) UpdateMockListing(ctx context.Context, listing MockListing) err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: will have to be updated once we start creating mock sync groups
|
||||||
func (db *Store) DeleteMockListing(ctx context.Context, ids AccountShopListingIDs) error {
|
func (db *Store) DeleteMockListing(ctx context.Context, ids AccountShopListingIDs) error {
|
||||||
_, listingTableName, err := getMockShopAndListingsTableNames(ids.Platform)
|
_, listingTableName, err := getMockShopAndListingsTableNames(ids.Platform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -279,6 +279,7 @@ func (s *accountSubrouter) addMockListing(c *gin.Context) (response.Response, er
|
|||||||
name string
|
name string
|
||||||
sku string
|
sku string
|
||||||
description string
|
description string
|
||||||
|
count int
|
||||||
)
|
)
|
||||||
|
|
||||||
err := param.Path("platform", param.Platform(&platform)).
|
err := param.Path("platform", param.Platform(&platform)).
|
||||||
@@ -286,6 +287,7 @@ func (s *accountSubrouter) addMockListing(c *gin.Context) (response.Response, er
|
|||||||
Form("name", param.Text(&name)).
|
Form("name", param.Text(&name)).
|
||||||
Form("sku", param.Text(&sku)).
|
Form("sku", param.Text(&sku)).
|
||||||
Form("description", param.Text(&description)).
|
Form("description", param.Text(&description)).
|
||||||
|
Form("count", param.Int(&count)).
|
||||||
Unmarshal(c)
|
Unmarshal(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -300,6 +302,7 @@ func (s *accountSubrouter) addMockListing(c *gin.Context) (response.Response, er
|
|||||||
Name: name,
|
Name: name,
|
||||||
SKU: sku,
|
SKU: sku,
|
||||||
Description: description,
|
Description: description,
|
||||||
|
Count: int64(count),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -320,6 +323,7 @@ func (s *accountSubrouter) updateMockListing(c *gin.Context) (response.Response,
|
|||||||
name string
|
name string
|
||||||
sku string
|
sku string
|
||||||
description string
|
description string
|
||||||
|
count int
|
||||||
)
|
)
|
||||||
|
|
||||||
err := param.Path("platform", param.Platform(&platform)).
|
err := param.Path("platform", param.Platform(&platform)).
|
||||||
@@ -328,6 +332,7 @@ func (s *accountSubrouter) updateMockListing(c *gin.Context) (response.Response,
|
|||||||
Form("name", param.Text(&name)).
|
Form("name", param.Text(&name)).
|
||||||
Form("sku", param.Text(&sku)).
|
Form("sku", param.Text(&sku)).
|
||||||
Form("description", param.Text(&description)).
|
Form("description", param.Text(&description)).
|
||||||
|
Form("count", param.Int(&count)).
|
||||||
Unmarshal(c)
|
Unmarshal(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -342,6 +347,7 @@ func (s *accountSubrouter) updateMockListing(c *gin.Context) (response.Response,
|
|||||||
Name: name,
|
Name: name,
|
||||||
SKU: sku,
|
SKU: sku,
|
||||||
Description: description,
|
Description: description,
|
||||||
|
Count: int64(count),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+33
-8
@@ -35,14 +35,16 @@
|
|||||||
listingID,
|
listingID,
|
||||||
name,
|
name,
|
||||||
sku,
|
sku,
|
||||||
description
|
description,
|
||||||
|
count
|
||||||
)
|
)
|
||||||
send hide to #new-listing-form
|
send hide to #new-listing-form
|
||||||
send show(
|
send show(
|
||||||
listingID: listingID,
|
listingID: listingID,
|
||||||
name: name,
|
name: name,
|
||||||
sku: sku,
|
sku: sku,
|
||||||
description: description
|
description: description,
|
||||||
|
count: count
|
||||||
) to #edit-listing-form
|
) to #edit-listing-form
|
||||||
|
|
||||||
on startEditingNewListing
|
on startEditingNewListing
|
||||||
@@ -72,6 +74,7 @@
|
|||||||
set the value of the first <input[name='name']/> in me to ''
|
set the value of the first <input[name='name']/> in me to ''
|
||||||
set the value of the first <input[name='sku']/> in me to ''
|
set the value of the first <input[name='sku']/> in me to ''
|
||||||
set the value of the first <input[name='description']/> in me to ''
|
set the value of the first <input[name='description']/> in me to ''
|
||||||
|
set the value of the first <input[name='count']/> in me to '0'
|
||||||
on show
|
on show
|
||||||
remove .hidden from me
|
remove .hidden from me
|
||||||
remove @disabled from <button#save-as-new-listing-button/>
|
remove @disabled from <button#save-as-new-listing-button/>
|
||||||
@@ -87,7 +90,6 @@
|
|||||||
type="text"
|
type="text"
|
||||||
name="name"
|
name="name"
|
||||||
required
|
required
|
||||||
minlength="5"
|
|
||||||
placeholder="What's in a name..."
|
placeholder="What's in a name..."
|
||||||
class="bg-accent p-[0.25em] rounded-sm"
|
class="bg-accent p-[0.25em] rounded-sm"
|
||||||
/>
|
/>
|
||||||
@@ -107,10 +109,20 @@
|
|||||||
type="text"
|
type="text"
|
||||||
name="description"
|
name="description"
|
||||||
required
|
required
|
||||||
minlength="10"
|
|
||||||
placeholder="Anything will do..."
|
placeholder="Anything will do..."
|
||||||
class="bg-accent p-[0.25em] rounded-sm"
|
class="bg-accent p-[0.25em] rounded-sm"
|
||||||
/>
|
/>
|
||||||
|
<label for="count" class="self-center">
|
||||||
|
Count:
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
name="count"
|
||||||
|
required
|
||||||
|
class="bg-accent p-[0.25em] rounded-sm"
|
||||||
|
value="0"
|
||||||
|
min="0"
|
||||||
|
/>
|
||||||
{{ component "button"
|
{{ component "button"
|
||||||
"Text" "Save"
|
"Text" "Save"
|
||||||
"Class" "self-center p-[1em] col-span-2"
|
"Class" "self-center p-[1em] col-span-2"
|
||||||
@@ -141,11 +153,13 @@
|
|||||||
set the value of the first <input[name='name']/> in me to ''
|
set the value of the first <input[name='name']/> in me to ''
|
||||||
set the value of the first <input[name='sku']/> in me to ''
|
set the value of the first <input[name='sku']/> in me to ''
|
||||||
set the value of the first <input[name='description']/> in me to ''
|
set the value of the first <input[name='description']/> in me to ''
|
||||||
|
set the value of the first <input[name='count']/> in me to ''
|
||||||
on show(
|
on show(
|
||||||
listingID,
|
listingID,
|
||||||
name,
|
name,
|
||||||
sku,
|
sku,
|
||||||
description
|
description,
|
||||||
|
count
|
||||||
)
|
)
|
||||||
set :listingID to listingID
|
set :listingID to listingID
|
||||||
remove .hidden from me
|
remove .hidden from me
|
||||||
@@ -155,6 +169,7 @@
|
|||||||
set the value of the first <input[name='name']/> in me to name
|
set the value of the first <input[name='name']/> in me to name
|
||||||
set the value of the first <input[name='sku']/> in me to sku
|
set the value of the first <input[name='sku']/> in me to sku
|
||||||
set the value of the first <input[name='description']/> in me to description
|
set the value of the first <input[name='description']/> in me to description
|
||||||
|
set the value of the first <input[name='count']/> in me to count
|
||||||
set the innerHTML of the <h3/> in me to ('Editing: ' + name)
|
set the innerHTML of the <h3/> in me to ('Editing: ' + name)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
@@ -168,7 +183,6 @@
|
|||||||
type="text"
|
type="text"
|
||||||
name="name"
|
name="name"
|
||||||
required
|
required
|
||||||
minlength="5"
|
|
||||||
placeholder="What's in a name..."
|
placeholder="What's in a name..."
|
||||||
class="bg-accent p-[0.25em] rounded-sm"
|
class="bg-accent p-[0.25em] rounded-sm"
|
||||||
/>
|
/>
|
||||||
@@ -188,10 +202,20 @@
|
|||||||
type="text"
|
type="text"
|
||||||
name="description"
|
name="description"
|
||||||
required
|
required
|
||||||
minlength="10"
|
|
||||||
placeholder="Anything will do..."
|
placeholder="Anything will do..."
|
||||||
class="bg-accent p-[0.25em] rounded-sm"
|
class="bg-accent p-[0.25em] rounded-sm"
|
||||||
/>
|
/>
|
||||||
|
<label for="count" class="self-center">
|
||||||
|
Count:
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
name="count"
|
||||||
|
required
|
||||||
|
class="bg-accent p-[0.25em] rounded-sm"
|
||||||
|
value="0"
|
||||||
|
min="0"
|
||||||
|
/>
|
||||||
<input
|
<input
|
||||||
type="hidden"
|
type="hidden"
|
||||||
name="listingID"
|
name="listingID"
|
||||||
@@ -310,7 +334,8 @@
|
|||||||
listingID: '{{$listing.ListingID}}',
|
listingID: '{{$listing.ListingID}}',
|
||||||
name: '{{$listing.Name}}',
|
name: '{{$listing.Name}}',
|
||||||
sku: '{{$listing.SKU}}',
|
sku: '{{$listing.SKU}}',
|
||||||
description: '{{$listing.Description}}'
|
description: '{{$listing.Description}}',
|
||||||
|
count: '{{$listing.Count}}'
|
||||||
) to #listings-container
|
) to #listings-container
|
||||||
send reset() to <li/> in the closest <ul/>
|
send reset() to <li/> in the closest <ul/>
|
||||||
add .border-foreground to me
|
add .border-foreground to me
|
||||||
|
|||||||
Reference in New Issue
Block a user