ElementGroup.js 1.23 KB
import React from 'react'
import Element from './Element'
import ReactAddonsUpdate from 'react-addons-update'
import autobind from 'autobind-decorator'
import { connect } from 'react-redux'

import { bindActionCreators } from 'redux'
import * as HeaderGroupActions from '../actions/headergroup'

@autobind
class ElementGroup extends React.Component {
  sidebar() {
    return document.getElementById('sidebar')
  }

  render() {
    const { elements, actions } = this.props
    return (
      <div>
        {
          elements.map(function(element) {
            return (
              <Element meta_element={ element } key={ "key_" + element.id } id={ element.id } name={ element.name } initialPos={ element.initialPos } target_type={ element.target_type } handleCloneElement={ actions.cloneElement } handleDeleteElement={ actions.deleteElement } handleDeleteLastElement={ actions.deleteLastElement } />
            )
          }.bind(this))
        }
      </div>
    )
  }
}

const mapStateToProps = (state, ownProps) => ({
  elements: state.headergroup
})

const mapDispatchToProps = (dispatch, ownProps) => ({
  actions: bindActionCreators(HeaderGroupActions, dispatch)
})

export default connect(
  mapStateToProps,
  mapDispatchToProps
)(ElementGroup)