172
172
class =" children"
173
173
>
174
174
<data-field
175
- v-for =" subField in limitedSubFields "
175
+ v-for =" subField in formattedSubFields "
176
176
:key =" subField.key"
177
177
:field =" subField"
178
178
:parent-field =" field"
185
185
:is-state-field =" isStateField"
186
186
/>
187
187
<span
188
- v-if =" formattedSubFields.length > limit"
188
+ v-if =" subFieldCount > limit"
189
+ v-tooltip =" 'Show more'"
189
190
:style =" { marginLeft: depthMargin + 'px' }"
190
191
class =" more"
191
- @click =" limit += 10 "
192
+ @click =" showMoreSubfields() "
192
193
>
193
194
...
194
195
</span >
@@ -273,7 +274,7 @@ export default {
273
274
data () {
274
275
return {
275
276
contextMenuOpen: false ,
276
- limit: Array . isArray ( this . field . value ) ? 10 : Infinity ,
277
+ limit: 20 ,
277
278
expanded: this .depth === 0 && this .field .key !== ' $route' && (subFieldCount (this .field .value ) < 5 )
278
279
}
279
280
},
@@ -309,7 +310,7 @@ export default {
309
310
} else {
310
311
return ' string'
311
312
}
312
- } else if (Array .isArray (value)) {
313
+ } else if (Array .isArray (value) || (value && value . _isArray ) ) {
313
314
return ' array'
314
315
} else if (isPlainObject (value)) {
315
316
return ' plain-object'
@@ -367,7 +368,7 @@ export default {
367
368
}
368
369
},
369
370
370
- formattedSubFields () {
371
+ rawValue () {
371
372
let value = this .field .value
372
373
373
374
// CustomValue API
@@ -378,8 +379,17 @@ export default {
378
379
value = value ._custom .value
379
380
}
380
381
382
+ if (value && value ._isArray ) {
383
+ value = value .items
384
+ }
385
+ return { value, inherit }
386
+ },
387
+
388
+ formattedSubFields () {
389
+ let { value, inherit } = this .rawValue
390
+
381
391
if (Array .isArray (value)) {
382
- value = value .map ((item , i ) => ({
392
+ return value . slice ( 0 , this . limit ) .map ((item , i ) => ({
383
393
key: i,
384
394
value: item,
385
395
... inherit
@@ -394,11 +404,13 @@ export default {
394
404
value = sortByKey (value)
395
405
}
396
406
}
397
- return value
407
+
408
+ return value .slice (0 , this .limit )
398
409
},
399
410
400
- limitedSubFields () {
401
- return this .formattedSubFields .slice (0 , this .limit )
411
+ subFieldCount () {
412
+ const { value } = this .rawValue
413
+ return subFieldCount (value)
402
414
},
403
415
404
416
valueTooltip () {
@@ -505,6 +517,10 @@ export default {
505
517
this .$_contextMenuTimer = setTimeout (() => {
506
518
this .contextMenuOpen = false
507
519
}, 4000 )
520
+ },
521
+
522
+ showMoreSubfields () {
523
+ this .limit += 20
508
524
}
509
525
}
510
526
}
0 commit comments