Commit 78d169e0 authored by homiexie's avatar homiexie
Browse files

#1640 enhance for graph and plugin regist

parent 8861dda7
Showing with 90 additions and 45 deletions
+90 -45
......@@ -164,14 +164,22 @@
</Col>
<Col span="10" offset="0">
<FormItem :label-width="0">
<PathExp
<!-- <PathExp
v-if="param.mappingType === 'entity'"
:rootPkg="pkgName"
:rootEntity="rootEntity"
:allDataModelsWithAttrs="allEntityType"
:disabled="currentPluginObj.status === 'ENABLED'"
v-model="param.mappingEntityExpression"
></PathExp>
></PathExp> -->
<FilterRules
v-if="param.mappingType === 'entity'"
v-model="param.mappingEntityExpression"
:disabled="currentPluginObj.status === 'ENABLED'"
:allDataModelsWithAttrs="allEntityType"
:needNativeAttr="true"
:needAttr="true"
></FilterRules>
<Select
v-if="param.mappingType === 'system_variable'"
v-model="param.mappingSystemVariableName"
......@@ -249,14 +257,22 @@
</Col>
<Col span="10" offset="0">
<FormItem :label-width="0">
<PathExp
<!-- <PathExp
v-if="outPut.mappingType === 'entity'"
:rootPkg="pkgName"
:rootEntity="rootEntity"
:allDataModelsWithAttrs="allEntityType"
:disabled="currentPluginObj.status === 'ENABLED'"
v-model="outPut.mappingEntityExpression"
></PathExp>
></PathExp> -->
<FilterRules
v-if="outPut.mappingType === 'entity'"
v-model="outPut.mappingEntityExpression"
:disabled="currentPluginObj.status === 'ENABLED'"
:allDataModelsWithAttrs="allEntityType"
:needNativeAttr="true"
:needAttr="true"
></FilterRules>
<span v-if="outPut.mappingType === 'context'">N/A</span>
</FormItem>
</Col>
......
......@@ -48,7 +48,7 @@
</ul>
<hr />
<div style="max-height: 145px;overflow: auto;">
<ul v-for="opt in currentLeafOptiongs" :key="opt.pathExp + Math.random() * 1000">
<ul v-if="!needNativeAttr" v-for="opt in currentLeafOptiongs" :key="opt.pathExp + Math.random() * 1000">
<li style="color:rgb(49, 104, 4)" @click="optClickHandler(opt)">{{ opt.pathExp }}</li>
</ul>
<ul v-for="opt in currentRefOptiongs" :key="opt.pathExp + Math.random() * 1000">
......@@ -127,13 +127,16 @@ export default {
type: Boolean,
default: false
},
needNativeAttr: {
type: Boolean,
default: false
},
disabled: {},
allDataModelsWithAttrs: {}
},
watch: {
value: {
handler (val) {
console.log(val)
// if (val === this.fullPathExp) return
this.formatFirstCurrentOptions()
}
......@@ -254,7 +257,7 @@ export default {
this.formatNextCurrentOptions(opt)
this.currentNodeIndex++
this.currentNode = opt
this.poptipVisable = this.needAttr
this.poptipVisable = this.needAttr || this.needNativeAttr
},
async attrChangeHandler (v, rule) {
const found = this.currentNodeEntityAttrs.find(_ => _.name === v)
......@@ -389,7 +392,7 @@ export default {
this.formatCurrentOptions()
return
}
if (opt.nodeType === 'leaf' || !this.needAttr) {
if (opt.nodeType === 'leaf' || !this.needAttr || opt.nodeType === 'attr') {
this.currentOptiongs = []
this.currentRefOptiongs = []
this.currentLeafOptiongs = []
......@@ -413,42 +416,57 @@ export default {
}
})
this.currentLeafOptiongs = []
let referenceToEntityList = []
data.leafEntityList.referenceToEntityList.forEach(e => {
const index = referenceToEntityList.indexOf(e.filterRule)
if (index < 0) {
const found = data.referenceToEntityList.filter(
_ => `${_.packageName}:${_.name}` === `${e.packageName}:${e.entityName}`
)
found.forEach(j => {
this.currentLeafOptiongs.push({
pkg: e.packageName,
entity: e.name,
pathExp: `.${j.relatedAttribute.name}>${e.filterRule}`,
nodeType: 'entity'
})
if (this.needNativeAttr) {
const foundEntity = this.allEntity.find(i => i.packageName === opt.pkg && i.name === opt.entity)
const attrOption = foundEntity.attributes
.filter(attr => attr.dataType !== 'ref')
.map(a => {
return {
pkg: a.packageName,
entity: a.entityName,
pathExp: `.${a.name}`,
nodeType: 'attr'
}
})
referenceToEntityList.push(e.filterRule)
}
})
let referenceByEntityList = []
data.leafEntityList.referenceByEntityList.forEach(e => {
const index = referenceByEntityList.indexOf(e.filterRule)
if (index < 0) {
const found = data.referenceByEntityList.filter(
_ => `${_.packageName}:${_.name}` === `${e.packageName}:${e.entityName}`
)
found.forEach(j => {
this.currentLeafOptiongs.push({
pkg: e.packageName,
entity: e.name,
pathExp: `~(${j.relatedAttribute.name})${e.filterRule}`,
nodeType: 'leaf'
this.currentOptiongs = this.currentOptiongs.concat(attrOption)
} else {
let referenceToEntityList = []
data.leafEntityList.referenceToEntityList.forEach(e => {
const index = referenceToEntityList.indexOf(e.filterRule)
if (index < 0) {
const found = data.referenceToEntityList.filter(
_ => `${_.packageName}:${_.name}` === `${e.packageName}:${e.entityName}`
)
found.forEach(j => {
this.currentLeafOptiongs.push({
pkg: e.packageName,
entity: e.name,
pathExp: `.${j.relatedAttribute.name}>${e.filterRule}`,
nodeType: 'entity'
})
})
})
referenceByEntityList.push(e.filterRule)
}
})
referenceToEntityList.push(e.filterRule)
}
})
let referenceByEntityList = []
data.leafEntityList.referenceByEntityList.forEach(e => {
const index = referenceByEntityList.indexOf(e.filterRule)
if (index < 0) {
const found = data.referenceByEntityList.filter(
_ => `${_.packageName}:${_.name}` === `${e.packageName}:${e.entityName}`
)
found.forEach(j => {
this.currentLeafOptiongs.push({
pkg: e.packageName,
entity: e.name,
pathExp: `~(${j.relatedAttribute.name})${e.filterRule}`,
nodeType: 'leaf'
})
})
referenceByEntityList.push(e.filterRule)
}
})
}
}
}
}
......
......@@ -558,10 +558,10 @@ export default {
const isRecord = _.refFlowNodeIds.length > 0
const shape = isRecord ? 'ellipse' : 'ellipse'
const refStr = _.refFlowNodeIds.toString().replace(/,/g, '/')
const len = refStr.length - _.displayName.length > 0 ? refStr.length : _.displayName.length
const fontSize = Math.abs(50 - len) * 0.25
// const len = refStr.length - _.displayName.length > 0 ? refStr.length : _.displayName.length
// const fontSize = Math.abs(50 - len) * 0.25
const label = (_.displayName || _.dataId) + '\n' + refStr
return `${nodeId} [label="${label}" class="model" id="${nodeId}" color="${color}" style="filled" fontsize=${fontSize} fillcolor="white" shape="${shape}"]`
return `${nodeId} [label="${label}" class="model" id="${nodeId}" color="${color}" style="filled" fillcolor="white" shape="${shape}"]`
})
let genEdge = () => {
let pathAry = []
......@@ -591,11 +591,22 @@ export default {
genEdge() +
'}'
this.graph.graphviz.renderDot(nodesString)
this.setFontSizeForText()
removeEvent('.model text', 'mouseenter', this.modelGraphMouseenterHandler)
removeEvent('.model text', 'mouseleave', this.modelGraphMouseleaveHandler)
addEvent('.model text', 'mouseenter', this.modelGraphMouseenterHandler)
addEvent('.model text', 'mouseleave', this.modelGraphMouseleaveHandler)
},
setFontSizeForText () {
const nondes = d3.selectAll('#graph svg g .node')._groups[0]
for (let i = 0; i < nondes.length; i++) {
const len = nondes[i].children[2].innerHTML.length
const fontsize = Math.abs(58 - len) * 0.2
for (let j = 2; j < nondes[i].children.length; j++) {
nondes[i].children[j].setAttribute('font-size', fontsize)
}
}
},
modelGraphMouseenterHandler (e) {
clearTimeout(this.modelDetailTimer)
this.modelDetailTimer = setTimeout(async () => {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment