| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- import React from 'react'
- import LazyLoad from 'react-lazyload'
- import cls from 'classnames'
- import Block from './base/Block'
- import BlockChildren from './base/BlockChildren'
- import BlockOrder from './base/BlockOrder'
- import BlockDel from './base/BlockDel'
- import BlockDescWrap from './base/group/BlockDescWrap'
- import BlockEnable from './base/BlockEnable'
- export default class BlockGroup extends Block {
- constructor(props) {
- super(props)
- }
- render() {
- let jengaContent = document.getElementsByClassName('jenga-content')[0]
- let getRelChildComs = () => {
- return this.state.hasChildren ? (
- <div className="f--h">
- <div
- className={cls(
- 'btn-clear btn-toggle-sub btn-toggle-sub-empty',
- 'btn-toggle-sub-empty-' + this.getLineColor(),
- 'btn-toggle-sub-empty-small'
- )}
- style={{ marginTop: '9px' }}
- />
- <button
- className={cls('btn-clear btn-toggle-sub btn-toggle-group f--hcc')}
- onClick={this.onToggleBlockExpand}
- >
- <div className={cls('icon', { collpase: !this.state.isExpand })} />
- </button>
- </div>
- ) : (
- <div
- className={cls(
- 'btn-clear btn-toggle-sub btn-toggle-sub-empty',
- 'btn-toggle-sub-empty-' + this.getLineColor()
- )}
- />
- )
- }
- let extraLineCom = () => {
- return (
- this.state.isExpand &&
- this.state.hasChildren && (
- <div
- style={{
- left: -this.getGapLeft() + 'px',
- marginLeft: this.getGapLeft() - 1 + 'px'
- }}
- className={cls(
- 'index-line',
- 'index-extra-children',
- 'index-line-' + this.getLineColor()
- )}
- />
- )
- )
- }
- return (
- <LazyLoad height={26} overflow={true} scrollContainer={jengaContent}>
- <div
- className={cls(
- 'block-wrap block-wrap-group f--h',
- `block-wrap-group-${this.getGroupColor()}`
- )}
- >
- <span
- className={cls('index-line', 'index-line-' + this.getLineColor(), {
- 'index-last-line': this.props.isLast,
- 'index-virtual-layer': this.props.virtualLayer
- })}
- style={this.indexLeftStyle()}
- />
- <div
- className={cls('flex-1 block-wrapper-inner', {
- 'flex-wrap-disabled': !this.state.isEnable
- })}
- >
- <div
- className={cls('block-item block-group f--h', {
- 'block-active': this.state.isActive
- })}
- // onDragOver={this.onDragOver}
- // onDrop={this.onDrop}
- onClick={this.onSelectBlock}
- onContextMenu={this.onContextMenu}
- >
- <BlockDel
- isActive={this.state.isActive}
- layer={this.props.layer}
- bid={this.props.bid}
- />
- <BlockOrder
- layer={this.props.layer}
- bid={this.props.bid}
- eventNodeId={this.props.eventNodeId}
- extraGapGroupLayer={this.extraGapGroupLayer()}
- />
- <div
- className="block-gap"
- style={{
- left: -this.getGapLeft() + 'px',
- padding: '0 ' + this.getGapLeft() / 2 + 'px'
- }}
- />
- {extraLineCom()}
- {getRelChildComs()}
- <div
- id={'block-main-' + this.props.bid}
- className="block-main flex-1 f--h"
- style={this.blockMainStyle()}
- draggable={true}
- onDragStart={this.onDragStart}
- onDragEnd={this.onDragEnd}
- >
- <div
- id={'over-cover-' + this.props.bid}
- className="over-cover"
- />
- <BlockEnable
- className="btn-toggle-con-enable"
- bid={this.props.bid}
- isEnable={this.state.isEnable}
- eventNodeId={this.props.eventNodeId}
- />
- <BlockDescWrap
- bid={this.props.bid}
- hasGroupExtraLine={
- this.props.groupLayer === 0 && this.state.hasChildren
- }
- />
- </div>
- </div>
- {/*group 不需要设置layer+1*/}
- {this.state.isExpand ? (
- <BlockChildren
- loops={this.getLoops()}
- layer={this.props.layer}
- groupLayer={this.props.groupLayer + 1}
- nestGroupLayer={this.props.nestGroupLayer + 1}
- offspringInNestGroupLayer={this.props.nestGroupLayer + 1}
- extraGapGroupLayer={this.extraGapGroupLayer()}
- parentBid={this.props.bid}
- eventNodeId={this.props.eventNodeId}
- visibleBlockIds={this.props.visibleBlockIds}
- virtualLayer={this.props.layer}
- />
- ) : null}
- </div>
- </div>
- </LazyLoad>
- )
- }
- }
|