Add ignoreKeys property to JsonEditor

This commit is contained in:
Tamius Han 2020-03-12 23:35:52 +01:00
parent 9a5ccf1602
commit 7e74aa2c3b
2 changed files with 23 additions and 16 deletions

View File

@ -12,12 +12,14 @@
> >
<JsonArray v-if="Array.isArray(row)" <JsonArray v-if="Array.isArray(row)"
:value="row" :value="row"
:ignoreKeys="ignoreKeys"
@change="changeItem(rowKey, $event)" @change="changeItem(rowKey, $event)"
> >
</JsonArray> </JsonArray>
<JsonObject v-else-if="typeof row === 'object' && row !== null" <JsonObject v-else-if="typeof row === 'object' && row !== null"
:value="row" :value="row"
:label="rowKey" :label="rowKey"
:ignoreKeys="ignoreKeys"
@change="changeItem(rowKey, $event)" @change="changeItem(rowKey, $event)"
> >
</JsonObject> </JsonObject>
@ -41,6 +43,7 @@ export default {
props: [ props: [
'value', 'value',
'expanded', 'expanded',
'ignoreKeys', // this prop is passthrough for JsonArray
], ],
components: { components: {
JsonObject, JsonObject,

View File

@ -16,24 +16,27 @@
<div v-for="(row, rowKey) of value_internal" <div v-for="(row, rowKey) of value_internal"
:key="rowKey" :key="rowKey"
> >
<JsonArray v-if="Array.isArray(row)" <template v-if="(ignoreKeys || {})[rowKey] !== true">
:value="row" <JsonArray v-if="Array.isArray(row)"
@change="changeItem(rowKey, $event)"
>
</JsonArray>
<JsonObject v-else-if="typeof row === 'object' && row !== null"
:value="row" :value="row"
:label="rowKey" :ignoreKeys="(ignoreKeys || {})[rowKey]"
@change="changeItem(rowKey, $event)" @change="changeItem(rowKey, $event)"
> >
</JsonObject> </JsonArray>
<JsonElement v-else <JsonObject v-else-if="typeof row === 'object' && row !== null"
:value="row" :value="row"
:label="rowKey" :label="rowKey"
@change="changeItem(rowKey, $event)" :ignoreKeys="(ignoreKeys || {})[rowKey]"
> @change="changeItem(rowKey, $event)"
</JsonElement> >
</JsonObject>
<JsonElement v-else
:value="row"
:label="rowKey"
@change="changeItem(rowKey, $event)"
>
</JsonElement>
</template>
</div> </div>
<div><b>},</b></div> <div><b>},</b></div>
</template> </template>
@ -50,6 +53,7 @@ export default {
'value', 'value',
'label', 'label',
'expanded', 'expanded',
'ignoreKeys',
], ],
components: { components: {
JsonArray, JsonArray,