Sha256: 32edef1566d8f17b4bb496e734034a12744eb64bfadc83290d5f03cde7b8385c

Contents?: true

Size: 1.21 KB

Versions: 11

Compression:

Stored size: 1.21 KB

Contents

# @cjsx React.DOM 
React = require('react')
Card = require('./card')
Message = require('./message')

module.exports = React.createClass
  displayName: 'Cards'

  getInitialState: ()->
    error: false

  componentDidMount: ()->
    console.log '[views/cards] component did mount'
    @props.cards.on 'sync', @forceUpdate.bind(@, null)
    if @props.card
      @props.card.on 'error', (model, response)=>
        @setState error: response
        @forceUpdate.bind(@, null)

  componentWillReceiveProps: (nextProps)->
    console.log '[views/cards] component will receive props'
    nextProps.cards.on 'sync', @forceUpdate.bind(@, null)
    if nextProps.card
      nextProps.card.on 'error', (model, response)=>
        @setState error: response
        @forceUpdate.bind(@, null)

  render: ->
    if @props.cards.fetching
      <Message>
        <i className='glyphicon glyphicon-refresh glyphicon-refresh-animate' /> Loading ...
      </Message>
    else if @state.error
      <Message>
        <i className='glyphicon glyphicon-alert' /> {@state.error.status} {@state.error.statusText}
      </Message>
    else
      cards = @props.cards.map (card)-> <Card key={card.get("title")} card={card} />
      <div className='row'>{cards}</div>

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
carte-server-1.0.7 lib/carte/client/views/cards.cjsx
carte-server-1.0.6 lib/carte/client/views/cards.cjsx
carte-server-1.0.5 lib/carte/client/views/cards.cjsx
carte-server-1.0.4 lib/carte/client/views/cards.cjsx
carte-server-1.0.3 lib/carte/client/views/cards.cjsx
carte-server-1.0.2 lib/carte/client/views/cards.cjsx
carte-server-1.0.1 lib/carte/client/views/cards.cjsx
carte-server-1.0.0 lib/carte/client/views/cards.cjsx
carte-server-0.0.28 lib/carte/client/views/cards.cjsx
carte-server-0.0.27 lib/carte/client/views/cards.cjsx
carte-server-0.0.26 lib/carte/client/views/cards.cjsx