From 54f54fe938e80418a82bb4731d40303432ea4ae0 Mon Sep 17 00:00:00 2001 From: Derek Goetz Date: Wed, 3 Jan 2024 09:35:34 -0500 Subject: [PATCH 1/2] Register survey field blocks. --- .../Blocks/CheckboxSurveyFieldBlock.php | 47 ++++++++++++ .../Filament/Blocks/RadioSurveyFieldBlock.php | 47 ++++++++++++ .../Blocks/SelectSurveyFieldBlock.php | 47 ++++++++++++ .../Blocks/SurveyFieldBlockRegistry.php | 72 +++++++++++++++++++ .../Blocks/TextAreaSurveyFieldBlock.php | 47 ++++++++++++ .../Blocks/TextInputSurveyFieldBlock.php | 47 ++++++++++++ .../Concerns/HasSharedFormConfiguration.php | 4 +- 7 files changed, 309 insertions(+), 2 deletions(-) create mode 100644 app-modules/survey/src/Filament/Blocks/CheckboxSurveyFieldBlock.php create mode 100644 app-modules/survey/src/Filament/Blocks/RadioSurveyFieldBlock.php create mode 100644 app-modules/survey/src/Filament/Blocks/SelectSurveyFieldBlock.php create mode 100644 app-modules/survey/src/Filament/Blocks/SurveyFieldBlockRegistry.php create mode 100644 app-modules/survey/src/Filament/Blocks/TextAreaSurveyFieldBlock.php create mode 100644 app-modules/survey/src/Filament/Blocks/TextInputSurveyFieldBlock.php diff --git a/app-modules/survey/src/Filament/Blocks/CheckboxSurveyFieldBlock.php b/app-modules/survey/src/Filament/Blocks/CheckboxSurveyFieldBlock.php new file mode 100644 index 0000000000..7e8671763e --- /dev/null +++ b/app-modules/survey/src/Filament/Blocks/CheckboxSurveyFieldBlock.php @@ -0,0 +1,47 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\Survey\Filament\Blocks; + +use AdvisingApp\Form\Filament\Blocks\CheckboxFormFieldBlock; + +class CheckboxSurveyFieldBlock extends CheckboxFormFieldBlock +{ + public static function type(): string + { + return 'multiple_choice'; + } +} diff --git a/app-modules/survey/src/Filament/Blocks/RadioSurveyFieldBlock.php b/app-modules/survey/src/Filament/Blocks/RadioSurveyFieldBlock.php new file mode 100644 index 0000000000..c7df3e74e7 --- /dev/null +++ b/app-modules/survey/src/Filament/Blocks/RadioSurveyFieldBlock.php @@ -0,0 +1,47 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\Survey\Filament\Blocks; + +use AdvisingApp\Form\Filament\Blocks\RadioFormFieldBlock; + +class RadioSurveyFieldBlock extends RadioFormFieldBlock +{ + public static function type(): string + { + return 'choice_(radio)'; + } +} diff --git a/app-modules/survey/src/Filament/Blocks/SelectSurveyFieldBlock.php b/app-modules/survey/src/Filament/Blocks/SelectSurveyFieldBlock.php new file mode 100644 index 0000000000..1f6152f801 --- /dev/null +++ b/app-modules/survey/src/Filament/Blocks/SelectSurveyFieldBlock.php @@ -0,0 +1,47 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\Survey\Filament\Blocks; + +use AdvisingApp\Form\Filament\Blocks\SelectFormFieldBlock; + +class SelectSurveyFieldBlock extends SelectFormFieldBlock +{ + public static function type(): string + { + return 'choice_(dropdown)'; + } +} diff --git a/app-modules/survey/src/Filament/Blocks/SurveyFieldBlockRegistry.php b/app-modules/survey/src/Filament/Blocks/SurveyFieldBlockRegistry.php new file mode 100644 index 0000000000..2b37c5e8ff --- /dev/null +++ b/app-modules/survey/src/Filament/Blocks/SurveyFieldBlockRegistry.php @@ -0,0 +1,72 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\Survey\Filament\Blocks; + +use AdvisingApp\Form\Filament\Blocks\EmailFormFieldBlock; +use AdvisingApp\Form\Filament\Blocks\NumberFormFieldBlock; +use AdvisingApp\Form\Filament\Blocks\EducatableEmailFormFieldBlock; + +class SurveyFieldBlockRegistry +{ + /** + * @return array> + */ + public static function get(): array + { + return [ + EducatableEmailFormFieldBlock::class, + TextInputSurveyFieldBlock::class, + TextAreaSurveyFieldBlock::class, + SelectSurveyFieldBlock::class, + RadioSurveyFieldBlock::class, + CheckboxSurveyFieldBlock::class, + EmailFormFieldBlock::class, + NumberFormFieldBlock::class, + ]; + } + + /** + * @return array> + */ + public static function keyByType(): array + { + /** @var FormFieldBlock $block */ + return collect(static::get()) + ->mapWithKeys(fn (string $block): array => [$block::type() => $block]) + ->all(); + } +} diff --git a/app-modules/survey/src/Filament/Blocks/TextAreaSurveyFieldBlock.php b/app-modules/survey/src/Filament/Blocks/TextAreaSurveyFieldBlock.php new file mode 100644 index 0000000000..b6a38e8a03 --- /dev/null +++ b/app-modules/survey/src/Filament/Blocks/TextAreaSurveyFieldBlock.php @@ -0,0 +1,47 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\Survey\Filament\Blocks; + +use AdvisingApp\Form\Filament\Blocks\TextAreaFormFieldBlock; + +class TextAreaSurveyFieldBlock extends TextAreaFormFieldBlock +{ + public static function type(): string + { + return 'question_(multi-line)'; + } +} diff --git a/app-modules/survey/src/Filament/Blocks/TextInputSurveyFieldBlock.php b/app-modules/survey/src/Filament/Blocks/TextInputSurveyFieldBlock.php new file mode 100644 index 0000000000..17e0628bfc --- /dev/null +++ b/app-modules/survey/src/Filament/Blocks/TextInputSurveyFieldBlock.php @@ -0,0 +1,47 @@ + + + Copyright © 2022-2023, Canyon GBS LLC. All rights reserved. + + Advising App™ is licensed under the Elastic License 2.0. For more details, + see https://github.com/canyongbs/advisingapp/blob/main/LICENSE. + + Notice: + + - You may not provide the software to third parties as a hosted or managed + service, where the service provides users with access to any substantial set of + the features or functionality of the software. + - You may not move, change, disable, or circumvent the license key functionality + in the software, and you may not remove or obscure any functionality in the + software that is protected by the license key. + - You may not alter, remove, or obscure any licensing, copyright, or other notices + of the licensor in the software. Any use of the licensor’s trademarks is subject + to applicable law. + - Canyon GBS LLC respects the intellectual property rights of others and expects the + same in return. Canyon GBS™ and Advising App™ are registered trademarks of + Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks + vigorously. + - The software solution, including services, infrastructure, and code, is offered as a + Software as a Service (SaaS) by Canyon GBS LLC. + - Use of this software implies agreement to the license terms and conditions as stated + in the Elastic License 2.0. + + For more information or inquiries please visit our website at + https://www.canyongbs.com or contact us via email at legal@canyongbs.com. + + +*/ + +namespace AdvisingApp\Survey\Filament\Blocks; + +use AdvisingApp\Form\Filament\Blocks\TextInputFormFieldBlock; + +class TextInputSurveyFieldBlock extends TextInputFormFieldBlock +{ + public static function type(): string + { + return 'question_(single_line)'; + } +} diff --git a/app-modules/survey/src/Filament/Resources/SurveyResource/Pages/Concerns/HasSharedFormConfiguration.php b/app-modules/survey/src/Filament/Resources/SurveyResource/Pages/Concerns/HasSharedFormConfiguration.php index 8999527271..332948559d 100644 --- a/app-modules/survey/src/Filament/Resources/SurveyResource/Pages/Concerns/HasSharedFormConfiguration.php +++ b/app-modules/survey/src/Filament/Resources/SurveyResource/Pages/Concerns/HasSharedFormConfiguration.php @@ -53,8 +53,8 @@ use AdvisingApp\Survey\Models\SurveyStep; use AdvisingApp\Survey\Models\SurveyField; use FilamentTiptapEditor\Enums\TiptapOutput; -use AdvisingApp\Form\Filament\Blocks\FormFieldBlockRegistry; use Illuminate\Database\Eloquent\Builder as EloquentBuilder; +use AdvisingApp\Survey\Filament\Blocks\SurveyFieldBlockRegistry; use AdvisingApp\IntegrationGoogleRecaptcha\Settings\GoogleRecaptchaSettings; trait HasSharedFormConfiguration @@ -146,7 +146,7 @@ public function fieldBuilder(): TiptapEditor { return TiptapEditor::make('content') ->output(TiptapOutput::Json) - ->blocks(FormFieldBlockRegistry::get()) + ->blocks(SurveyFieldBlockRegistry::get()) ->tools(['bold', 'italic', 'small', '|', 'heading', 'bullet-list', 'ordered-list', 'hr', '|', 'link', 'grid', 'blocks']) ->placeholder('Drag blocks here to build your survey') ->hiddenLabel() From 4129bad99a8560d5874ca4fa928fc22d9b75bb5e Mon Sep 17 00:00:00 2001 From: Derek Goetz Date: Wed, 3 Jan 2024 09:57:46 -0500 Subject: [PATCH 2/2] Update field labels. --- .../survey/src/Filament/Blocks/CheckboxSurveyFieldBlock.php | 4 ++-- .../survey/src/Filament/Blocks/RadioSurveyFieldBlock.php | 4 ++-- .../survey/src/Filament/Blocks/SelectSurveyFieldBlock.php | 4 ++-- .../survey/src/Filament/Blocks/TextAreaSurveyFieldBlock.php | 4 ++-- .../survey/src/Filament/Blocks/TextInputSurveyFieldBlock.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app-modules/survey/src/Filament/Blocks/CheckboxSurveyFieldBlock.php b/app-modules/survey/src/Filament/Blocks/CheckboxSurveyFieldBlock.php index 7e8671763e..6b5e23ae58 100644 --- a/app-modules/survey/src/Filament/Blocks/CheckboxSurveyFieldBlock.php +++ b/app-modules/survey/src/Filament/Blocks/CheckboxSurveyFieldBlock.php @@ -40,8 +40,8 @@ class CheckboxSurveyFieldBlock extends CheckboxFormFieldBlock { - public static function type(): string + public function getLabel(): string { - return 'multiple_choice'; + return 'Multiple Choice'; } } diff --git a/app-modules/survey/src/Filament/Blocks/RadioSurveyFieldBlock.php b/app-modules/survey/src/Filament/Blocks/RadioSurveyFieldBlock.php index c7df3e74e7..3b92ba8995 100644 --- a/app-modules/survey/src/Filament/Blocks/RadioSurveyFieldBlock.php +++ b/app-modules/survey/src/Filament/Blocks/RadioSurveyFieldBlock.php @@ -40,8 +40,8 @@ class RadioSurveyFieldBlock extends RadioFormFieldBlock { - public static function type(): string + public function getLabel(): string { - return 'choice_(radio)'; + return 'Choice (Radio)'; } } diff --git a/app-modules/survey/src/Filament/Blocks/SelectSurveyFieldBlock.php b/app-modules/survey/src/Filament/Blocks/SelectSurveyFieldBlock.php index 1f6152f801..b700e2eb82 100644 --- a/app-modules/survey/src/Filament/Blocks/SelectSurveyFieldBlock.php +++ b/app-modules/survey/src/Filament/Blocks/SelectSurveyFieldBlock.php @@ -40,8 +40,8 @@ class SelectSurveyFieldBlock extends SelectFormFieldBlock { - public static function type(): string + public function getLabel(): string { - return 'choice_(dropdown)'; + return 'Choice (Dropdown)'; } } diff --git a/app-modules/survey/src/Filament/Blocks/TextAreaSurveyFieldBlock.php b/app-modules/survey/src/Filament/Blocks/TextAreaSurveyFieldBlock.php index b6a38e8a03..b713bd9a90 100644 --- a/app-modules/survey/src/Filament/Blocks/TextAreaSurveyFieldBlock.php +++ b/app-modules/survey/src/Filament/Blocks/TextAreaSurveyFieldBlock.php @@ -40,8 +40,8 @@ class TextAreaSurveyFieldBlock extends TextAreaFormFieldBlock { - public static function type(): string + public function getLabel(): string { - return 'question_(multi-line)'; + return 'Question (Multi-Line)'; } } diff --git a/app-modules/survey/src/Filament/Blocks/TextInputSurveyFieldBlock.php b/app-modules/survey/src/Filament/Blocks/TextInputSurveyFieldBlock.php index 17e0628bfc..d414fb092e 100644 --- a/app-modules/survey/src/Filament/Blocks/TextInputSurveyFieldBlock.php +++ b/app-modules/survey/src/Filament/Blocks/TextInputSurveyFieldBlock.php @@ -40,8 +40,8 @@ class TextInputSurveyFieldBlock extends TextInputFormFieldBlock { - public static function type(): string + public function getLabel(): string { - return 'question_(single_line)'; + return 'Question (Single Line)'; } }