27
27
@keyup.enter =" submitEdit()"
28
28
>
29
29
</span >
30
- <span v-else class =" key" :class =" { abstract: field.abstractField }" >{{ field.key }}</span ><span class =" colon" v-if =" !field.abstractField " >:</span >
30
+ <span v-else class =" key" :class =" { abstract: fieldOptions.abstract }" >{{ field.key }}</span ><span class =" colon" v-if =" !fieldOptions.abstract " >:</span >
31
31
32
32
<span
33
33
v-if =" editing"
@@ -266,13 +266,17 @@ export default {
266
266
},
267
267
isExpandableType () {
268
268
const value = this .field .value
269
- return Array .isArray (value) ||
270
- (this .valueType === ' custom' && value ._custom .state ) ||
271
- (this .valueType !== ' custom' && isPlainObject (value))
269
+ return (typeof this .fieldOptions .expandable === ' undefined' || this .fieldOptions .expandable ) &&
270
+ (
271
+ Array .isArray (value) ||
272
+ (this .valueType === ' custom' && value ._custom .expandable ) ||
273
+ (this .valueType !== ' custom' && isPlainObject (value))
274
+ )
272
275
},
273
276
isEditable () {
274
277
return this .editable &&
275
- ! this .field .abstractField &&
278
+ ! this .fieldOptions .abstract &&
279
+ ! this .fieldOptions .readOnly &&
276
280
(
277
281
typeof this .field .key !== ' string' ||
278
282
this .field .key .charAt (0 ) !== ' $'
@@ -294,7 +298,7 @@ export default {
294
298
},
295
299
formattedValue () {
296
300
const value = this .field .value
297
- if (this .field . abstractField ) {
301
+ if (this .fieldOptions . abstract ) {
298
302
return ' '
299
303
} else if (value === null ) {
300
304
return ' null'
@@ -327,29 +331,40 @@ export default {
327
331
},
328
332
formattedSubFields () {
329
333
let value = this .field .value
334
+
335
+ // CustomValue API
336
+ const isCustom = this .valueType === ' custom'
337
+ let inherit = {}
338
+ if (isCustom) {
339
+ inherit = value ._custom .fields || {}
340
+ value = value ._custom .value
341
+ }
342
+
330
343
if (Array .isArray (value)) {
331
344
value = value .map ((item , i ) => ({
332
345
key: i,
333
- value: item
346
+ value: item,
347
+ ... inherit
334
348
}))
335
349
} else if (typeof value === ' object' ) {
336
- const isCustom = this .valueType === ' custom'
337
- let abstractField = false
338
- if (isCustom) {
339
- abstractField = !! value ._custom .abstract
340
- value = value ._custom .state
341
- }
342
350
value = sortByKey (Object .keys (value).map (key => ({
343
351
key,
344
352
value: value[key],
345
- abstractField
353
+ ... inherit
346
354
})))
347
355
}
348
356
return value
349
357
},
350
358
limitedSubFields () {
351
359
return this .formattedSubFields .slice (0 , this .limit )
352
360
},
361
+ fieldOptions () {
362
+ if (this .valueType === ' custom' ) {
363
+ return Object .assign ({}, this .field , this .field .value ._custom )
364
+ } else {
365
+ return this .field
366
+ }
367
+ },
353
368
valueValid () {
354
369
try {
355
370
parse (this .transformSpecialTokens (this .editedValue , false ))
0 commit comments