Edit Link now defaults to current link instead of "custom"

If a link is edited on the edit-link section, the default button selection now has the current button selected rather than the custom button.

@bonelifer

https://github.com/JulianPrieber/littlelink-custom/issues/113
This commit is contained in:
Julian Prieber 2022-07-31 13:35:52 +02:00
parent 66ac92087a
commit 38c471ec61
2 changed files with 6 additions and 2 deletions

View File

@ -207,10 +207,11 @@ class UserController extends Controller
$order = Link::where('id', $linkId)->value('order'); $order = Link::where('id', $linkId)->value('order');
$custom_css = Link::where('id', $linkId)->value('custom_css'); $custom_css = Link::where('id', $linkId)->value('custom_css');
$buttonId = Link::where('id', $linkId)->value('button_id'); $buttonId = Link::where('id', $linkId)->value('button_id');
$buttonName = Button::where('id', $buttonId)->value('name');
$buttons = Button::select('id', 'name')->get(); $buttons = Button::select('id', 'name')->get();
return view('studio/edit-link', ['custom_css' => $custom_css, 'buttonId' => $buttonId, 'buttons' => $buttons, 'link' => $link, 'title' => $title, 'order' => $order, 'id' => $linkId]); return view('studio/edit-link', ['custom_css' => $custom_css, 'buttonId' => $buttonId, 'buttons' => $buttons, 'link' => $link, 'title' => $title, 'order' => $order, 'id' => $linkId , 'buttonName' => $buttonName]);
} }

View File

@ -17,8 +17,11 @@
<div class="form-group col-lg-8"> <div class="form-group col-lg-8">
<label for="exampleFormControlSelect1">Button</label> <label for="exampleFormControlSelect1">Button</label>
<select class="form-control" name="button"> <select class="form-control" name="button">
<option> {{ $buttonName }} </option>
@foreach($buttons as $button) @foreach($buttons as $button)
<option <?= ($buttonId === $button->id) ? 'selected' : '' ?>> {{ $button->name }} </option> @if ($button->name != $buttonName)
<option> {{ $button->name }} </option>
@endif
@endforeach @endforeach
</select> </select>
</div> </div>