diff --git a/resources/js/components/fieldtypes/ArrayFieldtype.vue b/resources/js/components/fieldtypes/ArrayFieldtype.vue index bc98ff0f6c..37ede3db49 100644 --- a/resources/js/components/fieldtypes/ArrayFieldtype.vue +++ b/resources/js/components/fieldtypes/ArrayFieldtype.vue @@ -170,6 +170,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return _.reduce(this.value, (carry, value, key) => { let str = `${key}: ${value}`; if (carry) str = carry + ', ' + str; diff --git a/resources/js/components/fieldtypes/ButtonGroupFieldtype.vue b/resources/js/components/fieldtypes/ButtonGroupFieldtype.vue index 34b997a7b6..543c311cce 100644 --- a/resources/js/components/fieldtypes/ButtonGroupFieldtype.vue +++ b/resources/js/components/fieldtypes/ButtonGroupFieldtype.vue @@ -28,6 +28,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + var option = _.findWhere(this.config.options, {value: this.value}); return (option) ? option.label : this.value; }, diff --git a/resources/js/components/fieldtypes/CheckboxesFieldtype.vue b/resources/js/components/fieldtypes/CheckboxesFieldtype.vue index a7bc850d50..a1c9eb959e 100644 --- a/resources/js/components/fieldtypes/CheckboxesFieldtype.vue +++ b/resources/js/components/fieldtypes/CheckboxesFieldtype.vue @@ -34,6 +34,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return this.values.map(value => { const option = _.findWhere(this.options, { value }); return option ? option.label : value; diff --git a/resources/js/components/fieldtypes/CodeFieldtype.vue b/resources/js/components/fieldtypes/CodeFieldtype.vue index 6fd083ccb3..7a11f191dd 100644 --- a/resources/js/components/fieldtypes/CodeFieldtype.vue +++ b/resources/js/components/fieldtypes/CodeFieldtype.vue @@ -105,6 +105,8 @@ export default { return 'theme-' + this.config.theme; }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return this.value.code ? truncate(this.value.code, 60) : ''; }, readOnlyOption() { diff --git a/resources/js/components/fieldtypes/ColorFieldtype.vue b/resources/js/components/fieldtypes/ColorFieldtype.vue index eedc8bc8be..70848b3011 100644 --- a/resources/js/components/fieldtypes/ColorFieldtype.vue +++ b/resources/js/components/fieldtypes/ColorFieldtype.vue @@ -92,6 +92,8 @@ export default { computed: { replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return this.value ? `` : null; diff --git a/resources/js/components/fieldtypes/DateFieldtype.vue b/resources/js/components/fieldtypes/DateFieldtype.vue index 172bf3507a..720042907b 100644 --- a/resources/js/components/fieldtypes/DateFieldtype.vue +++ b/resources/js/components/fieldtypes/DateFieldtype.vue @@ -159,6 +159,7 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; if (! this.value.date) return; if (this.isRange) { diff --git a/resources/js/components/fieldtypes/Fieldtype.vue b/resources/js/components/fieldtypes/Fieldtype.vue index 00b50f441e..a40ff35fe2 100644 --- a/resources/js/components/fieldtypes/Fieldtype.vue +++ b/resources/js/components/fieldtypes/Fieldtype.vue @@ -21,6 +21,10 @@ export default { type: Boolean, default: false }, + showFieldPreviews: { + type: Boolean, + default: false + }, namePrefix: String, fieldPathPrefix: String, }, @@ -56,6 +60,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return this.value; }, @@ -71,6 +77,8 @@ export default { replicatorPreview: { immediate: true, handler(text) { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + this.$emit('replicator-preview-updated', text); } } diff --git a/resources/js/components/fieldtypes/GroupFieldtype.vue b/resources/js/components/fieldtypes/GroupFieldtype.vue index 599f85aa0b..c40b6d3687 100644 --- a/resources/js/components/fieldtypes/GroupFieldtype.vue +++ b/resources/js/components/fieldtypes/GroupFieldtype.vue @@ -106,6 +106,8 @@ export default { return this.config.fields; }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return Object.values(this.value).join(', '); } }, diff --git a/resources/js/components/fieldtypes/RadioFieldtype.vue b/resources/js/components/fieldtypes/RadioFieldtype.vue index 0799d56882..f82f8ee1f6 100644 --- a/resources/js/components/fieldtypes/RadioFieldtype.vue +++ b/resources/js/components/fieldtypes/RadioFieldtype.vue @@ -32,6 +32,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + var option = _.findWhere(this.config.options, {value: this.value}); return (option) ? option.label : this.value; }, diff --git a/resources/js/components/fieldtypes/SelectFieldtype.vue b/resources/js/components/fieldtypes/SelectFieldtype.vue index 9294730f42..a1c0e43c48 100644 --- a/resources/js/components/fieldtypes/SelectFieldtype.vue +++ b/resources/js/components/fieldtypes/SelectFieldtype.vue @@ -110,6 +110,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return this.selectedOptions.map(option => option.label).join(', '); }, diff --git a/resources/js/components/fieldtypes/TableFieldtype.vue b/resources/js/components/fieldtypes/TableFieldtype.vue index 8dad81c814..147e025690 100644 --- a/resources/js/components/fieldtypes/TableFieldtype.vue +++ b/resources/js/components/fieldtypes/TableFieldtype.vue @@ -163,6 +163,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + // Join all values with commas. Exclude any empties. return _(this.data) .map(row => row.value.cells.filter(cell => !!cell).join(', ')) diff --git a/resources/js/components/fieldtypes/ToggleFieldtype.vue b/resources/js/components/fieldtypes/ToggleFieldtype.vue index 7898b20955..c519480101 100644 --- a/resources/js/components/fieldtypes/ToggleFieldtype.vue +++ b/resources/js/components/fieldtypes/ToggleFieldtype.vue @@ -16,6 +16,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return (this.value ? '✓' : '✗') + ' ' + __(this.config.display); } diff --git a/resources/js/components/fieldtypes/assets/AssetsFieldtype.vue b/resources/js/components/fieldtypes/assets/AssetsFieldtype.vue index 2d6304e960..ed0aeba884 100644 --- a/resources/js/components/fieldtypes/assets/AssetsFieldtype.vue +++ b/resources/js/components/fieldtypes/assets/AssetsFieldtype.vue @@ -336,6 +336,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return replicatorPreviewHtml(_.map(this.assets, (asset) => { return (asset.isImage || asset.isSvg) ? `` diff --git a/resources/js/components/fieldtypes/bard/BardFieldtype.vue b/resources/js/components/fieldtypes/bard/BardFieldtype.vue index 5f2784d0c5..21062358ab 100644 --- a/resources/js/components/fieldtypes/bard/BardFieldtype.vue +++ b/resources/js/components/fieldtypes/bard/BardFieldtype.vue @@ -286,6 +286,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + const stack = JSON.parse(this.value); let text = ''; while (stack.length) { diff --git a/resources/js/components/fieldtypes/bard/Set.vue b/resources/js/components/fieldtypes/bard/Set.vue index 13bf5ffc89..8b49ddbcae 100644 --- a/resources/js/components/fieldtypes/bard/Set.vue +++ b/resources/js/components/fieldtypes/bard/Set.vue @@ -44,6 +44,7 @@ :set-index="index" :field-path="fieldPath(field)" :read-only="isReadOnly" + :show-field-previews="showFieldPreviews" @updated="updated(field.handle, $event)" @meta-updated="metaUpdated(field.handle, $event)" @focus="focused" diff --git a/resources/js/components/fieldtypes/grid/Grid.vue b/resources/js/components/fieldtypes/grid/Grid.vue index 868a163a0b..c38b32e40a 100644 --- a/resources/js/components/fieldtypes/grid/Grid.vue +++ b/resources/js/components/fieldtypes/grid/Grid.vue @@ -136,6 +136,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return `${__(this.config.display)}: ${__n(':count row|:count rows', this.value.length)}`; } diff --git a/resources/js/components/fieldtypes/markdown/MarkdownFieldtype.vue b/resources/js/components/fieldtypes/markdown/MarkdownFieldtype.vue index 2657b3d4d1..4fd8dcd46d 100644 --- a/resources/js/components/fieldtypes/markdown/MarkdownFieldtype.vue +++ b/resources/js/components/fieldtypes/markdown/MarkdownFieldtype.vue @@ -692,6 +692,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return marked(this.data || '', { renderer: new PlainTextRenderer }) .replace(/<\/?[^>]+(>|$)/g, ""); } diff --git a/resources/js/components/fieldtypes/relationship/RelationshipFieldtype.vue b/resources/js/components/fieldtypes/relationship/RelationshipFieldtype.vue index 90962a95b8..3e91f3f778 100644 --- a/resources/js/components/fieldtypes/relationship/RelationshipFieldtype.vue +++ b/resources/js/components/fieldtypes/relationship/RelationshipFieldtype.vue @@ -134,6 +134,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return this.value.map(id => { const item = _.findWhere(this.meta.data, { id }); return item ? item.title : id; diff --git a/resources/js/components/fieldtypes/replicator/Field.vue b/resources/js/components/fieldtypes/replicator/Field.vue index 6c0465f4aa..a2fd3c43ef 100644 --- a/resources/js/components/fieldtypes/replicator/Field.vue +++ b/resources/js/components/fieldtypes/replicator/Field.vue @@ -23,6 +23,7 @@ :field-path-prefix="fieldPath" :has-error="hasError || hasNestedError" :read-only="isReadOnly" + :show-field-previews="showFieldPreviews" @input="$emit('updated', $event)" @meta-updated="$emit('meta-updated', $event)" @focus="$emit('focus')" @@ -69,6 +70,7 @@ export default { type: String }, readOnly: Boolean, + showFieldPreviews: Boolean, }, inject: ['storeName'], diff --git a/resources/js/components/fieldtypes/replicator/Replicator.vue b/resources/js/components/fieldtypes/replicator/Replicator.vue index 73ecb5f153..0dfb85324f 100644 --- a/resources/js/components/fieldtypes/replicator/Replicator.vue +++ b/resources/js/components/fieldtypes/replicator/Replicator.vue @@ -172,6 +172,8 @@ export default { }, replicatorPreview() { + if (! this.showFieldPreviews || ! this.config.replicator_preview) return; + return `${__(this.config.display)}: ${__n(':count set|:count sets', this.value.length)}`; } }, diff --git a/resources/js/components/fieldtypes/replicator/Set.vue b/resources/js/components/fieldtypes/replicator/Set.vue index d1a8581397..4361bde58c 100644 --- a/resources/js/components/fieldtypes/replicator/Set.vue +++ b/resources/js/components/fieldtypes/replicator/Set.vue @@ -44,6 +44,7 @@ :set-index="index" :field-path="fieldPath(field)" :read-only="isReadOnly" + :show-field-previews="showFieldPreviews" @updated="updated(field.handle, $event)" @meta-updated="metaUpdated(field.handle, $event)" @focus="$emit('focus')"