From 5c4fc70a8957e3f455f8a11bab47947f989217ba Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Wed, 12 Jun 2024 13:49:54 +0200 Subject: [PATCH] Add `external_uuid` column to Contact/Contactgroup model Only show this column in the search column suggestions if explicitly specified --- library/Notifications/Model/Contact.php | 8 +++++--- library/Notifications/Model/Contactgroup.php | 8 ++++++-- .../Web/Control/SearchBar/ObjectSuggestions.php | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/library/Notifications/Model/Contact.php b/library/Notifications/Model/Contact.php index 5db9ef417..633429bcb 100644 --- a/library/Notifications/Model/Contact.php +++ b/library/Notifications/Model/Contact.php @@ -26,15 +26,17 @@ public function getColumns(): array return [ 'full_name', 'username', - 'default_channel_id' + 'default_channel_id', + 'external_uuid' ]; } public function getColumnDefinitions() { return [ - 'full_name' => t('Full Name'), - 'username' => t('Username') + 'full_name' => t('Full Name'), + 'username' => t('Username'), + 'external_uuid' => t('UUID') ]; } diff --git a/library/Notifications/Model/Contactgroup.php b/library/Notifications/Model/Contactgroup.php index aac6ab6db..eae37b358 100644 --- a/library/Notifications/Model/Contactgroup.php +++ b/library/Notifications/Model/Contactgroup.php @@ -33,13 +33,17 @@ public function getKeyName(): string public function getColumns(): array { return [ - 'name' + 'name', + 'external_uuid' ]; } public function getColumnDefinitions(): array { - return ['name' => t('Name')]; + return [ + 'name' => t('Name'), + 'external_uuid' => t('UUID') + ]; } public function getSearchColumns(): array diff --git a/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php b/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php index 6ca9b208c..956bd378c 100644 --- a/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Notifications/Web/Control/SearchBar/ObjectSuggestions.php @@ -231,7 +231,7 @@ protected function queryTags(Model $model, string $searchTerm): Query protected function matchSuggestion($path, $label, $searchTerm) { - if (preg_match('/[_.](id)$/', $path)) { + if (preg_match('/[_.](id|uuid)$/', $path)) { // Only suggest exotic columns if the user knows about them $trimmedSearch = trim($searchTerm, ' *'); return substr($path, -strlen($trimmedSearch)) === $trimmedSearch;