Skip to content

Commit

Permalink
works now
Browse files Browse the repository at this point in the history
  • Loading branch information
edalzell committed Mar 2, 2025
1 parent 015086e commit bfac336
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
19 changes: 17 additions & 2 deletions resources/js/components/fieldtypes/LinkFieldtype.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default {
option: this.meta.initialOption,
options: this.initialOptions(),
urlValue: this.meta.initialUrl,
urlData: [],
urlData: this.meta.initialUrlOptions,
urlOptions: ['no-follow', 'no-rel'],
selectedEntries: this.meta.initialSelectedEntries,
selectedAssets: this.meta.initialSelectedAssets,
Expand Down Expand Up @@ -141,10 +141,25 @@ export default {
this.updateMeta({...this.meta, initialOption: option});
},
urlData(data) {
if (data.length > 0) {
this.update({options: this.urlData, value: this.urlValue})
this.updateMeta({...this.meta, initialUrlOptions: data});
} else {
this.update(this.urlValue)
this.updateMeta({...this.meta, initialUrlOptions: null});
}
},
urlValue(url) {
if (this.metaChanging) return;
this.update(url);
if (this.urlData.length > 0) {
this.update({options: this.urlData, value: url});
} else {
this.update(url);
}
this.updateMeta({...this.meta, initialUrl: url});
},
Expand Down
7 changes: 6 additions & 1 deletion src/Fieldtypes/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public function augment($value)

public function preload()
{
$value = is_array($data = $this->field->value()) ? $data['value'] : $data;
$urlOptions = null;
if (is_array($value = $this->field->value())) {
$urlOptions = $value['options'];
$value = $value['value'];
}

$showAssetOption = $this->showAssetOption();

Expand All @@ -72,6 +76,7 @@ public function preload()
'initialSelectedEntries' => $selectedEntry ? [$selectedEntry] : [],
'initialSelectedAssets' => $selectedAsset ? [$selectedAsset] : [],
'initialOption' => $this->initialOption($value, $selectedEntry, $selectedAsset),
'initialUrlOptions' => $urlOptions ?? null,
'showFirstChildOption' => $this->showFirstChildOption(),
'showAssetOption' => $showAssetOption,
'entry' => [
Expand Down

0 comments on commit bfac336

Please sign in to comment.