diff --git a/.phpstan/baseline.neon b/.phpstan/baseline.neon
index 527438b53cd..24ec78db201 100644
--- a/.phpstan/baseline.neon
+++ b/.phpstan/baseline.neon
@@ -67,7 +67,7 @@ parameters:
path: ../src/Facades/Endpoint/Parse.php
-
- message: '#^Method Illuminate\\Contracts\\Validation\\DataAwareRule@anonymous/Fieldtypes/Bard\.php\:898\:\:setData\(\) should return \$this\(Illuminate\\Contracts\\Validation\\DataAwareRule@anonymous/Fieldtypes/Bard\.php\:898\) but return statement is missing\.$#'
+ message: '#^Method Illuminate\\Contracts\\Validation\\DataAwareRule@anonymous/Fieldtypes/Bard\.php\:935\:\:setData\(\) should return \$this\(Illuminate\\Contracts\\Validation\\DataAwareRule@anonymous/Fieldtypes/Bard\.php\:935\) but return statement is missing\.$#'
identifier: return.missing
count: 1
path: ../src/Fieldtypes/Bard.php
diff --git a/resources/js/components/fieldtypes/LinkFieldtype.vue b/resources/js/components/fieldtypes/LinkFieldtype.vue
index 0b48bf99c7b..d0797f6d472 100644
--- a/resources/js/components/fieldtypes/LinkFieldtype.vue
+++ b/resources/js/components/fieldtypes/LinkFieldtype.vue
@@ -2,36 +2,22 @@
@@ -45,7 +31,7 @@ import { markRaw } from 'vue';
import { UPDATE_DEBOUNCE_MS } from './constants';
export default {
- components: { Input, Text, Select },
+ components: { Input, Select },
mixins: [Fieldtype],
provide: {
@@ -57,8 +43,7 @@ export default {
option: this.meta.initialOption,
options: this.initialOptions(),
urlValue: this.meta.initialUrl,
- selectedEntries: this.meta.initialSelectedEntries,
- selectedAssets: this.meta.initialSelectedAssets,
+ selectedByType: this.initialSelectedByType(this.meta),
metaChanging: false,
};
},
@@ -71,26 +56,29 @@ export default {
},
computed: {
- entryValue() {
- return this.selectedEntries.length ? `entry::${this.selectedEntries[0]}` : null;
+ matchedType() {
+ return this.meta.types[this.option] ?? null;
+ },
+
+ matchedTypeComponent() {
+ return `${this.matchedType.component}-fieldtype`;
},
- assetValue() {
- return this.selectedAssets.length ? `asset::${this.selectedAssets[0]}` : null;
+ typeValue() {
+ const selected = this.selectedByType[this.option];
+ return selected && selected.length ? `${this.option}::${selected[0]}` : null;
},
replicatorPreview() {
if (!this.showFieldPreviews) return;
- switch (this.option) {
- case 'url':
- return this.urlValue;
- case 'first-child':
- return __('First Child');
- case 'entry':
- return data_get(this.meta, 'entry.meta.data.0.title', this.entryValue);
- case 'asset':
- return data_get(this.meta, 'asset.meta.data.0.basename', this.assetValue);
+ if (this.option === 'url') return this.urlValue;
+ if (this.option === 'first-child') return __('First Child');
+
+ if (this.matchedType) {
+ return data_get(this.meta, `types.${this.option}.meta.data.0.title`)
+ ?? data_get(this.meta, `types.${this.option}.meta.data.0.basename`)
+ ?? this.typeValue;
}
return this.value;
@@ -107,18 +95,10 @@ export default {
this.updateDebounced(this.urlValue);
} else if (option === 'first-child') {
this.update('@child');
- } else if (option === 'entry') {
- if (this.entryValue) {
- this.update(this.entryValue);
- } else {
- setTimeout(() => this.$refs.entries.linkExistingItem(), 0);
- }
- } else if (option === 'asset') {
- if (this.assetValue) {
- this.update(this.assetValue);
- } else {
- setTimeout(() => this.$refs.assets.openSelector(), 0);
- }
+ } else if (this.matchedType) {
+ this.typeValue
+ ? this.update(this.typeValue)
+ : this.$nextTick(() => this.openTypeSelector());
}
this.updateMeta({ ...this.meta, initialOption: option });
@@ -136,8 +116,7 @@ export default {
this.metaChanging = true;
this.urlValue = meta.initialUrl;
this.option = meta.initialOption;
- this.selectedEntries = meta.initialSelectedEntries;
- this.selectedAssets = meta.initialSelectedAssets;
+ this.selectedByType = this.initialSelectedByType(meta);
this.$nextTick(() => (this.metaChanging = false));
},
},
@@ -151,22 +130,45 @@ export default {
this.meta.showFirstChildOption ? { label: __('First Child'), value: 'first-child' } : null,
- { label: __('Entry'), value: 'entry' },
-
- this.meta.showAssetOption ? { label: __('Asset'), value: 'asset', maxFiles: 1 } : null,
+ ...Object.entries(this.meta.types).map(([handle, type]) => ({ label: type.title, value: handle })),
].filter((option) => option);
},
- entriesSelected(entries) {
- this.selectedEntries = entries;
- this.update(this.entryValue);
- this.updateMeta({ ...this.meta, initialSelectedEntries: entries });
+ initialSelectedByType(meta) {
+ return Object.fromEntries(
+ Object.entries(meta.types).map(([handle, type]) => [handle, type.selected])
+ );
+ },
+
+ openTypeSelector() {
+ const field = this.$refs.typeField;
+
+ if (!field) return;
+
+ if (typeof field.linkExistingItem === 'function') field.linkExistingItem();
+ else if (typeof field.openSelector === 'function') field.openSelector();
+ },
+
+ typeSelected(selected) {
+ this.selectedByType = { ...this.selectedByType, [this.option]: selected };
+ this.update(this.typeValue);
+ this.updateMeta({
+ ...this.meta,
+ types: {
+ ...this.meta.types,
+ [this.option]: { ...this.meta.types[this.option], selected },
+ },
+ });
},
- assetsSelected(assets) {
- this.selectedAssets = assets;
- this.update(this.assetValue);
- this.updateMeta({ ...this.meta, initialSelectedAssets: assets });
+ updateTypeMeta(typeMeta) {
+ this.updateMeta({
+ ...this.meta,
+ types: {
+ ...this.meta.types,
+ [this.option]: { ...this.meta.types[this.option], meta: typeMeta },
+ },
+ });
},
},
};
diff --git a/resources/js/components/fieldtypes/LinkIndexFieldtype.vue b/resources/js/components/fieldtypes/LinkIndexFieldtype.vue
index 11a461df9bc..fe76aaf1d1e 100644
--- a/resources/js/components/fieldtypes/LinkIndexFieldtype.vue
+++ b/resources/js/components/fieldtypes/LinkIndexFieldtype.vue
@@ -7,10 +7,7 @@ const props = defineProps(IndexFieldtype.props);
-
-
-
-
+
diff --git a/resources/js/components/fieldtypes/bard/LinkToolbar.vue b/resources/js/components/fieldtypes/bard/LinkToolbar.vue
index 6edf6ad82ab..b4fd53535c6 100644
--- a/resources/js/components/fieldtypes/bard/LinkToolbar.vue
+++ b/resources/js/components/fieldtypes/bard/LinkToolbar.vue
@@ -3,13 +3,13 @@
-
+
-
-
-
-
-
-
![]()
-
{{ displayValue || __('Choose item...') }}
-
-
-
-
+
+
@@ -115,36 +92,6 @@
-
-
-
-
-
@@ -172,21 +119,21 @@