/**
* @author oldj
* @blog https://oldj.net
*/
'use strict'
import React from 'react'
import classnames from 'classnames'
import Sortable from 'sortablejs'
import listToArray from 'wheel-js/src/common/list-to-array'
import './group.less'
export default class Group extends React.Component {
constructor (props) {
super(props)
this.state = {
list: this.props.hosts.list
}
this.current_host = null
}
makeItem (item) {
let attrs = {
'data-id': 'id:' + (item.id || '')
}
return (
{item.title}
)
}
makeList () {
let items = this.state.list
.filter(item => item.where !== 'group')
.map(item => this.makeItem(item))
return (
)
}
currentList () {
return (
)
}
getCurrentListFromDOM () {
let nodes = this.refs.group_current.getElementsByClassName('hosts-item')
nodes = listToArray(nodes)
console.log(nodes)
}
componentDidMount () {
Sortable.create(this.refs.group_valid, {
group: 'sorting'
, sort: false
})
Sortable.create(this.refs.group_current, {
group: 'sorting'
, sort: true
, onSort: evt => {
this.getCurrentListFromDOM()
}
})
}
render () {
return (
{this.makeList()}
{this.currentList()}
)
}
}