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