From 4fd103d4ba395cdaa5e18fcfc51f4f9dd0ff7c56 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 13 Dec 2023 10:38:54 +1300 Subject: [PATCH] ENH Use SearchableMultiDropdownField to select Members --- code/Model/SiteTree.php | 25 ++++++++++--------------- composer.json | 2 +- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 42b516a931..a17a0006ec 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -38,6 +38,7 @@ use SilverStripe\Forms\ListboxField; use SilverStripe\Forms\LiteralField; use SilverStripe\Forms\OptionsetField; +use SilverStripe\Forms\SearchableMultiDropdownField; use SilverStripe\Forms\Tab; use SilverStripe\Forms\TabSet; use SilverStripe\Forms\TextareaField; @@ -2256,16 +2257,6 @@ public function getSettingsFields() $viewAllGroupsMap = $mapFn(Permission::get_groups_by_permission(['SITETREE_VIEW_ALL', 'ADMIN'])); $editAllGroupsMap = $mapFn(Permission::get_groups_by_permission(['SITETREE_EDIT_ALL', 'ADMIN'])); - // $membersMap is limited to 100 records specifically so that it does not crash the front-end - // if the website has a large number of Members, which is likely to happen if the website also - // uses the Member table for non-cms public users - // This limit should be removed if the ListboxField front-end component is switched out or - // modified so that it does not load all users at once and instead uses XHR to fetch a subset - // of users based on what the user types in - $membersMap = Member::get() - ->limit(100) - ->map('ID', 'Name'); - $fields = new FieldList( $rootTab = new TabSet( "Root", @@ -2296,11 +2287,13 @@ public function getSettingsFields() _t(__CLASS__.'.VIEWERGROUPS', "Viewer Groups"), Group::class ), - $viewerMembersField = ListboxField::create( + $viewerMembersField = SearchableMultiDropdownField::create( "ViewerMembers", _t(__CLASS__.'.VIEWERMEMBERS', "Viewer Users"), - $membersMap, - ), + Member::get(), + ) + ->setIsLazyLoaded(true) + ->setUseSearchContext(true), $editorsOptionsField = new OptionsetField( "CanEditType", _t(__CLASS__.'.EDITHEADER', "Who can edit this page?") @@ -2310,11 +2303,13 @@ public function getSettingsFields() _t(__CLASS__.'.EDITORGROUPS', "Editor Groups"), Group::class ), - $editorMembersField = ListboxField::create( + $editorMembersField = SearchableMultiDropdownField::create( "EditorMembers", _t(__CLASS__.'.EDITORMEMBERS', "Editor Users"), - $membersMap + Member::get() ) + ->setIsLazyLoaded(true) + ->setUseSearchContext(true) ) ) ); diff --git a/composer.json b/composer.json index 0fd74df259..4fbc5c5559 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php": "^8.1", "silverstripe/admin": "^2", "silverstripe/campaign-admin": "^2", - "silverstripe/framework": "^5.1", + "silverstripe/framework": "^5.2", "silverstripe/reports": "^5", "silverstripe/siteconfig": "^5", "silverstripe/versioned": "^2",