Skip to content

Commit

Permalink
feat: geocoding geographic radius set up (#3692)
Browse files Browse the repository at this point in the history
* feat: add collectAddress checkbox with subfields

* test: update preference tests

* fix: add minimum value validation for radius field

* fix: make collect address not required

* fix: expand collect address fields

* fix: change fields order in PreferenceDrawer

* fix: align styles to design

add error message
KrissDrawing authored Nov 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 6adbdbc commit ed5077a
Showing 7 changed files with 374 additions and 82 deletions.
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import { IsBoolean, IsNumber, IsOptional, IsString, ValidateNested } from "class
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum"
import { ApiProperty } from "@nestjs/swagger"
import { MultiselectLink } from "./multiselect-link"
import { ValidationMethod } from "./validation-method-enum"

export class MultiselectOption {
@Expose()
@@ -38,7 +39,34 @@ export class MultiselectOption {
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsBoolean({ groups: [ValidationsGroupsEnum.default] })
@ApiProperty({ required: false })
collectAddress?: boolean | null
collectAddress?: boolean

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@ApiProperty({
required: false,
enum: ValidationMethod,
enumName: "ValidationMethod",
})
validationMethod?: ValidationMethod

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsNumber({}, { groups: [ValidationsGroupsEnum.default] })
@ApiProperty({ required: false })
radiusSize?: number

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsBoolean({ groups: [ValidationsGroupsEnum.default] })
@ApiProperty({ required: false })
collectName?: boolean

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
@IsBoolean({ groups: [ValidationsGroupsEnum.default] })
@ApiProperty({ required: false })
collectRelationship?: boolean

@Expose()
@IsOptional({ groups: [ValidationsGroupsEnum.default] })
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ValidationMethod {
radius = "radius",
map = "map",
none = "none",
}
18 changes: 18 additions & 0 deletions backend/core/types/src/backend-swagger.ts
Original file line number Diff line number Diff line change
@@ -4517,6 +4517,18 @@ export interface MultiselectOption {
/** */
collectAddress?: boolean

/** */
validationMethod?: ValidationMethod

/** */
radiusSize?: number

/** */
collectName?: boolean

/** */
collectRelationship?: boolean

/** */
exclusive?: boolean
}
@@ -6356,6 +6368,12 @@ export enum ListingEventType {
"lotteryResults" = "lotteryResults",
}

export enum ValidationMethod {
"radius" = "radius",
"map" = "map",
"none" = "none",
}

export enum ApplicationSection {
"programs" = "programs",
"preferences" = "preferences",
3 changes: 2 additions & 1 deletion shared-helpers/__tests__/testHelpers.ts
Original file line number Diff line number Diff line change
@@ -36,8 +36,9 @@ export const multiselectQuestionPreference: MultiselectQuestion = {
url: "https://www.example.com",
},
],
collectAddress: false,
},
{ text: "Work in County", ordinal: 1 },
{ text: "Work in County", ordinal: 1, collectAddress: false },
],
applicationSection: ApplicationSection.preferences,
}
Original file line number Diff line number Diff line change
@@ -27,10 +27,16 @@ describe("Preference Management Tests", () => {
cy.getByTestId("preference-option-description").type("Preference Option Description")
cy.getByTestId("preference-option-link").type("https://www.example2.com")
cy.getByTestId("preference-option-link-title").type("Preference Option Link Title")
cy.getByTestId("preference-option-collect-address").check()
cy.getByTestId("collect-address-yes").click()
cy.getByTestId("exclusive-question-exclusive").check()
cy.getByTestId("preference-option-save").click()

cy.getByTestId("validation-method-radius").click()
cy.getByTestId("preference-option-radius-size").type("100")
cy.getByTestId("collect-name-yes").click()
cy.getByTestId("collect-relationship-yes").click()
cy.getByTestId("preference-option-save").click()

cy.getByTestId("preference-opt-out-label").clear()
cy.getByTestId("preference-opt-out-label").type("Preference Opt Out Label")
cy.getByTestId("preference-jurisdiction").select("Alameda")
@@ -59,7 +65,12 @@ describe("Preference Management Tests", () => {
"have.value",
"Preference Option Link Title"
)
cy.getByTestId("preference-option-collect-address").should("be.checked")

cy.getByTestId("collect-address-yes").should("be.checked")
cy.getByTestId("validation-method-radius").should("be.checked")
cy.getByTestId("preference-option-radius-size").should("have.value", "100")
cy.getByTestId("collect-name-yes").should("be.checked")
cy.getByTestId("collect-relationship-yes").should("be.checked")
cy.getByTestId("exclusive-question-exclusive").should("have.value", "exclusive")
cy.getByTestId("preference-option-save").click()

9 changes: 8 additions & 1 deletion sites/partners/page_content/locale_overrides/general.json
Original file line number Diff line number Diff line change
@@ -337,13 +337,16 @@
"settings.createCopyDescription": "Create a copy of your preference.",
"settings.preference": "Preference",
"settings.preferenceAdd": "Add Preference",
"settings.preferenceAdditionalFields": "Additional Fields",
"settings.preferenceAlertCreated": "Preference Created",
"settings.preferenceAlertUpdated": "Preference Updated",
"settings.preferenceAlertDeleted": "Preference Removed",
"settings.preferenceOptionAdd": "Add Preference Option",
"settings.preferenceAddOption": "Add Option",
"settings.preferenceEditOption": "Edit Option",
"settings.preferenceCollectAddress": "Collect the applicant address",
"settings.preferenceCollectAddress": "Do you want to collect address information?",
"settings.preferenceCollectAddressHolderName": "Do you want to collect name of address holder?",
"settings.preferenceCollectAddressHolderRelationship": "Do you want to collect relationship to address holder?",
"settings.preferenceDelete": "Deleting a preference cannot be undone.",
"settings.preferenceDescription": "Preference Description",
"settings.preferenceEdit": "Edit Preference",
@@ -356,6 +359,10 @@
"settings.preferenceOptionDescription": "Preference Option Description",
"settings.preferenceOptionEdit": "Edit Option",
"settings.preferenceShowOnListing": "Show preference on listing?",
"settings.preferenceValidatingAddress": "Do you need help validating the address?",
"settings.preferenceValidatingAddress.checkWithinRadius": "Yes, check if within geographic radius of property",
"settings.preferenceValidatingAddress.checkManually": "No, will check manually",
"settings.preferenceValidatingAddress.howManyMiles": "How many miles is the qualifying geographic radius?",
"settings.preferenceDeleteConfirmation": "Deleting a preference cannot be undone.",
"settings.preferenceChangesRequired": "Changes required before deleting",
"settings.preferenceDeleteError": "This preference is currently added to listings and needs to be removed before being deleted.",
376 changes: 299 additions & 77 deletions sites/partners/src/components/settings/PreferenceDrawer.tsx

Large diffs are not rendered by default.

0 comments on commit ed5077a

Please sign in to comment.