Skip to content

Commit

Permalink
project form completed with all required fields
Browse files Browse the repository at this point in the history
tried to make validations work, it was an incomplete success.
  • Loading branch information
horatiorosa committed Oct 23, 2024
1 parent 3e40dc6 commit d889e6b
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 16 deletions.
6 changes: 5 additions & 1 deletion client/app/components/packages/projects/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
@form={{saveableProjectsNewForm}}
@boroughOptions={{this.boroughOptions}}
@onBoroughChange={{this.handleBoroughChange}}
@selectedBorough={{this.selectedBorough}} />
@selectedBorough={{this.selectedBorough}}
@onApplicantTypeSelection={{this.handleApplicantTypeChange}}
@selectedApplicantType={{this.selectedApplicantType}}
@applicantOptions={{this.applicantOptions}}
/>
<Packages::Projects::ProjectsNewAddContacts
@form={{saveableProjectsNewForm}} />
</div>
Expand Down
18 changes: 18 additions & 0 deletions client/app/components/packages/projects/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ export default class ProjectsNewFormComponent extends Component {
@tracked
selectedBorough = null;

@tracked
selectedApplicantType = null;

get boroughOptions() {
return optionset(['project', 'boroughs', 'list']);
}

get applicantOptions() {
return optionset(['applicant', 'dcpApplicantType', 'list']);
}

@action
handleBoroughChange(selectedBorough) {
console.log('Selected borough:', selectedBorough);

Check warning on line 36 in client/app/components/packages/projects/new.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Unexpected console statement

Check warning on line 36 in client/app/components/packages/projects/new.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Unexpected console statement
Expand All @@ -35,6 +42,17 @@ export default class ProjectsNewFormComponent extends Component {
}
}

@action
handleApplicantTypeChange(selectedApplicantType) {
console.log('Selected Applicant Type:', selectedApplicantType);

Check warning on line 47 in client/app/components/packages/projects/new.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Unexpected console statement

Check warning on line 47 in client/app/components/packages/projects/new.js

View workflow job for this annotation

GitHub Actions / 🧪 Test client code

Unexpected console statement

this.selectedApplicantType = selectedApplicantType;

if (this.args.form) {
this.args.form.set('dcpApplicantType', selectedApplicantType);
}
}

@action
async submitPackage() {
const primaryContactInput = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@

<h3>Applicant</h3>
<p>The owner, entity, or representative of the project described in this application.</p>
<p class="q-help">
If using a company or organization, please split the name in the "First Name" and "Last Name" fields. For example,
"NYC
Planning" would be: <b>First Name:</b> NYC, <b>Last Name:</b> Planning
</p>
<Ui::Question @required={{true}} as |Q|>
<Q.Label>
First Name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,54 @@
{{#let @form as |form|}}
<form.Section @title="Project Information">
<form.Section @title='Project Information'>
<Ui::Question @required={{true}} as |Q|>
<Q.Label>
Project Name
</Q.Label>

<form.Field
@attribute="projectName"
@type="text-input"
@attribute='projectName'
@type='text-input'
id={{Q.questionId}}
@showCounter={{true}}
@maxlength="50"
@maxlength='50'
placeholder="project name"
/>
</Ui::Question>
<Ui::Question @required={{true}} as |Q|>
<Q.Label>
<Q.Label data-test-projects-new-borough-dropdown>
Borough
</Q.Label>
<PowerSelect
<PowerSelect
supportsDataTestProperties={{true}}
@attribute='borough'
@options={{@boroughOptions}}
@onChange={{@onBoroughChange}}
@selected={{@selectedBorough}}
@searchField="label"
@placeholder="Select a borough"
as |borough|
>
@searchField='label'
data-test-id='project-new-borough-dropdown'
@placeholder='select a borough' as |borough| >
{{borough.label}}
</PowerSelect>
</Ui::Question>
<Ui::Question @required={{true}} as |Q|>
<Q.Label data-test-projects-new-applicant-type>
Applicant Type
</Q.Label>
<p class='q-help'>
Identify if you represent a public agency or are a private entity.
</p>
<PowerSelect
supportsDataTestProperties={{true}}
@attribute='dcpApplicantType'
@options={{@applicantOptions}}
@onChange={{@onApplicantTypeSelection}}
@selected={{@selectedApplicantType}}
@searchField='label'
data-test-id='projects-new-applicant-type'
@placeholder='select applicant type' as |dcpApplicantType| >
{{dcpApplicantType.label}}
</PowerSelect>
</Ui::Question>
</form.Section>
{{/let}}

1 change: 1 addition & 0 deletions client/app/helpers/optionset.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const OPTIONSET_LOOKUP = {
applicant: {
dcpState: APPLICANT_OPTIONSETS.DCPSTATE,
dcpType: APPLICANT_OPTIONSETS.DCPTYPE,
dcpApplicantType: APPLICANT_OPTIONSETS.DCP_APPLICANTTYPE,
},
bbl: {
boroughs: BBL_OPTIONSETS.BOROUGHS,
Expand Down
12 changes: 12 additions & 0 deletions client/app/optionsets/applicant.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,21 @@ export const DCPSTATE = {
},
};

export const DCP_APPLICANTTYPE = {
OTHER_PUBLIC_AGENCY: {
label: 'Other Public Agency',
code: 717170001,
},
PRIVATE: {
label: 'Private',
code: 717170002,
},
};

const APPLICANT_OPTIONSETS = {
DCPTYPE,
DCPSTATE,
DCP_APPLICANTTYPE,
};

export default APPLICANT_OPTIONSETS;
10 changes: 5 additions & 5 deletions client/app/optionsets/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ export const STATUSCODE = {
export const BOROUGHS = {
BRONX: {
code: 717170000,
label: "Bronx",
label: 'Bronx',
},
BROOKLYN: {
code: 717170002,
label: "Brooklyn",
label: 'Brooklyn',
},
MANHATTAN: {
code: 717170001,
label: "Manhattan",
label: 'Manhattan',
},
QUEENS: {
code: 717170003,
label: "Queens",
label: 'Queens',
},
STATEN_ISLAND: {
code: 717170004,
label: "Staten Island",
label: 'Staten Island',
},
};

Expand Down
12 changes: 12 additions & 0 deletions client/app/validations/submittable-projects-new-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,16 @@ export default {
message: 'This field is required',
}),
],
borough: [
validatePresence({
presence: true,
message: 'Please select a Borough',
}),
],
dcpApplicantType: [
validatePresence({
presence: true,
message: 'Please select an Applicant Type',
}),
],
};

0 comments on commit d889e6b

Please sign in to comment.