A free open source IT asset/license management system
Fixed selector and test for manager user selector
snipef24bfa967828
diff --git a/resources/views/blade/input/user-select.blade.php b/resources/views/blade/input/user-select.blade.phpindex 380f9b9b42..a324db480c 100644--- a/resources/views/blade/input/user-select.blade.php+++ b/resources/views/blade/input/user-select.blade.php@@ -2,13 +2,12 @@{{-- companyId scopes the ajax lookup to a specific company (viadata-company-ids consumed by the js-data-ajax initializer in- snipeit.js). excludeId hides a specific user from the list — used+ snipeit.js). excludeId hides a specific user from the list. Usedby the users/edit page's manager picker so a user can't select- themselves as their own manager. wrapperId and id default to the- legacy "assigned_user" / "assigned_user_select" values so pages- with JS that toggles #assigned_user (asset checkout target- picker) keep working after the migration off- partials.forms.edit.user-select. --}}+ themselves as their own manager. wrapperId and id default to+ values derived from the name prop, so a manager picker with+ name="manager_id" gets id="manager_id_select" and+ wrapperId="manager_id" automatically. --}}@props(['label','name',@@ -17,11 +16,16 @@'hideNewButton' => false,'companyId' => null,'excludeId' => null,- 'wrapperId' => 'assigned_user',- 'id' => 'assigned_user_select',+ 'wrapperId' => null,+ 'id' => null,'style' => null,])+@php+ $wrapperId = $wrapperId ?? $name;+ $id = $id ?? ($name.'_select');+@endphp+<divid="{{ $wrapperId }}"@class([diff --git a/tests/Feature/Locations/Ui/UpdateLocationsTest.php b/tests/Feature/Locations/Ui/UpdateLocationsTest.phpindex 0c07ccc35a..a2c2a5d42e 100644--- a/tests/Feature/Locations/Ui/UpdateLocationsTest.php+++ b/tests/Feature/Locations/Ui/UpdateLocationsTest.php@@ -30,12 +30,14 @@ class UpdateLocationsTest extends TestCasepublic function test_edit_page_ships_manager_select_and_submit_controls(){- // Regression guard for the migration off @include('partials.forms- // .edit.user-select') to <x-input.user-select>. The manager- // picker must still emit the assigned_user_select select id (the- // "+ New user" quick-create modal targets it via data-select), and- // the bottom cancel/save controls come from <x-box.footer /> which- // <x-box> renders when its parent <x-form> exposes a route.+ // Regression guard for the manager picker + submit controls on+ // the location edit page. The select id is derived from the+ // component's `name` prop, so a manager picker with+ // name="manager_id" gets id="manager_id_select" and the+ // "+ New user" quick-create modal targets that id via+ // data-select. The bottom cancel/save controls come from+ // <x-box.footer /> which <x-box> renders when its parent+ // <x-form> exposes a route.$manager = User::factory()->create();$location = Location::factory()->create(['manager_id' => $manager->id]);@@ -43,7 +45,7 @@ class UpdateLocationsTest extends TestCase->get(route('locations.edit', $location))->assertOk();- $response->assertSee('id="assigned_user_select"', false);+ $response->assertSee('id="manager_id_select"', false);$response->assertSee('name="manager_id"', false);$response->assertSee('value="'.$manager->id.'"', false);$response->assertSee('id="submit_button"', false);