Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADVAPP-244]: Introduce configuration of successful submission message for forms. #469

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 47 additions & 5 deletions _ide_helper_models.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ class IdeHelperTenant {}
* @property-read int|null $care_teams_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \AdvisingApp\CaseloadManagement\Models\Caseload> $caseloads
* @property-read int|null $caseloads_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \AdvisingApp\ServiceManagement\Models\ChangeRequestResponse> $changeRequestResponses
* @property-read int|null $change_request_responses_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \AdvisingApp\ServiceManagement\Models\ChangeRequestType> $changeRequestTypes
* @property-read int|null $change_request_types_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \AdvisingApp\ServiceManagement\Models\ChangeRequest> $changeRequests
Expand Down Expand Up @@ -1809,6 +1811,7 @@ class IdeHelperSmsTemplate {}
* @property bool $is_wizard
* @property bool $recaptcha_enabled
* @property array|null $content
* @property string|null $on_screen_response
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $deleted_at
Expand All @@ -1832,6 +1835,7 @@ class IdeHelperSmsTemplate {}
* @method static \Illuminate\Database\Eloquent\Builder|Form whereIsAuthenticated($value)
* @method static \Illuminate\Database\Eloquent\Builder|Form whereIsWizard($value)
* @method static \Illuminate\Database\Eloquent\Builder|Form whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|Form whereOnScreenResponse($value)
* @method static \Illuminate\Database\Eloquent\Builder|Form wherePrimaryColor($value)
* @method static \Illuminate\Database\Eloquent\Builder|Form whereRecaptchaEnabled($value)
* @method static \Illuminate\Database\Eloquent\Builder|Form whereRounding($value)
Expand Down Expand Up @@ -2646,10 +2650,10 @@ class IdeHelperKnowledgeBaseCategory {}
* AdvisingApp\KnowledgeBase\Models\KnowledgeBaseItem
*
* @property string $id
* @property string $question
* @property bool $public
* @property array|null $solution
* @property array|null $notes
* @property string $title
* @property array|null $article_details
* @property string|null $notes
* @property string|null $quality_id
* @property string|null $status_id
* @property string|null $category_id
Expand All @@ -2668,15 +2672,15 @@ class IdeHelperKnowledgeBaseCategory {}
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem query()
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereArticleDetails($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereCategoryId($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereNotes($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem wherePublic($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereQualityId($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereQuestion($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereSolution($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereStatusId($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereTitle($value)
* @method static \Illuminate\Database\Eloquent\Builder|KnowledgeBaseItem whereUpdatedAt($value)
* @mixin \Eloquent
*/
Expand Down Expand Up @@ -3337,8 +3341,12 @@ class IdeHelperProspectStatus {}
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, \AdvisingApp\ServiceManagement\Models\ChangeRequestResponse> $approvals
* @property-read int|null $approvals_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \AdvisingApp\Audit\Models\Audit> $audits
* @property-read int|null $audits_count
* @property-read \Illuminate\Database\Eloquent\Collection<int, \AdvisingApp\ServiceManagement\Models\ChangeRequestResponse> $responses
* @property-read int|null $responses_count
* @property-read \AdvisingApp\ServiceManagement\Models\ChangeRequestStatus $status
* @property-read \AdvisingApp\ServiceManagement\Models\ChangeRequestType $type
* @property-read \App\Models\User|null $user
Expand Down Expand Up @@ -3368,6 +3376,38 @@ class IdeHelperProspectStatus {}
class IdeHelperChangeRequest {}
}

namespace AdvisingApp\ServiceManagement\Models{
/**
* AdvisingApp\ServiceManagement\Models\ChangeRequestResponse
*
* @property string $id
* @property string $change_request_id
* @property string $user_id
* @property bool $approved
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property string|null $deleted_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, \AdvisingApp\Audit\Models\Audit> $audits
* @property-read int|null $audits_count
* @property-read \AdvisingApp\ServiceManagement\Models\ChangeRequest $changeRequest
* @property-read \App\Models\User $user
* @method static \AdvisingApp\ServiceManagement\Database\Factories\ChangeRequestResponseFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestResponse newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestResponse newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestResponse query()
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestResponse whereApproved($value)
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestResponse whereChangeRequestId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestResponse whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestResponse whereDeletedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestResponse whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestResponse whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestResponse whereUserId($value)
* @mixin \Eloquent
*/
#[\AllowDynamicProperties]
class IdeHelperChangeRequestResponse {}
}

namespace AdvisingApp\ServiceManagement\Models{
/**
* AdvisingApp\ServiceManagement\Models\ChangeRequestStatus
Expand Down Expand Up @@ -3400,6 +3440,7 @@ class IdeHelperChangeRequestStatus {}
*
* @property string $id
* @property string $name
* @property int $number_of_required_approvals
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, \AdvisingApp\Audit\Models\Audit> $audits
Expand All @@ -3415,6 +3456,7 @@ class IdeHelperChangeRequestStatus {}
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestType whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestType whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestType whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestType whereNumberOfRequiredApprovals($value)
* @method static \Illuminate\Database\Eloquent\Builder|ChangeRequestType whereUpdatedAt($value)
* @mixin \Eloquent
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function up(): void
$table->boolean('is_wizard')->default(false);
$table->boolean('recaptcha_enabled')->default(false);
$table->json('content')->nullable();
$table->text('on_screen_response')->nullable();

$table->timestamps();
$table->softDeletes();
Expand Down
3 changes: 3 additions & 0 deletions app-modules/form/src/Filament/Resources/FormResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use AdvisingApp\Form\Filament\Resources\FormResource\Pages\ListForms;
use AdvisingApp\Form\Filament\Resources\FormResource\Pages\CreateForm;
use AdvisingApp\Form\Filament\Resources\FormResource\Pages\ManageFormSubmissions;
use AdvisingApp\Form\Filament\Resources\FormResource\Pages\SubmissionOnScreenResponse;

class FormResource extends Resource
{
Expand Down Expand Up @@ -72,6 +73,7 @@ public static function getRecordSubNavigation(Page $page): array
{
return $page->generateNavigationItems([
EditForm::class,
SubmissionOnScreenResponse::class,
ManageFormSubmissions::class,
]);
}
Expand All @@ -82,6 +84,7 @@ public static function getPages(): array
'index' => ListForms::route('/'),
'create' => CreateForm::route('/create'),
'edit' => EditForm::route('/{record}/edit'),
'manage-on-screen-response' => SubmissionOnScreenResponse::route('/{record}/on-screen-response'),
'manage-submissions' => ManageFormSubmissions::route('/{record}/submissions'),
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

/*
<COPYRIGHT>

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.

</COPYRIGHT>
*/

namespace AdvisingApp\Form\Filament\Resources\FormResource\Pages;

use Filament\Forms\Form as FilamentForm;
use Filament\Resources\Pages\EditRecord;
use Filament\Forms\Components\MarkdownEditor;
use AdvisingApp\Form\Filament\Resources\FormResource;

class SubmissionOnScreenResponse extends EditRecord
{
protected static string $resource = FormResource::class;

protected static ?string $navigationLabel = 'On-Screen Response';

protected static ?string $navigationIcon = 'heroicon-o-bars-arrow-up';

public function form(FilamentForm $form): FilamentForm
{
return $form
->schema(
[
MarkdownEditor::make('on_screen_response')
->disableToolbarButtons(['attachFiles']),
]
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function view(GenerateFormKitSchema $generateSchema, Form $form): JsonRes
'schema' => $generateSchema($form),
'primary_color' => Color::all()[$form->primary_color ?? 'blue'],
'rounding' => $form->rounding,
'on_screen_response' => $form->on_screen_response,
],
);
}
Expand Down
1 change: 1 addition & 0 deletions app-modules/form/src/Models/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Form extends Submissible
'primary_color',
'rounding',
'content',
'on_screen_response',
];

protected $casts = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use AdvisingApp\Audit\Models\Concerns\Auditable as AuditableTrait;

/**
* @mixin IdeHelperChangeRequestResponse
*/
class ChangeRequestResponse extends BaseModel implements Auditable
{
use AuditableTrait;
Expand Down
20 changes: 16 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build:survey": "(cd widgets/survey && vite build)",
"build:event-registration": "(cd widgets/event-registration && vite build)",
"build": "npm run build:js-compile && npm run build:vite && npm run build:filament && npm run build:application && npm run build:form && npm run build:survey && npm run build:event-registration",
"api-docs:generate": "export NODE_OPTIONS=--max_old_space_size=4096 && env-cmd spectaql spectaql.yml"
"api-docs:generate": "export NODE_OPTIONS=--max_old_space_size=4096 && env-cmd spectaql spectaql.yml"
},
"devDependencies": {
"@headlessui/vue": "^1.7.16",
Expand Down Expand Up @@ -50,6 +50,7 @@
"env-cmd": "^10.1.0",
"esbuild-plugin-polyfill-node": "^0.3.0",
"flowbite": "^1.8.1",
"marked": "^11.1.1",
"showdown": "^2.1.0",
"sortablejs": "^1.15.0",
"spectaql": "^2.3.0",
Expand Down
10 changes: 8 additions & 2 deletions widgets/form/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
</COPYRIGHT>
-->
<script setup>
import { defineProps, ref, reactive, onMounted } from 'vue';
import { defineProps, onMounted, reactive, ref } from 'vue';
import wizard from './FormKit/wizard';
import attachRecaptchaScript from '../../../app-modules/integration-google-recaptcha/resources/js/Services/AttachRecaptchaScript.js';
import getRecaptchaToken from '../../../app-modules/integration-google-recaptcha/resources/js/Services/GetRecaptchaToken.js';
import { marked } from 'marked';
import DOMPurify from 'dompurify';

onMounted(async () => {
await getForm().then(function () {
Expand Down Expand Up @@ -126,6 +128,7 @@ const formPrimaryColor = ref('');
const formRounding = ref('');
const formRecaptchaEnabled = ref(false);
const formRecaptchaKey = ref(null);
const onScreenResponse = ref(null);
const schema = ref([]);

const authentication = ref({
Expand Down Expand Up @@ -194,6 +197,8 @@ async function getForm() {
},
}[json.rounding ?? 'md'];

onScreenResponse.value = json.on_screen_response ?? null;

display.value = true;
})
.catch((error) => {
Expand Down Expand Up @@ -351,7 +356,8 @@ async function authenticate(formData, node) {
</div>

<div v-if="submittedSuccess">
<h1 class="text-2xl font-bold mb-2 text-center">Thank you, your submission has been received.</h1>
<div v-if="onScreenResponse" v-html="DOMPurify.sanitize(marked.parse(onScreenResponse))"></div>
<h1 v-else class="text-2xl font-bold mb-2 text-center">Thank you, your submission has been received.</h1>
</div>
</div>
</template>