feat: 🎸 #84, add default title props

pull/75/merge
youxingzhi 2 years ago
parent 347a927e90
commit 5b2fea32ad
  1. 16
      src/VueTreeList.vue
  2. 4
      tests/unit/__snapshots__/render.spec.js.snap
  3. 4
      tests/unit/__snapshots__/slot.spec.js.snap
  4. 4
      tests/unit/operation.spec.js

@ -58,7 +58,7 @@
/>
<div class="vtl-operation" v-show="isHover">
<span
title="add tree node"
:title="defaultAddTreeNodeTitle"
@click.stop.prevent="addChild(false)"
v-if="!model.isLeaf && !model.addTreeNodeDisabled"
>
@ -67,7 +67,7 @@
</slot>
</span>
<span
title="add leaf node"
:title="defaultAddLeafNodeTitle"
@click.stop.prevent="addChild(true)"
v-if="!model.isLeaf && !model.addLeafNodeDisabled"
>
@ -162,11 +162,19 @@ export default {
},
defaultLeafNodeName: {
type: String,
default: 'New leaf node'
default: 'Leaf Node'
},
defaultTreeNodeName: {
type: String,
default: 'New tree node'
default: 'Tree Node'
},
defaultAddTreeNodeTitle: {
type: String,
default: 'Add Tree Node'
},
defaultAddLeafNodeTitle: {
type: String,
default: 'Add Leaf Node'
},
defaultExpanded: {
type: Boolean,

@ -47,7 +47,7 @@ exports[`Render render correctly 1`] = `
<div class="vtl-node-content">
Node 2
</div>
<div class="vtl-operation" style="display: none;"><span title="add tree node"><i class="vtl-icon vtl-icon-folder-plus-e"></i></span> <span title="add leaf node"><i class="vtl-icon vtl-icon-plus"></i></span> <span title="edit"><i class="vtl-icon vtl-icon-edit"></i></span> <span title="delete"><i class="vtl-icon vtl-icon-trash"></i></span></div>
<div class="vtl-operation" style="display: none;"><span title="Add Tree Node"><i class="vtl-icon vtl-icon-folder-plus-e"></i></span> <span title="Add Leaf Node"><i class="vtl-icon vtl-icon-plus"></i></span> <span title="edit"><i class="vtl-icon vtl-icon-edit"></i></span> <span title="delete"><i class="vtl-icon vtl-icon-trash"></i></span></div>
</div>
<!---->
</div>
@ -61,7 +61,7 @@ exports[`Render render correctly 1`] = `
<div class="vtl-node-content">
Node 3
</div>
<div class="vtl-operation" style="display: none;"><span title="add tree node"><i class="vtl-icon vtl-icon-folder-plus-e"></i></span> <span title="add leaf node"><i class="vtl-icon vtl-icon-plus"></i></span> <span title="edit"><i class="vtl-icon vtl-icon-edit"></i></span> <span title="delete"><i class="vtl-icon vtl-icon-trash"></i></span></div>
<div class="vtl-operation" style="display: none;"><span title="Add Tree Node"><i class="vtl-icon vtl-icon-folder-plus-e"></i></span> <span title="Add Leaf Node"><i class="vtl-icon vtl-icon-plus"></i></span> <span title="edit"><i class="vtl-icon vtl-icon-edit"></i></span> <span title="delete"><i class="vtl-icon vtl-icon-trash"></i></span></div>
</div>
<!---->
</div>

@ -11,7 +11,7 @@ exports[`Slot render slot correctly 1`] = `
<div class="vtl-node-content">
Node 1
</div>
<div class="vtl-operation" style="display: none;"><span title="add tree node"><span class="add-tree-node-icon">📂</span></span> <span title="add leaf node"><span class="icon">+</span></span> <span title="edit"><span class="icon">📃</span></span> <span title="delete"><span></span></span></div>
<div class="vtl-operation" style="display: none;"><span title="Add Tree Node"><span class="add-tree-node-icon">📂</span></span> <span title="Add Leaf Node"><span class="icon">+</span></span> <span title="edit"><span class="icon">📃</span></span> <span title="delete"><span></span></span></div>
</div>
<div class="vtl-border vtl-bottom"></div>
</div>
@ -42,7 +42,7 @@ exports[`Slot render slot correctly 1`] = `
<div class="vtl-node-content">
Node 2
</div>
<div class="vtl-operation" style="display: none;"><span title="add tree node"><span class="add-tree-node-icon">📂</span></span> <span title="add leaf node"><span class="icon">+</span></span> <span title="edit"><span class="icon">📃</span></span> <span title="delete"><span class="del-node-icon">✂</span></span></div>
<div class="vtl-operation" style="display: none;"><span title="Add Tree Node"><span class="add-tree-node-icon">📂</span></span> <span title="Add Leaf Node"><span class="icon">+</span></span> <span title="edit"><span class="icon">📃</span></span> <span title="delete"><span class="del-node-icon">✂</span></span></div>
</div>
<!---->
</div>

@ -51,7 +51,7 @@ describe('Operation', () => {
})
it('add leaf node', done => {
const $node1AddLeafNode = wrapper.find('#t1 [title="add leaf node"]')
const $node1AddLeafNode = wrapper.find('#t1 [title="Add Leaf Node"]')
$node1AddLeafNode.trigger('click')
Vue.nextTick(() => {
expect(wrapper.findAll('.vtl-leaf-node').length).toBe(2)
@ -60,7 +60,7 @@ describe('Operation', () => {
})
it('add tree node', done => {
const $node1AddTreeNode = wrapper.find('#t1 [title="add tree node"]')
const $node1AddTreeNode = wrapper.find('#t1 [title="Add Tree Node"]')
$node1AddTreeNode.trigger('click')
Vue.nextTick(() => {
expect(wrapper.findAll('.vtl-tree-node').length).toBe(3)

Loading…
Cancel
Save