     options.itemClass or= AccountSubscriptionsListItem
 
     super options, data
-
 
 class AccountSubscriptionsListItem extends KDListItemView
 

      iconClass : 'refresh'
      callback  : @getListView().emit.bind @getListView(), 'Reload'


class AccountSubscriptionsList extends KDListView

  constructor:(options={}, data)->


    @subscription = new SubscriptionView {}, @getData()

    @controls = new SubscriptionControls {}, @getData()

    @forwardEvents @controls, [
      'PlanChangeRequested'
      'UnsubscribeRequested'
      'ReactivateRequested'
    ]

  viewAppended: JView::viewAppended

  pistachio:->
    """
    <div class='payment-details'>
      {{> @subscription}}
      {{> @controls}}
    </div>
    """

class SubscriptionControls extends JView

  getStatusInfo: (subscription = @getData()) ->
    switch subscription.status
      when 'active'
        text        : 'unsubscribe'
        event       : 'UnsubscribeRequested'
        showChange  : yes
      when 'canceled', 'expired'
        text        : 'reactivate'
        event       : 'ReactivateRequested'
        showChange  : no

  viewAppended: ->
    @unsetClass 'kdview'
    @setClass 'controls'

    { text, event, showChange } = @getStatusInfo()

    if showChange
      @changeLink = new CustomLinkView
        title     : 'change plan'
        click     : (e) =>
          e.preventDefault()
          @emit 'PlanChangeRequested'
      @addSubView @changeLink
      @setPartial ' | '

    @statusLink = new CustomLinkView
      title     : text
      click     : (e) =>
        e.preventDefault()
        @emit event
    @addSubView @statusLink
