|
@@ -4,33 +4,26 @@ import i18n from 'i18next'
|
|
|
import cls from 'classnames'
|
|
import cls from 'classnames'
|
|
|
import newEventActions from 'actions/newEvent'
|
|
import newEventActions from 'actions/newEvent'
|
|
|
import newEventStores from 'stores/newEvent'
|
|
import newEventStores from 'stores/newEvent'
|
|
|
-// import {
|
|
|
|
|
-// getActionBlockObjNode,
|
|
|
|
|
-// getEventBlockByBid,
|
|
|
|
|
-// getEventNodeById
|
|
|
|
|
-// } from 'stores/funcs/newEvent'
|
|
|
|
|
-// import {
|
|
|
|
|
-// nodeIsDbPayment,
|
|
|
|
|
-// nodeIsFunctionGroup,
|
|
|
|
|
-// nodeIsService,
|
|
|
|
|
-// nodeIsIotMessage,
|
|
|
|
|
-// nodeIsFuncGroupCb,
|
|
|
|
|
-// nodeIsMq
|
|
|
|
|
-// } from 'stores/funcs/nodeType'
|
|
|
|
|
-import { EVENT_BLOCK_TYPE } from 'const/const'
|
|
|
|
|
|
|
+import { getEventBlockByBid, getEventNodeById } from 'stores/funcs/newEvent'
|
|
|
|
|
+import {
|
|
|
|
|
+ nodeIsDbPayment,
|
|
|
|
|
+ nodeIsFunctionGroup,
|
|
|
|
|
+ nodeIsService,
|
|
|
|
|
+ nodeIsIotMessage
|
|
|
|
|
+} from 'stores/funcs/nodeType'
|
|
|
|
|
+import { EVENT_BLOCK_TYPE, BLOCK_OP_TYPE } from 'const/const'
|
|
|
|
|
|
|
|
export default class JengaTypeBlockOperator extends React.Component {
|
|
export default class JengaTypeBlockOperator extends React.Component {
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props)
|
|
super(props)
|
|
|
|
|
+ this.curEventNodeId = newEventStores.curEventNodeId
|
|
|
|
|
+ this.curBlockId = newEventStores.curBlockId
|
|
|
this.state = {
|
|
this.state = {
|
|
|
showComment: newEventStores.showComment, // 显示备注条
|
|
showComment: newEventStores.showComment, // 显示备注条
|
|
|
- type: 'child' // 子层,同层
|
|
|
|
|
- // enables: this.genEnableMap('child') // 分别对应循环,动作,条件
|
|
|
|
|
|
|
+ type: 'child', // 子层,同层
|
|
|
|
|
+ enables: this.genEnableMap('child') // 分别对应循环,动作,条件,备注,分组
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this.curEventNodeId = newEventStores.curEventNodeId
|
|
|
|
|
- this.curBlockId = newEventStores.curBlockId
|
|
|
|
|
-
|
|
|
|
|
this.buttons = [
|
|
this.buttons = [
|
|
|
{
|
|
{
|
|
|
type: EVENT_BLOCK_TYPE.LOOP,
|
|
type: EVENT_BLOCK_TYPE.LOOP,
|
|
@@ -51,6 +44,11 @@ export default class JengaTypeBlockOperator extends React.Component {
|
|
|
type: EVENT_BLOCK_TYPE.COMMENT,
|
|
type: EVENT_BLOCK_TYPE.COMMENT,
|
|
|
class: 'btn-comment',
|
|
class: 'btn-comment',
|
|
|
name: i18n.t('EventView.jenga_nav.memo')
|
|
name: i18n.t('EventView.jenga_nav.memo')
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ type: EVENT_BLOCK_TYPE.GROUP,
|
|
|
|
|
+ class: 'btn-group',
|
|
|
|
|
+ name: i18n.t('EventView.jenga_nav.group')
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
|
|
|
|
@@ -59,9 +57,7 @@ export default class JengaTypeBlockOperator extends React.Component {
|
|
|
this.onChangeType = this.onChangeType.bind(this)
|
|
this.onChangeType = this.onChangeType.bind(this)
|
|
|
this.isSelectedType = this.isSelectedType.bind(this)
|
|
this.isSelectedType = this.isSelectedType.bind(this)
|
|
|
this.onChangeShowComment = this.onChangeShowComment.bind(this)
|
|
this.onChangeShowComment = this.onChangeShowComment.bind(this)
|
|
|
- // this.genEnableMap = this.genEnableMap.bind(this)
|
|
|
|
|
- // this.dealEnableMap = this.dealEnableMap.bind(this)
|
|
|
|
|
- // this.dealStatusEnable = this.dealStatusEnable.bind(this)
|
|
|
|
|
|
|
+ this.genEnableMap = this.genEnableMap.bind(this)
|
|
|
|
|
|
|
|
this.onAddBlock = this.onAddBlock.bind(this)
|
|
this.onAddBlock = this.onAddBlock.bind(this)
|
|
|
}
|
|
}
|
|
@@ -88,13 +84,6 @@ export default class JengaTypeBlockOperator extends React.Component {
|
|
|
obj.enables = this.genEnableMap(this.state.type)
|
|
obj.enables = this.genEnableMap(this.state.type)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (
|
|
|
|
|
- status.types.includes('updateBlockProp') &&
|
|
|
|
|
- ['object', 'action'].indexOf(status.data.prop) >= 0 &&
|
|
|
|
|
- this.curBlockId === status.data.affectBlockId
|
|
|
|
|
- ) {
|
|
|
|
|
- obj.enables = this.genEnableMap(this.state.type)
|
|
|
|
|
- }
|
|
|
|
|
if (status.types.includes('changeShowComment')) {
|
|
if (status.types.includes('changeShowComment')) {
|
|
|
let { showComment } = this.state
|
|
let { showComment } = this.state
|
|
|
if (showComment !== status.data.showComment) {
|
|
if (showComment !== status.data.showComment) {
|
|
@@ -117,7 +106,7 @@ export default class JengaTypeBlockOperator extends React.Component {
|
|
|
break
|
|
break
|
|
|
}
|
|
}
|
|
|
this.setState(obj, () => {
|
|
this.setState(obj, () => {
|
|
|
- // this.setState({ enables: this.genEnableMap(this.state.type) })
|
|
|
|
|
|
|
+ this.setState({ enables: this.genEnableMap(this.state.type) })
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -138,119 +127,57 @@ export default class JengaTypeBlockOperator extends React.Component {
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // genEnableMap(type) {
|
|
|
|
|
- // let result = {}
|
|
|
|
|
- // let curBlock = getEventBlockByBid(this.curBlockId)
|
|
|
|
|
- // if (!curBlock) {
|
|
|
|
|
- // return this.dealEnableMap()
|
|
|
|
|
- // } else {
|
|
|
|
|
- // switch (type) {
|
|
|
|
|
- // case 'bro':
|
|
|
|
|
- // let parentBid = curBlock.parentBid
|
|
|
|
|
- // let parentBlock = getEventBlockByBid(parentBid)
|
|
|
|
|
- // return this.dealEnableMap(parentBlock)
|
|
|
|
|
- // case 'child':
|
|
|
|
|
- // return this.dealEnableMap(curBlock)
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // return result
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // dealEnableMap(block) {
|
|
|
|
|
- // let curEventNode = getEventNodeById(this.curEventNodeId)
|
|
|
|
|
- // let result = {}
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.ACTION] = false
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.LOOP] = false
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.CON] = false
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.STATUS] = false
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.ROOT] =
|
|
|
|
|
- // curEventNode &&
|
|
|
|
|
- // (!nodeIsService(curEventNode.type) ||
|
|
|
|
|
- // (nodeIsService(curEventNode.type) &&
|
|
|
|
|
- // nodeIsIotMessage(curEventNode.type))) &&
|
|
|
|
|
- // !nodeIsFunctionGroup(curEventNode.type) &&
|
|
|
|
|
- // !nodeIsDbPayment(curEventNode.type) &&
|
|
|
|
|
- // !nodeIsMq(curEventNode.type)
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.COMMENT] = false
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.GROUP] = false
|
|
|
|
|
- // if (block) {
|
|
|
|
|
- // switch (block.type) {
|
|
|
|
|
- // case EVENT_BLOCK_TYPE.ACTION:
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.ACTION] = false
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.LOOP] = false
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.CON] = false
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.STATUS] = this.dealStatusEnable(block)
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.COMMENT] = false
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.GROUP] = false
|
|
|
|
|
- // break
|
|
|
|
|
- // case EVENT_BLOCK_TYPE.ROOT:
|
|
|
|
|
- // case EVENT_BLOCK_TYPE.LOOP:
|
|
|
|
|
- // case EVENT_BLOCK_TYPE.CON:
|
|
|
|
|
- // case EVENT_BLOCK_TYPE.STATUS:
|
|
|
|
|
- // case EVENT_BLOCK_TYPE.GROUP:
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.ACTION] = true
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.LOOP] = true
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.CON] = true
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.STATUS] = false
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.COMMENT] = true
|
|
|
|
|
- // result[EVENT_BLOCK_TYPE.GROUP] = true
|
|
|
|
|
- // break
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // return result
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- // dealStatusEnable(block) {
|
|
|
|
|
- // let result = false
|
|
|
|
|
- // if (block.action && block.action.callback) {
|
|
|
|
|
- // // 当前的动作
|
|
|
|
|
- // let obj = getActionBlockObjNode({
|
|
|
|
|
- // obj: block.object,
|
|
|
|
|
- // blockId: block.bid
|
|
|
|
|
- // })
|
|
|
|
|
- // if (obj && nodeIsFunctionGroup(obj.type)) {
|
|
|
|
|
- // // 是否action是调用动作且此对象的事件有回调函数
|
|
|
|
|
- // if (
|
|
|
|
|
- // block.action.name === 'fireFuncGroup' &&
|
|
|
|
|
- // obj &&
|
|
|
|
|
- // obj.events &&
|
|
|
|
|
- // obj.events.list &&
|
|
|
|
|
- // obj.events.list.length > 0 &&
|
|
|
|
|
- // obj.events.order &&
|
|
|
|
|
- // obj.events.order.length > 0
|
|
|
|
|
- // ) {
|
|
|
|
|
- // let found = false
|
|
|
|
|
- // for (let i = 0; i < obj.events.order.length && !found; i++) {
|
|
|
|
|
- // let _block = getEventBlockByBid(obj.events.order[i])
|
|
|
|
|
- // if (
|
|
|
|
|
- // _block &&
|
|
|
|
|
- // _block.type === EVENT_BLOCK_TYPE.ACTION &&
|
|
|
|
|
- // _block.enable !== false &&
|
|
|
|
|
- // _block.action &&
|
|
|
|
|
- // _block.action.name === 'funcResult'
|
|
|
|
|
- // ) {
|
|
|
|
|
- // found = true
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // if (found) {
|
|
|
|
|
- // result = true
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // // 有自定义回调也算
|
|
|
|
|
- // if (!result && obj.children) {
|
|
|
|
|
- // obj.children.forEach(v => {
|
|
|
|
|
- // let childNode = getEventNodeById(v)
|
|
|
|
|
- // if (childNode && nodeIsFuncGroupCb(childNode.type)) {
|
|
|
|
|
- // result = true
|
|
|
|
|
- // }
|
|
|
|
|
- // })
|
|
|
|
|
- // }
|
|
|
|
|
- // } else {
|
|
|
|
|
- // result = true
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // return result
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ genEnableMap(type) {
|
|
|
|
|
+ let curEventNode = getEventNodeById(this.curEventNodeId)
|
|
|
|
|
+ let result = {}
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.ACTION] = false
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.LOOP] = false
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.CON] = false
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.ROOT] =
|
|
|
|
|
+ curEventNode &&
|
|
|
|
|
+ (!nodeIsService(curEventNode.type) ||
|
|
|
|
|
+ (nodeIsService(curEventNode.type) &&
|
|
|
|
|
+ nodeIsIotMessage(curEventNode.type))) &&
|
|
|
|
|
+ !nodeIsFunctionGroup(curEventNode.type) &&
|
|
|
|
|
+ !nodeIsDbPayment(curEventNode.type)
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.COMMENT] = false
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.GROUP] = false
|
|
|
|
|
+ if (this.curBlockId) {
|
|
|
|
|
+ let curBlock = getEventBlockByBid(this.curBlockId, this.curEventNodeId)
|
|
|
|
|
+ if (curBlock) {
|
|
|
|
|
+ switch (type) {
|
|
|
|
|
+ case 'bro':
|
|
|
|
|
+ if (!curBlock.eventId) {
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.ACTION] = true
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.LOOP] = true
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.CON] = true
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.COMMENT] = true
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.GROUP] = true
|
|
|
|
|
+ }
|
|
|
|
|
+ break
|
|
|
|
|
+ case 'child':
|
|
|
|
|
+ if (
|
|
|
|
|
+ curBlock.eventId ||
|
|
|
|
|
+ [
|
|
|
|
|
+ BLOCK_OP_TYPE.FOR,
|
|
|
|
|
+ BLOCK_OP_TYPE.WHILE,
|
|
|
|
|
+ BLOCK_OP_TYPE.IF,
|
|
|
|
|
+ BLOCK_OP_TYPE.ELSE,
|
|
|
|
|
+ BLOCK_OP_TYPE.BLOCK
|
|
|
|
|
+ ].indexOf(curBlock.op) >= 0
|
|
|
|
|
+ ) {
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.ACTION] = true
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.LOOP] = true
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.CON] = true
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.COMMENT] = true
|
|
|
|
|
+ result[EVENT_BLOCK_TYPE.GROUP] = true
|
|
|
|
|
+ }
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return result
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
onAddBlock(type) {
|
|
onAddBlock(type) {
|
|
|
// if (type !== EVENT_BLOCK_TYPE.ROOT) {
|
|
// if (type !== EVENT_BLOCK_TYPE.ROOT) {
|
|
@@ -322,7 +249,7 @@ export default class JengaTypeBlockOperator extends React.Component {
|
|
|
return (
|
|
return (
|
|
|
<button
|
|
<button
|
|
|
key={i}
|
|
key={i}
|
|
|
- // disabled={!this.state.enables[btn.type]}
|
|
|
|
|
|
|
+ disabled={!this.state.enables[btn.type]}
|
|
|
onClick={this.onAddBlock.bind(this, btn.type)}
|
|
onClick={this.onAddBlock.bind(this, btn.type)}
|
|
|
className={cls('btn-clear btn-block', btn.class)}
|
|
className={cls('btn-clear btn-block', btn.class)}
|
|
|
>
|
|
>
|
|
@@ -332,7 +259,7 @@ export default class JengaTypeBlockOperator extends React.Component {
|
|
|
})}
|
|
})}
|
|
|
<button
|
|
<button
|
|
|
className="btn-clear btn-block btn-event f--hlc"
|
|
className="btn-clear btn-block btn-event f--hlc"
|
|
|
- // disabled={!this.state.enables[EVENT_BLOCK_TYPE.ROOT]}
|
|
|
|
|
|
|
+ disabled={!this.state.enables[EVENT_BLOCK_TYPE.ROOT]}
|
|
|
onClick={this.onAddBlock.bind(this, EVENT_BLOCK_TYPE.ROOT)}
|
|
onClick={this.onAddBlock.bind(this, EVENT_BLOCK_TYPE.ROOT)}
|
|
|
>
|
|
>
|
|
|
<div>{i18n.t('EventView.jenga_nav.event')}</div>
|
|
<div>{i18n.t('EventView.jenga_nav.event')}</div>
|