mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
make not recursive
This commit is contained in:
parent
b0cc1abd28
commit
f064fc14f4
|
@ -1,10 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="n8n-tree">
|
<div class="n8n-tree">
|
||||||
<n8n-tree-node :input="input" :path="path">
|
<div v-for="row in parsedData" :style="getStyles(row)">
|
||||||
<template v-for="(index, name) in $scopedSlots" v-slot:[name]="data">
|
<slot name="label" v-bind:label="row.label" />
|
||||||
<slot :name="name" v-bind="data"></slot>
|
<span v-if="row.value"> : </span>
|
||||||
</template>
|
<span v-if="row.value" :class="$style.value">{{ row.value }}</span>
|
||||||
</n8n-tree-node>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -12,11 +12,10 @@
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import N8nTreeNode from './TreeNode.vue';
|
import N8nTreeNode from './TreeNode.vue';
|
||||||
|
|
||||||
|
const INDENT = 24;
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
name: 'n8n-tree',
|
name: 'n8n-tree',
|
||||||
components: {
|
|
||||||
N8nTreeNode,
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
input: {
|
input: {
|
||||||
},
|
},
|
||||||
|
@ -26,9 +25,46 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
parsedData() {
|
||||||
|
const data = traverse(this.input);
|
||||||
|
console.log(data);
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getStyles(row) {
|
||||||
|
return {marginLeft: `${INDENT * row.depth}px`};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function traverse(data, parsed = [], depth = 0) {
|
||||||
|
Object.keys(data).forEach((label, i) => {
|
||||||
|
const row = {
|
||||||
|
label,
|
||||||
|
depth,
|
||||||
|
};
|
||||||
|
parsed.push(row);
|
||||||
|
if (typeof data[label] !== 'object') {
|
||||||
|
row.value = data[label];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
traverse(data[label], parsed, depth + 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
|
.simple {
|
||||||
|
text-indent: -24px;
|
||||||
|
margin-left: var(--spacing-l);
|
||||||
|
}
|
||||||
|
|
||||||
|
.value {
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue