From b353e6f34d5f97c452fadcd10a8871072b9432e9 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Wed, 11 Mar 2020 23:12:18 +0100 Subject: [PATCH] Fix json components --- .../components/JsonEditor/JsonArray.vue | 49 ++++++----- .../components/JsonEditor/JsonElement.vue | 49 ++++++----- .../components/JsonEditor/JsonObject.vue | 83 ++++++++++++------- src/common/components/JsonEditor/json.scss | 16 ++++ 4 files changed, 128 insertions(+), 69 deletions(-) create mode 100644 src/common/components/JsonEditor/json.scss diff --git a/src/common/components/JsonEditor/JsonArray.vue b/src/common/components/JsonEditor/JsonArray.vue index 5e4123a..d751b99 100644 --- a/src/common/components/JsonEditor/JsonArray.vue +++ b/src/common/components/JsonEditor/JsonArray.vue @@ -1,32 +1,34 @@ @@ -46,25 +48,34 @@ export default { }, data() { return { - _value: undefined, - _expanded: true, + value_internal: undefined, + expanded_internal: true, } }, + created() { + this.value_internal = this.value; + }, watch: { value: function(val) { - this._value = val; + this.value_internal = val; }, expanded: function(val) { if (val !== undefined && val !== null) { - this._expanded = !!val; + this.expanded_internal = !!val; } } }, methods: { changeItem(key, value) { - this._value.value[key] = value; - this.$emit('change', this._value.value); + this.value_internal[key] = value; + this.$emit('change', this.value_internal); } } } - \ No newline at end of file + + + diff --git a/src/common/components/JsonEditor/JsonElement.vue b/src/common/components/JsonEditor/JsonElement.vue index 0221f65..525f726 100644 --- a/src/common/components/JsonEditor/JsonElement.vue +++ b/src/common/components/JsonEditor/JsonElement.vue @@ -1,39 +1,42 @@ @@ -38,6 +51,7 @@ export default { name: 'JsonObject', props: [ 'value', + 'label', 'expanded', ], components: { @@ -46,25 +60,32 @@ export default { }, data() { return { - _value: undefined, - _expanded: true, + value_internal: undefined, + expanded_internal: true, } }, + created() { + this.value_internal = this.value; + }, watch: { value: function(val) { - this._value = val; + this.value_internal = val; }, expanded: function(val) { if (val !== undefined && val !== null) { - this._expanded = !!val; + this.expanded_internal = !!val; } } }, methods: { changeItem(key, value) { - this._value.value[key] = value; - this.$emit('change', this._value.value); + this.value_internal[key] = value; + this.$emit('change', this.value_internal); } } } - \ No newline at end of file + + + \ No newline at end of file diff --git a/src/common/components/JsonEditor/json.scss b/src/common/components/JsonEditor/json.scss new file mode 100644 index 0000000..6b6b307 --- /dev/null +++ b/src/common/components/JsonEditor/json.scss @@ -0,0 +1,16 @@ +.json-level-indent { + padding-left: 2em !important; +} +.item-key { + color: #fa6; +} + +.json-value-boolean { + color: rgb(53, 179, 120); +} +.json-value-number { + color: rgb(73, 73, 160); +} +.json-value-string { + color: rgb(195, 35, 35); +}