Skip to content

Commit 2cbf7d0

Browse files
#51 Remember toggle state for key-value component members in inspector
* Remember toggle state for key-value component members in inspector * Switch toggle state memory for kv members from key to absolute path.
1 parent 77ec829 commit 2cbf7d0

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

etc/js/components/widgets/inspector/entity-inspector-component.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<template v-if="expand && value">
7171
<div class="component-value">
7272
<entity-inspector-value
73+
:path="fullName"
7374
:value="value"
7475
:type="type"
7576
:readonly="isReadonly"

etc/js/components/widgets/inspector/entity-inspector-kv.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</entity-inspector-preview>
1919
<template v-if="expand">
2020
<entity-inspector-value
21+
:path="path"
2122
:value="value"
2223
:type="type"
2324
:readonly="readonly"
@@ -41,9 +42,10 @@ export default { name: "entity-inspector-kv" }
4142
</script>
4243

4344
<script setup>
44-
import { defineProps, defineEmits, ref } from 'vue';
45+
import { defineProps, defineEmits, ref, onMounted } from 'vue';
4546
4647
const props = defineProps({
48+
path: {type: String, required: true},
4749
keyname: {type: String, required: true},
4850
value: {required: true},
4951
type: {type: Object, required: true},
@@ -55,6 +57,7 @@ const expand = ref(false);
5557
5658
function toggle() {
5759
expand.value = !expand.value;
60+
localStorage.setItem(`${props.path}.expand`, String(expand.value));
5861
}
5962
6063
function setValue(evt, key) {
@@ -65,6 +68,10 @@ function setValue(evt, key) {
6568
}
6669
}
6770
71+
onMounted(() => {
72+
expand.value = localStorage.getItem(`${props.path}.expand`) === "true";
73+
});
74+
6875
</script>
6976

7077
<style scoped>

etc/js/components/widgets/inspector/entity-inspector-value.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<div class="prop-grid">
55
<template v-for="(value, key) in value">
66
<entity-inspector-kv
7+
:path="path + '.' + key"
78
:keyname="key"
89
:value="value"
910
:type="type[key]"
@@ -32,6 +33,7 @@ export default { name: "entity-inspector-value" }
3233
import { defineProps, defineEmits } from 'vue';
3334
3435
const props = defineProps({
36+
path: {type: String, required: true},
3537
value: {required: true},
3638
type: {type: Object, required: true},
3739
readonly: {type: Boolean, required: true}

0 commit comments

Comments
 (0)