From a865ea62cadc17df8e36bd17687e4a3b6ed4a3ef Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 4 Nov 2024 12:58:11 -0500 Subject: [PATCH] ability to search for keywords --- resources/js/components/fields/FieldtypeSelector.vue | 5 +++-- src/Fields/Fieldtype.php | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/resources/js/components/fields/FieldtypeSelector.vue b/resources/js/components/fields/FieldtypeSelector.vue index 9fd80980c9..e006b427cc 100644 --- a/resources/js/components/fields/FieldtypeSelector.vue +++ b/resources/js/components/fields/FieldtypeSelector.vue @@ -99,7 +99,7 @@ export default { if (!this.fieldtypesLoaded) return []; let options = this.fieldtypes.map(fieldtype => { - return {text: fieldtype.title, value: fieldtype.handle, categories: fieldtype.categories, icon: fieldtype.icon}; + return {text: fieldtype.title, value: fieldtype.handle, categories: fieldtype.categories, keywords: fieldtype.keywords, icon: fieldtype.icon}; }); if (this.allowDate) options.unshift({text: __('Publish Date'), value: 'date', categories: ['system'], isMeta: true, icon: 'date'}); @@ -133,7 +133,8 @@ export default { threshold: 0.1, keys: [ {name: 'text', weight: 1}, - {name: 'categories', weight: 0.1} + {name: 'categories', weight: 0.1}, + {name: 'keywords', weight: 0.8}, ], }); diff --git a/src/Fields/Fieldtype.php b/src/Fields/Fieldtype.php index bdf18fa9ba..7fd86d79bf 100644 --- a/src/Fields/Fieldtype.php +++ b/src/Fields/Fieldtype.php @@ -29,6 +29,7 @@ abstract class Fieldtype implements Arrayable protected $selectableInForms = false; protected $relationship = false; protected $categories = []; + protected $keywords = []; protected $rules = []; protected $extraRules = []; protected $defaultValue; @@ -113,6 +114,11 @@ public function categories(): array return $this->categories; } + public function keywords(): array + { + return $this->keywords; + } + public function filter() { return new FieldtypeFilter($this); @@ -167,6 +173,7 @@ public function toArray(): array 'validatable' => $this->validatable(), 'defaultable' => $this->defaultable(), 'categories' => $this->categories(), + 'keywords' => $this->keywords(), 'icon' => $this->icon(), 'config' => $this->configFields()->toPublishArray(), ];