Code coverage report for code/views/document-actions-view.coffee

Statements: 0% (0 / 28)      Branches: 0% (0 / 6)      Functions: 0% (0 / 8)      Lines: 0% (0 / 18)      Ignored: none     

All files » code/views/ » document-actions-view.coffee
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49                                                                                                 
{div, span, i, br} = React.DOM
 
CodapStore = require "../stores/codap-store"
tr         = require '../utils/translate'
 
module.exports = React.createClass
 
  mixins: [ CodapStore.mixin ]
 
  displayName: 'DocumentActions'
 
  getInitialState: ->
    canRedo: false
    canUndo: false
 
  componentDidMount: ->
    @props.graphStore.addChangeListener @modelChanged
 
  modelChanged: (status) ->
    @setState
      canRedo: status.canRedo
      canUndo: status.canUndo
 
  undoClicked: ->
    @props.graphStore.undo()
 
  redoClicked: ->
    @props.graphStore.redo()
 
  renderRunLink: ->
    if @state.codapHasLoaded and not @props.simplified
      (span {},
        (i {className: "fa fa-play-circle", onClick: @props.runSimulation})
        tr "~DOCUMENT.ACTIONS.RUN_SIMULATION"
      )
 
  render: ->
    buttonClass = (enabled) -> "button-link #{if not enabled then 'disabled' else ''}"
    (div {className: 'document-actions'},
      (div {className: "misc-actions"},
        @renderRunLink()
      )
      unless @state.hideUndoRedo
        (div {className: 'undo-redo'},
          (span {className: (buttonClass @state.canUndo), onClick: @undoClicked, disabled: not @state.canUndo}, tr "~DOCUMENT.ACTIONS.UNDO")
          (span {className: (buttonClass @state.canRedo), onClick: @redoClicked, disabled: not @state.canRedo}, tr "~DOCUMENT.ACTIONS.REDO")
        )
    )