Sha256: 937c2b632cda35739754c15064fa9ac6c03833e15f1fbb18ed1e6dfbc1bfcca8

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 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 '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 'component did mount'
    nextProps.cards.on 'sync', @forceUpdate.bind(@, null)
    if nextProps.card
      nextProps.card.on 'error', (model, response)=>
        @setState error: response
        @forceUpdate.bind(@, null)

  render: ->
    console.log 'render cards', @props.cards, @state
    if @props.cards.fetching
      console.log 'cards loading'
      <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
      console.log 'cards loaded'
      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-0.0.25 lib/carte/client/views/cards.cjsx
carte-server-0.0.24 lib/carte/client/views/cards.cjsx
carte-server-0.0.23 lib/carte/client/views/cards.cjsx
carte-server-0.0.22 lib/carte/client/views/cards.cjsx
carte-server-0.0.21 lib/carte/client/views/cards.cjsx
carte-server-0.0.20 lib/carte/client/views/cards.cjsx
carte-server-0.0.19 lib/carte/client/views/cards.cjsx
carte-server-0.0.18 lib/carte/client/views/cards.cjsx
carte-server-0.0.17 lib/carte/client/views/cards.cjsx
carte-server-0.0.16 lib/carte/client/views/cards.cjsx
carte-server-0.0.15 lib/carte/client/views/cards.cjsx