Skip to content

Commit 6c735eb

Browse files
authored
Merge pull request #45 from leezng/dev
release 1.6.2
2 parents ea8f0cd + d37a3cc commit 6c735eb

File tree

5 files changed

+33
-24
lines changed

5 files changed

+33
-24
lines changed

example/App.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
</vue-json-pretty>
134134
</div>
135135
</div>
136-
<a style="position: fixed; right: 0; top: 0;" href="https://github.com/leezng/el-form-renderer" target="_blank"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
136+
<a style="position: fixed; right: 0; top: 0;" href="https://github.com/leezng/vue-json-pretty" target="_blank"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png"></a>
137137
</div>
138138
</template>
139139

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-json-pretty",
3-
"version": "1.6.1",
3+
"version": "1.6.2",
44
"description": "A JSON tree view component that is easy to use and also supports data selection.",
55
"author": "leezng <im.leezng@gmail.com>",
66
"main": "vue-json-pretty.js",

src/components/app.vue

+28-19
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
'is-highlight-selected': isSelected && highlightSelectedNode,
1010
'is-mouseover': isMouseover
1111
}"
12-
@click="handleClick($event, 'tree')"
12+
@click="handleClick"
1313
@mouseover.stop="handleMouseover"
1414
@mouseout.stop="handleMouseout">
1515
<template v-if="showSelectController && selectable">
16-
<vue-checkbox v-if="isMultiple" v-model="currentCheckboxVal" @change="handleClick($event, 'checkbox')"></vue-checkbox>
17-
<vue-radio v-else-if="isSingle" v-model="model" @change="handleClick($event, 'radio')" :path="path"></vue-radio>
16+
<vue-checkbox v-if="isMultiple" v-model="currentCheckboxVal" @change="handleValueChange('checkbox')"></vue-checkbox>
17+
<vue-radio v-else-if="isSingle" v-model="model" @change="handleValueChange('radio')" :path="path"></vue-radio>
1818
</template>
1919

2020
<template v-if="Array.isArray(data) || isObject(data)">
@@ -73,7 +73,12 @@
7373
:parent-data="parentData"
7474
:data="data"
7575
:current-key="currentKey">
76-
<span v-if="!Array.isArray(parentData)" class="vjs-key">{{ keyFormatter(currentKey) }}:</span>
76+
<span
77+
v-if="parentData && currentKey && !Array.isArray(parentData)"
78+
class="vjs-key"
79+
>
80+
{{ keyFormatter(currentKey) }}:
81+
</span>
7782
</simple-text>
7883
</div>
7984
</template>
@@ -237,20 +242,8 @@
237242
}
238243
},
239244
methods: {
240-
/**
241-
* emit click event
242-
* @param {string} emitType tree/checkbox/radio
243-
*/
244-
handleClick (e, emitType = '') {
245-
// Event can not be stopPropagation, because user may be listening the click event.
246-
// So use _uid to simulated.
247-
if (e._uid && e._uid !== this._uid) return
248-
e._uid = this._uid
249-
250-
this.$emit('click', this.path, this.data)
251-
if (!this.selectable) return
252-
253-
if (this.isMultiple && (emitType === 'checkbox' || (this.selectOnClickNode && emitType === 'tree'))) {
245+
handleValueChange (emitType) {
246+
if (this.isMultiple && (emitType === 'checkbox' || emitType === 'tree')) {
254247
// handle multiple
255248
const index = this.model.findIndex(item => item === this.path)
256249
const oldVal = [...this.model]
@@ -264,7 +257,7 @@
264257
this.currentCheckboxVal = !this.currentCheckboxVal
265258
}
266259
this.$emit('change', this.model, oldVal)
267-
} else if (this.isSingle && (emitType === 'radio' || (this.selectOnClickNode && emitType === 'tree'))) {
260+
} else if (this.isSingle && (emitType === 'radio' || emitType === 'tree')) {
268261
// handle single
269262
if (this.model !== this.path) {
270263
const oldVal = this.model
@@ -275,6 +268,22 @@
275268
}
276269
},
277270
271+
/**
272+
* emit click event
273+
* @param {string} emitType tree/checkbox/radio
274+
*/
275+
handleClick (e) {
276+
// Event can not be stopPropagation, because user may be listening the click event.
277+
// So use _uid to simulated.
278+
if (e._uid && e._uid !== this._uid) return
279+
e._uid = this._uid
280+
281+
this.$emit('click', this.path, this.data)
282+
if (this.selectable && this.selectOnClickNode) {
283+
this.handleValueChange('tree')
284+
}
285+
},
286+
278287
// handle children's click, and propagation
279288
handleItemClick (path, data) {
280289
this.$emit('click', path, data)

src/components/radio.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
type="radio"
88
v-model="model"
99
:value="currentPath"
10-
@change="test"
10+
@change="change"
1111
@focus="focus = true"
1212
@blur="focus = false">
1313
</label>
@@ -42,7 +42,7 @@
4242
}
4343
},
4444
methods: {
45-
test () {
45+
change () {
4646
this.$emit('change', this.model)
4747
}
4848
}

src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import App from './components/app.vue'
22
import './assets/less/index.less'
33

44
export default Object.assign({}, App, {
5-
version: '1.6.1'
5+
version: '1.6.2'
66
})

0 commit comments

Comments
 (0)