Skip to content
代码片段 群组 项目
提交 4ab7b199 编辑于 作者: Jing Teng's avatar Jing Teng
浏览文件

util function for parsing selected components from jetty server response

上级 14adcce9
No related branches found
No related tags found
无相关合并请求
......@@ -31,6 +31,7 @@ limitations under the License.
<script>
const restApi = require('../../src-shared/rest-api.js')
import CommonMixin from '../util/common-mixin'
const util = require('../util/util.js')
export default {
name: 'UcComponentSetup',
......@@ -59,21 +60,13 @@ export default {
studioProject: this.$store.state.zap.studioProject,
},
}).then((response) => {
this.componentTree.length = 0
response.data.forEach((ele) => this.componentTree.push(ele))
// computed selected Nodes
let selected = []
this.componentTree.filter(function f(e) {
if (e.children) {
e.children.filter(f, this)
}
if (e.isSelected) {
this.push(e.id)
}
}, selected)
selected.forEach((e) => this.uc.ticked.push(e))
let selectedComponentIds = util.getSelectedComponent(response.data)
this.uc.ticked.length = 0
selectedComponentIds.forEach((e) => this.uc.ticked.push(e))
this.uc.last_ticked = this.uc.ticked
})
},
......
......@@ -116,3 +116,20 @@ export function notifyComponentStatus(componentIdStates, added) {
}
}
}
export function getSelectedComponent(ucComponentTreeResponse) {
// computed selected Nodes
let selected = []
if (ucComponentTreeResponse) {
ucComponentTreeResponse.filter(function f(e) {
if (e.children) {
e.children.filter(f, this)
}
if (e.isSelected) {
this.push(e.id)
}
}, selected)
}
return selected
}
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册