From 4d5c62859d834625967c1a1ae786366918e781fc Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Thu, 21 Nov 2024 14:43:03 -0500 Subject: [PATCH] - add prompt translation - make whole field clickable to open the record finder form --- modules/backend/formwidgets/RecordFinder.php | 6 +++++- .../formwidgets/recordfinder/partials/_recordfinder.php | 8 +++++++- modules/backend/lang/en/lang.php | 1 + modules/backend/lang/fr/lang.php | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/backend/formwidgets/RecordFinder.php b/modules/backend/formwidgets/RecordFinder.php index 982e12dc01..0e5799cf0d 100644 --- a/modules/backend/formwidgets/RecordFinder.php +++ b/modules/backend/formwidgets/RecordFinder.php @@ -60,7 +60,7 @@ class RecordFinder extends FormWidgetBase /** * @var string Prompt to display if no record is selected. */ - public $prompt = 'Click the %s button to find a record'; + public $prompt = null; /** * @var int Maximum rows to display for each page. @@ -144,6 +144,10 @@ public function init() 'modelClass', ]); + if (!isset($this->prompt)) { + $this->prompt = Lang::get('backend::lang.recordfinder.default_prompt'); + } + if (!$this->useRelation && !class_exists($this->modelClass)) { throw new ApplicationException(Lang::get('backend::lang.recordfinder.invalid_model_class', ['modelClass' => $this->modelClass])); } diff --git a/modules/backend/formwidgets/recordfinder/partials/_recordfinder.php b/modules/backend/formwidgets/recordfinder/partials/_recordfinder.php index 79ad7f4fe9..3ad24d971a 100644 --- a/modules/backend/formwidgets/recordfinder/partials/_recordfinder.php +++ b/modules/backend/formwidgets/recordfinder/partials/_recordfinder.php @@ -10,7 +10,13 @@ class="field-recordfinder loading-indicator-container size-input-text" data-control="recordfinder" data-refresh-handler="getEventHandler('onRefresh') ?>" data-data-locker="#getId() ?>"> - > + + data-control="popup" + data-size="huge" + data-handler="getEventHandler('onFindRecord') ?>" + data-request-data="recordfinder_flag: 1" + > diff --git a/modules/backend/lang/en/lang.php b/modules/backend/lang/en/lang.php index 83fabed70e..5c1a96f55b 100644 --- a/modules/backend/lang/en/lang.php +++ b/modules/backend/lang/en/lang.php @@ -312,6 +312,7 @@ ], 'recordfinder' => [ 'find_record' => 'Find Record', + 'default_prompt' => 'Click the %s button to find a record', 'invalid_model_class' => 'The provided model class ":modelClass" for the recordfinder is invalid', 'cancel' => 'Cancel', ], diff --git a/modules/backend/lang/fr/lang.php b/modules/backend/lang/fr/lang.php index b0250c4d30..251d800c18 100644 --- a/modules/backend/lang/fr/lang.php +++ b/modules/backend/lang/fr/lang.php @@ -310,6 +310,7 @@ 'return_to_list' => 'Retourner à la liste' ], 'recordfinder' => [ + 'default_prompt' => 'Cliquer sur %s pour chercher un enregistrement', 'find_record' => 'Trouver un enregistrement', 'invalid_model_class' => "La classe du modèle \":modelClass\" fournie pour le recordfinder n'est pas valide.", 'cancel' => 'Annuler',