Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript StoreCart class #10332

Merged
merged 3 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions resources/js/_classes/store-cart.coffee

This file was deleted.

3 changes: 2 additions & 1 deletion resources/js/core-legacy/store-supporter-tag.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { route } from 'laroute'
import { fadeToggle } from 'utils/fade'
import { toggleCart } from 'utils/store-cart'

export default class StoreSupporterTag
RESOLUTION: 8
Expand Down Expand Up @@ -148,7 +149,7 @@ export default class StoreSupporterTag
messageInputVisible = enabled && @user?.id != window.currentUser.id
fadeToggle(@messageInput, messageInputVisible)

StoreCart.setEnabled(enabled)
toggleCart(enabled)
# TODO: need to elevate this element when switching over to new store design.
$(@el).toggleClass('js-store--disabled', !enabled)
$('.js-slider').slider('disabled': !enabled)
1 change: 0 additions & 1 deletion resources/js/entrypoints/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'app-deps';

import 'jquery-pubsub.coffee';

import '_classes/store-cart.coffee';
import '_classes/store-supporter-tag-price.coffee';
import '_classes/timeout.coffee';

Expand Down
6 changes: 3 additions & 3 deletions resources/js/store-username-change.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import { route } from 'laroute'
import { trans } from 'utils/lang'
import { toggleCart } from 'utils/store-cart'

preventUsernameSubmission = ->
StoreCart.setEnabled(false)
toggleCart(false)
$('#username-check-price').text ''

checkUsernameValidity = ->
Expand All @@ -17,10 +18,9 @@ checkUsernameValidity = ->
return unless data.username == $('.js-username-change-input').val()

if data.available
$('.js-store-add-to-cart').attr 'disabled', false
toggleCart(true)
$('#username-check-price').text data.costString
$('#username-form-price').val data.cost
$('#product-form').data('disabled', false)
else
preventUsernameSubmission()

Expand Down
7 changes: 7 additions & 0 deletions resources/js/utils/store-cart.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

export function toggleCart(flag: boolean) {
$('.js-store-add-to-cart').prop('disabled', !flag);
$('#product-form').data('disabled', !flag);
}