Skip to content

Commit

Permalink
Select correct initial option (#3637)
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurperton committed May 5, 2021
1 parent f9f51a3 commit 3c0e61d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions resources/js/components/fieldtypes/LinkFieldtype.vue
Expand Up @@ -89,37 +89,39 @@ export default {
created() {
this.options = this.initialOptions();
if (! this.value) {
this.option = this.config.required ? 'url' : null;
return;
}
if (this.value === '@child') {
this.option = 'first-child';
} else if (this.value && this.value.startsWith('entry::')) {
} else if (this.value.startsWith('entry::')) {
this.option = 'entry';
this.selectedEntries = [this.value.substr(7)];
} else {
this.urlValue = this.value;
}
if (this.config.required && this.option === null) {
this.option = 'url';
this.urlValue = this.value;
}
},
methods: {
initialOptions() {
return [
this.config.required
? null
: { label: __('None'), value: null },
{ label: __('URL'), value: 'url' },
this.meta.showFirstChildOption
? { label: __('First Child'), value: 'first-child' }
: null,
{ label: __('Entry'), value: 'entry' }
].filter(option => option);
},
Expand Down

0 comments on commit 3c0e61d

Please sign in to comment.