mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Refactor SubscriptionView to use view in template
This commit is contained in:
parent
d95b3b5334
commit
2e666073f1
2 changed files with 59 additions and 65 deletions
|
@ -19,43 +19,43 @@ block content
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
h3(data-i18n="subscribe.personal_sub")
|
||||
if personalSub.prepaidCode && !personalSub.usingPrepaidCode
|
||||
if view.personalSub.prepaidCode && !view.personalSub.usingPrepaidCode
|
||||
div
|
||||
span(data-i18n="subscribe.subscribe_prepaid")
|
||||
span.spl.spr= personalSub.prepaidCode
|
||||
span.spl.spr= view.personalSub.prepaidCode
|
||||
.panel-body
|
||||
if personalSub.state === 'loading'
|
||||
if view.personalSub.state === 'loading'
|
||||
.alert.alert-info(data-i18n="subscribe.loading_info")
|
||||
else if personalSub.state === 'subscribing'
|
||||
else if view.personalSub.state === 'subscribing'
|
||||
.alert.alert-info(data-i18n="subscribe.subscribing")
|
||||
else if personalSub.sponsor
|
||||
else if view.personalSub.sponsor
|
||||
div
|
||||
span(data-i18n="subscribe.managed_by")
|
||||
span.spl.spr #{personalSub.sponsorName} (#{personalSub.sponsorEmail})
|
||||
if personalSub.endDate
|
||||
span.spl.spr #{view.personalSub.sponsorName} (#{view.personalSub.sponsorEmail})
|
||||
if view.personalSub.endDate
|
||||
div
|
||||
span(data-i18n="subscribe.will_be_cancelled")
|
||||
span.spl.spr= moment(personalSub.endDate).format('l')
|
||||
span.spl.spr= moment(view.personalSub.endDate).format('l')
|
||||
|
||||
else if personalSub.usingPrepaidCode
|
||||
else if view.personalSub.usingPrepaidCode
|
||||
div(data-i18n="subscribe.using_prepaid")
|
||||
|
||||
else if personalSub.self
|
||||
if personalSub.state === 'declined'
|
||||
else if view.personalSub.self
|
||||
if view.personalSub.state === 'declined'
|
||||
.alert.alert-danger.alert-dismissible
|
||||
span(data-i18n="buy_gems.declined")
|
||||
button.close(type="button" data-dismiss="alert")
|
||||
span(aria-hidden="true") ×
|
||||
br
|
||||
else if personalSub.state === 'unknown_error'
|
||||
else if view.personalSub.state === 'unknown_error'
|
||||
.alert.alert-danger.alert-dismissible
|
||||
button.close(type="button" data-dismiss="alert")
|
||||
span(aria-hidden="true") ×
|
||||
p(data-i18n="loading_error.unknown")
|
||||
p= personalSub.stateMessage
|
||||
p= view.personalSub.stateMessage
|
||||
br
|
||||
|
||||
if !personalSub.subscribed || personalSub.prepaidCode
|
||||
if !view.personalSub.subscribed || view.personalSub.prepaidCode
|
||||
button.start-subscription-button.btn.btn-lg.btn-success(data-i18n="subscribe.subscribe_title") Subscribe
|
||||
else
|
||||
button.end-subscription-button.btn.btn-lg.btn-warning(data-i18n="subscribe.unsubscribe") Unsubscribe
|
||||
|
@ -63,9 +63,9 @@ block content
|
|||
.unsubscribe-feedback.row.secret
|
||||
.col-lg-7
|
||||
h3
|
||||
if personalSub.monthsSubscribed > 1
|
||||
if view.personalSub.monthsSubscribed > 1
|
||||
span(data-i18n="subscribe.thank_you_months_prefix") Thank you for supporting us these last
|
||||
span.spl.spr= personalSub.monthsSubscribed
|
||||
span.spl.spr= view.personalSub.monthsSubscribed
|
||||
span(data-i18n="subscribe.thank_you_months_suffix") months.
|
||||
else
|
||||
span(data-i18n="subscribe.thank_you") Thank you for supporting CodeCombat.
|
||||
|
@ -79,43 +79,43 @@ block content
|
|||
tr
|
||||
th(data-i18n="user.status") Status
|
||||
td
|
||||
if personalSub.subscribed
|
||||
if view.personalSub.subscribed
|
||||
strong(data-i18n="account.subscribed")
|
||||
else
|
||||
if personalSub.active
|
||||
if view.personalSub.active
|
||||
strong(data-i18n="account.active")
|
||||
.text-muted(data-i18n="account.status_unsubscribed_active")
|
||||
else
|
||||
strong(data-i18n="account.unsubscribed")
|
||||
.text-muted(data-i18n="account.status_unsubscribed")
|
||||
if personalSub.activeUntil
|
||||
if view.personalSub.activeUntil
|
||||
tr
|
||||
th(data-i18n="account.active_until")
|
||||
td= moment(personalSub.activeUntil).format('l')
|
||||
if personalSub.nextPaymentDate
|
||||
td= moment(view.personalSub.activeUntil).format('l')
|
||||
if view.personalSub.nextPaymentDate
|
||||
tr
|
||||
th(data-i18n="account.next_payment")
|
||||
td= moment(personalSub.nextPaymentDate).format('l')
|
||||
if personalSub.cost
|
||||
td= moment(view.personalSub.nextPaymentDate).format('l')
|
||||
if view.personalSub.cost
|
||||
tr
|
||||
th(data-i18n="account.cost")
|
||||
td= personalSub.cost
|
||||
if personalSub.card
|
||||
td= view.personalSub.cost
|
||||
if view.personalSub.card
|
||||
tr
|
||||
th(data-i18n="account.card")
|
||||
td= personalSub.card
|
||||
td= view.personalSub.card
|
||||
|
||||
else
|
||||
if personalSub.free === true
|
||||
if view.personalSub.free === true
|
||||
div(data-i18n="subscribe.currently_free")
|
||||
else if typeof personalSub.free === 'string'
|
||||
if new Date() < new Date(personalSub.free)
|
||||
else if typeof view.personalSub.free === 'string'
|
||||
if new Date() < new Date(view.personalSub.free)
|
||||
div
|
||||
span(data-i18n="subscribe.currently_free_until")
|
||||
span.spl.spr= moment(new Date(personalSub.free)).format('l')
|
||||
span.spl.spr= moment(new Date(view.personalSub.free)).format('l')
|
||||
else
|
||||
span(data-i18n="subscribe.was_free_until")
|
||||
span.spl.spr= moment(new Date(personalSub.free)).format('l')
|
||||
span.spl.spr= moment(new Date(view.personalSub.free)).format('l')
|
||||
else
|
||||
button.start-subscription-button.btn.btn-lg.btn-success(data-i18n="subscribe.subscribe_title") Subscribe
|
||||
|
||||
|
@ -147,56 +147,56 @@ block content
|
|||
td(data-i18n="subscribe.group_discounts_12th")
|
||||
td(data-i18n="subscribe.group_discounts_40")
|
||||
.panel-body
|
||||
if recipientSubs.state === 'subscribing'
|
||||
if view.recipientSubs.state === 'subscribing'
|
||||
.alert.alert-info(data-i18n="subscribe.subscribing")
|
||||
else
|
||||
textarea.recipient-emails(rows=3, data-i18n="[placeholder]subscribe.recipient_emails_placeholder")
|
||||
div
|
||||
button.recipients-subscribe-button.btn.btn-lg.btn-success(data-i18n="subscribe.subscribe_users")
|
||||
if recipientSubs.state === 'declined'
|
||||
if view.recipientSubs.state === 'declined'
|
||||
br
|
||||
.alert.alert-danger.alert-dismissible
|
||||
span(data-i18n="buy_gems.declined")
|
||||
button.close(type="button" data-dismiss="alert")
|
||||
span(aria-hidden="true") ×
|
||||
else if recipientSubs.state === 'unknown_error'
|
||||
else if view.recipientSubs.state === 'unknown_error'
|
||||
br
|
||||
.alert.alert-danger.alert-dismissible
|
||||
button.close(type="button" data-dismiss="alert")
|
||||
span(aria-hidden="true") ×
|
||||
p(data-i18n="loading_error.unknown")
|
||||
p= recipientSubs.stateMessage
|
||||
else if recipientSubs.justSubscribed && recipientSubs.justSubscribed.length > 0
|
||||
p= view.recipientSubs.stateMessage
|
||||
else if view.recipientSubs.justSubscribed && view.recipientSubs.justSubscribed.length > 0
|
||||
br
|
||||
.alert.alert-success.alert-dismissible
|
||||
if recipientSubs.justSubscribed.length > 0
|
||||
if view.recipientSubs.justSubscribed.length > 0
|
||||
div(data-i18n="subscribe.users_subscribed")
|
||||
ul
|
||||
each email in recipientSubs.justSubscribed
|
||||
each email in view.recipientSubs.justSubscribed
|
||||
li= email
|
||||
else if recipientSubs.justSubscribed && recipientSubs.justSubscribed.length === 0
|
||||
else if view.recipientSubs.justSubscribed && view.recipientSubs.justSubscribed.length === 0
|
||||
br
|
||||
.alert.alert-success.alert-dismissible
|
||||
div(data-i18n="subscribe.no_users_subscribed")
|
||||
|
||||
if recipientSubs.nextPaymentAmount > 0 && recipientSubs.sponsorSub
|
||||
if view.recipientSubs.nextPaymentAmount > 0 && view.recipientSubs.sponsorSub
|
||||
h4(data-i18n="account.next_payment")
|
||||
p= moment(new Date(recipientSubs.sponsorSub.current_period_end * 1000)).format('l')
|
||||
p $#{recipientSubs.nextPaymentAmount / 100}
|
||||
p= recipientSubs.card
|
||||
p= moment(new Date(view.recipientSubs.sponsorSub.current_period_end * 1000)).format('l')
|
||||
p $#{view.recipientSubs.nextPaymentAmount / 100}
|
||||
p= view.recipientSubs.card
|
||||
|
||||
h4(data-i18n="subscribe.current_recipients")
|
||||
if recipientSubs.unsubscribingRecipients && recipientSubs.unsubscribingRecipients.length > 0
|
||||
if view.recipientSubs.unsubscribingRecipients && view.recipientSubs.unsubscribingRecipients.length > 0
|
||||
.alert.alert-info
|
||||
span.spr(data-i18n="subscribe.unsubscribing")
|
||||
span= recipientSubs.unsubscribingRecipients[0]
|
||||
span= view.recipientSubs.unsubscribingRecipients[0]
|
||||
else
|
||||
table.table.table-striped.table-condensed.recipients-table
|
||||
tr
|
||||
th(data-i18n="general.email")
|
||||
th(data-i18n="general.name")
|
||||
th
|
||||
for recipient in recipientSubs.recipients
|
||||
for recipient in view.recipientSubs.recipients
|
||||
tr
|
||||
td.recipient-email= recipient.emailLower
|
||||
td.recipient-name= recipient.name
|
||||
|
|
|
@ -52,12 +52,6 @@ module.exports = class SubscriptionView extends RootView
|
|||
@personalSub.update => @render?()
|
||||
@recipientSubs.update => @render?()
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
c.personalSub = @personalSub
|
||||
c.recipientSubs = @recipientSubs
|
||||
c
|
||||
|
||||
# Personal Subscriptions
|
||||
|
||||
onClickStartSubscription: (e) ->
|
||||
|
|
Loading…
Reference in a new issue