Skip to content

Commit

Permalink
Proponent feedback consent
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjaytkbabu authored and kyle1morel committed Sep 4, 2024
1 parent 6dae104 commit cc2b596
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 14 deletions.
5 changes: 0 additions & 5 deletions app/src/controllers/enquiry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ const controller = {

createDraft: async (req: Request, res: Response, next: NextFunction) => {
try {
const userId = await userService.getCurrentUserId(getCurrentIdentity(req.currentUser, NIL), NIL);
// eslint-disable-next-line @typescript-eslint/no-explicit-any

const enquiry = await controller.generateEnquiryData(req);

// Create new enquiry
Expand Down Expand Up @@ -159,8 +156,6 @@ const controller = {

updateDraft: async (req: Request, res: Response, next: NextFunction) => {
try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const userId = await userService.getCurrentUserId(getCurrentIdentity(req.currentUser, NIL), NIL);
const enquiry = await controller.generateEnquiryData(req);

// Update enquiry
Expand Down
1 change: 1 addition & 0 deletions app/src/controllers/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ const controller = {

if (data.basic) {
basic = {
consentToFeedback: data.basic.consentToFeedback ?? false,
isDevelopedByCompanyOrOrg: data.basic.isDevelopedByCompanyOrOrg,
isDevelopedInBC: data.basic.isDevelopedInBC,
companyNameRegistered: data.basic.registeredName
Expand Down
13 changes: 13 additions & 0 deletions app/src/db/migrations/20240718000000_007-rbac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ export async function up(knex: Knex): Promise<void> {
})
)

// Alter public schema tables
.then(() =>
knex.schema.alterTable('submission', (table) => {
// Add new columns
table.boolean('consent_to_feedback').notNullable().defaultTo(false);
})
)
// Create the access_request table
.then(() =>
knex.schema.createTable('access_request', (table) => {
Expand Down Expand Up @@ -767,6 +774,12 @@ export async function down(knex: Knex): Promise<void> {
.then(() => knex.schema.dropTableIfExists('access_request'))
// Drop the access_request_status_enum type
.then(() => knex.schema.raw('DROP TYPE IF EXISTS access_request_status_enum'))
// Drop consent_to_feedback column from submission table
.then(() =>
knex.schema.alterTable('submission', (table) => {
table.dropColumn('consent_to_feedback');
})
)

.then(() =>
knex.schema.alterTable('user', (table) => {
Expand Down
2 changes: 2 additions & 0 deletions app/src/db/models/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default {
project_description: input.projectDescription,
submitted_at: new Date(input.submittedAt ?? Date.now()),
submitted_by: input.submittedBy,
consent_to_feedback: input.consentToFeedback,
location_pids: input.locationPIDs,
contact_name: `${input.contactFirstName} ${input.contactLastName}`,
contact_first_name: input.contactFirstName,
Expand Down Expand Up @@ -89,6 +90,7 @@ export default {
contactPhoneNumber: input.contact_phone_number,
contactEmail: input.contact_email,
contactPreference: input.contact_preference,
consentToFeedback: input.consent_to_feedback,
projectName: input.project_name,
projectDescription: input.project_description,
companyNameRegistered: input.company_name_registered,
Expand Down
1 change: 1 addition & 0 deletions app/src/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ model submission {
submission_type String?
contact_first_name String?
contact_last_name String?
consent_to_feedback Boolean @default(false)
activity activity @relation(fields: [activity_id], references: [activity_id], onDelete: Cascade, map: "submission_activity_id_foreign")
user user? @relation(fields: [assigned_user_id], references: [user_id], onDelete: Cascade, map: "submission_assigned_user_id_foreign")
Expand Down
1 change: 1 addition & 0 deletions app/src/types/Submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Submission = {
contactPhoneNumber: string | null;
contactEmail: string | null;
contactPreference: string | null;
consentToFeedback: boolean;
projectName: string | null;
projectDescription: string | null;
singleFamilyUnits: string | null;
Expand Down
1 change: 1 addition & 0 deletions app/src/validators/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ENQUIRY_TYPE_LIST } from '../utils/constants/housing';
import { BasicResponse } from '../utils/enums/application';

export const basicIntake = Joi.object({
consentToFeedback: Joi.boolean(),
isDevelopedByCompanyOrOrg: Joi.string()
.required()
.valid(...YES_NO_LIST),
Expand Down
1 change: 1 addition & 0 deletions app/src/validators/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const schema = {
body: Joi.object({
submissionId: uuidv4.required(),
activityId: activityId,
consentToFeedback: Joi.boolean(),
queuePriority: Joi.number().required().integer().min(0).max(3),
submissionType: Joi.string()
.required()
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/housing/CollectionDisclaimer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { Card, Divider } from '@/lib/primevue';
</template>
<template #content>
<p class="disclaimer">
This information is being collected under the legal authority of section 26 (c) and 27 (1)(a)(i) of the Freedom
of Information and Protection of Privacy Act (the Act) and is being used for the purpose of creating a client
relationship between you or your organization and Government of British Columbia. It may also be shared when
strictly necessary with partner agencies that are also subject to the provisions of the Act. Personal
This information is being collected under the legal authority of section 26 (c)(e) and 27 (1)(a)(i) of the
Freedom of Information and Protection of Privacy Act (the Act) and is being used for the purpose of creating a
client relationship between you or your organization and Government of British Columbia. It may also be shared
when strictly necessary with partner agencies that are also subject to the provisions of the Act. Personal
information may be used by the Permitting Solutions Branch for survey purposes. If you have any questions
regarding the use of this personal information, please contact Housing Authorizations at
<a href="mailto:Housing.Authorizations@gov.bc.ca">Housing.Authorizations@gov.bc.ca.</a>
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/components/housing/submission/SubmissionForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const formSchema = object({
relatedEnquiries: string().notRequired().label('Related enquiries'),
...applicantValidator,
companyNameRegistered: string().notRequired().max(255).label('Company'),
consentToFeedback: string().notRequired().nullable().label('Consent to feedback'),
isDevelopedInBC: string().when('companyNameRegistered', {
is: (val: string) => val,
then: (schema) => schema.required().oneOf(YES_NO_LIST).label('Company registered in B.C'),
Expand Down Expand Up @@ -199,14 +200,15 @@ const onSubmit = async (values: any) => {
const submitData: Submission = omit(setEmptyStringsToNull(values) as SubmissionForm, ['locationAddress', 'user']);
submitData.assignedUserId = values.user?.userId ?? undefined;
submitData.consentToFeedback = values.consentToFeedback === BasicResponse.YES;
const result = await submissionService.updateSubmission(values.submissionId, submitData);
submissionStore.setSubmission(result.data);
formRef.value?.resetForm({
values: {
...submitData,
locationAddress: values.locationAddress,
user: values.user
user: values.user,
consentToFeedback: values.consentToFeedback
}
});
Expand Down Expand Up @@ -249,6 +251,7 @@ onMounted(async () => {
contactPreference: props.submission.contactPreference,
contactPhoneNumber: props.submission.contactPhoneNumber,
contactEmail: props.submission.contactEmail,
consentToFeedback: props.submission.consentToFeedback ? BasicResponse.YES : BasicResponse.NO,
projectName: props.submission.projectName,
projectDescription: props.submission.projectDescription,
projectLocationDescription: props.submission.projectLocationDescription,
Expand Down Expand Up @@ -399,6 +402,13 @@ onMounted(async () => {
label="Contact email"
:disabled="!props.editable"
/>
<Dropdown
class="col-3"
name="consentToFeedback"
label="Research opt-in"
:disabled="!props.editable"
:options="YES_NO_LIST"
/>

<SectionHeader title="Housing" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,22 @@ onBeforeMount(async () => {
</div>
</template>
</Card>
<Card>
<template #content>
<div class="mb-2 flex align-items-center">
<Checkbox
class="m-0 inline-block"
name="basic.consentToFeedback"
:bold="false"
:disabled="!editable"
/>
<span class="font-bold inline">
Check this box if you agree to be contacted for user feedback, helping us improve our digital
service. Your personal information will not be shared with third parties.
</span>
</div>
</template>
</Card>

<StepperNavigation
:editable="editable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const submissionIntakeSchema = object({
contactPreference: string().required().oneOf(CONTACT_PREFERENCE_LIST).label('Contact Preference')
}),
[IntakeFormCategory.BASIC]: object({
consentToFeedback: boolean().notRequired().nullable().label('Consent to feedback'),
isDevelopedByCompanyOrOrg: string().required().oneOf(YES_NO_LIST).label('Project developed'),
isDevelopedInBC: string().when('isDevelopedByCompanyOrOrg', {
is: (value: string) => value === BasicResponse.YES,
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,22 @@ const routes: Array<RouteRecordRaw> = [
{
path: 'project',
meta: {
access: [Permissions.NAVIGATION_HOUSING_STATUS_TRACKER]
access: [NavigationPermission.HOUSING_STATUS_TRACKER]
},
children: [
{
path: '',
component: () => import('@/views/housing/project/ProjectListView.vue'),
meta: {
access: [Permissions.NAVIGATION_HOUSING_STATUS_TRACKER]
access: [NavigationPermission.HOUSING_STATUS_TRACKER]
},
name: RouteName.HOUSING_PROJECTS_LIST
},
{
path: ':submissionId',
component: () => import('@/views/housing/project/ProjectView.vue'),
meta: {
access: [Permissions.NAVIGATION_HOUSING_STATUS_TRACKER]
access: [NavigationPermission.HOUSING_STATUS_TRACKER]
},
name: RouteName.HOUSING_PROJECT,
props: createProps
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types/Submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Submission = {
contactFirstName: string;
contactLastName: string;
companyNameRegistered: string;
consentToFeedback?: boolean;
isDevelopedInBC: string;
contactApplicantRelationship: string;
contactPreference: string;
Expand Down

0 comments on commit cc2b596

Please sign in to comment.