Skip to content

Commit 48eba1e

Browse files
committed
FE - removed isDevelopedInBC field, autocomplete component updated
Signed-off-by: Sanjay Babu <sanjaytkbabu@gmail.com>
1 parent 989dbec commit 48eba1e

File tree

5 files changed

+16
-52
lines changed

5 files changed

+16
-52
lines changed

frontend/src/components/form/AutoComplete.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { onBeforeMount } from 'vue';
44
55
import { AutoComplete } from '@/lib/primevue';
66
7-
import type { AutoCompleteCompleteEvent } from 'primevue/autocomplete';
7+
import type { AutoCompleteChangeEvent, AutoCompleteCompleteEvent } from 'primevue/autocomplete';
88
99
// Props
1010
@@ -37,7 +37,7 @@ const {
3737
}>();
3838
3939
// Emits
40-
const emit = defineEmits(['onComplete', 'onSelect']);
40+
const emit = defineEmits(['onChange', 'onComplete', 'onSelect']);
4141
const { errorMessage, handleBlur, value, resetField } = useField<string>(name);
4242
4343
onBeforeMount(() => {
@@ -72,6 +72,7 @@ onBeforeMount(() => {
7272
:placeholder="placeholder"
7373
:suggestions="suggestions"
7474
@blur="handleBlur"
75+
@change="(e: AutoCompleteChangeEvent) => emit('onChange', e)"
7576
@complete="(e: AutoCompleteCompleteEvent) => emit('onComplete', e)"
7677
@option-select="(e) => emit('onSelect', e.value)"
7778
/>

frontend/src/components/housing/project/ProjectForm.vue

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ function initializeFormValues(project: HousingProject) {
208208
project: {
209209
companyIdRegistered: project.companyIdRegistered,
210210
companyNameRegistered: project.companyNameRegistered,
211-
isDevelopedInBc: project.companyIdRegistered ? BasicResponse.YES : BasicResponse.NO,
212211
projectName: project.projectName
213212
},
214213
@@ -431,7 +430,6 @@ const onSubmit = async (values: any) => {
431430
'contactPreference',
432431
'contactUserId',
433432
'assignedUser',
434-
'isDevelopedInBc',
435433
'submissionState',
436434
'locationAddress',
437435
'relatedEnquiries'
@@ -547,22 +545,14 @@ onBeforeMount(async () => {
547545
</h3>
548546
</div>
549547
</template>
550-
<div class="grid grid-cols-2 gap-x-6 gap-y-6">
551-
<Select
552-
name="project.isDevelopedInBc"
553-
:label="t('i.housing.project.projectForm.companyRegisteredInBC')"
554-
:disabled="!editable"
555-
:options="YES_NO_LIST"
556-
@on-change="setFieldValue('project.companyIdRegistered', null)"
557-
/>
548+
<div class="grid grid-cols-3 gap-x-6 gap-y-6">
558549
<InputText
559550
name="project.projectName"
560551
:label="t('i.housing.project.projectForm.projectNameLabel')"
561552
:disabled="!editable"
562553
@on-input="emitProjectNameChange"
563554
/>
564555
<AutoComplete
565-
v-if="values.project.isDevelopedInBc === BasicResponse.YES"
566556
name="project.companyNameRegistered"
567557
:label="t('i.housing.project.projectForm.companyLabel')"
568558
:bold="true"
@@ -571,6 +561,7 @@ onBeforeMount(async () => {
571561
:placeholder="t('i.common.projectForm.searchBCRegistered')"
572562
:get-option-label="(option: OrgBookOption) => option.registeredName"
573563
:suggestions="orgBookOptions"
564+
@on-change="setFieldValue('project.companyIdRegistered', null)"
574565
@on-complete="onRegisteredNameInput"
575566
@on-select="
576567
(orgBookOption: OrgBookOption) => {
@@ -580,23 +571,6 @@ onBeforeMount(async () => {
580571
"
581572
/>
582573
<InputText
583-
v-else
584-
name="project.companyNameRegistered"
585-
:label="t('i.housing.project.projectForm.companyLabel')"
586-
:disabled="!editable"
587-
@on-change="
588-
(e) => {
589-
setFieldValue('project.companyIdRegistered', null);
590-
if (!e.target.value) {
591-
setFieldValue('project.companyNameRegistered', null);
592-
setFieldValue('project.isDevelopedInBc', null);
593-
}
594-
}
595-
"
596-
/>
597-
598-
<InputText
599-
v-if="values.project.isDevelopedInBc === BasicResponse.YES"
600574
name="project.companyIdRegistered"
601575
:label="t('i.common.projectForm.bcRegistryId')"
602576
:disabled="true"

frontend/src/components/housing/project/ProjectFormSchema.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ export function createProjectFormSchema() {
108108
.notRequired()
109109
.max(255)
110110
.label(t('i.housing.project.projectFormSchema.projectCompanyNameRegistered')),
111-
isDevelopedInBc: string().when('companyNameRegistered', {
112-
is: (val: string) => val,
113-
then: (schema) =>
114-
schema.required().oneOf(YES_NO_LIST).label(t('i.housing.project.projectFormSchema.projectIsDevelopedInBc')),
115-
otherwise: () => string().notRequired()
116-
}),
117111
projectName: string().required().max(255).label(t('i.housing.project.projectFormSchema.projectProjectName'))
118112
}),
119113
projectDescription: string().notRequired().label(t('i.housing.project.projectFormSchema.projectDescription')),

frontend/src/locales/en-CA.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@
462462
"priorityNumber": "Priority must be a number",
463463
"projectLocationDescription": "Additional information about location",
464464
"projectCompanyNameRegistered": "Company name",
465-
"projectIsDevelopedInBc": "Company registered in B.C",
466465
"projectProjectName": "Project name",
467466
"projectDescription": "Additional information about project",
468467
"relatedEnquiries": "Related enquiries",

frontend/tests/unit/components/housing/project/ProjectForm.spec.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ describe('ProjectForm.vue', () => {
187187
await nextTick();
188188

189189
const elements = wrapper.findAll('.p-select-dropdown');
190-
expect(elements.length).toBe(17);
190+
expect(elements.length).toBe(16);
191191
});
192192

193193
it('renders the correct amount of input components', async () => {
@@ -266,6 +266,9 @@ describe('ProjectForm.vue', () => {
266266
}));
267267

268268
expect(notDisabled).toEqual([]);
269+
const elements = wrapper.findAll('.p-disabled');
270+
expect(wrapper.vm.$props?.editable).toBe(false);
271+
expect(elements.length).toBe(21);
269272
});
270273

271274
it('geojson download btn not visible when no geojson', async () => {
@@ -312,8 +315,7 @@ describe('onRegisteredNameInput', () => {
312315
});
313316

314317
it('should not call searchOrgBook when query length is less than 2', async () => {
315-
const modifiedSubmission = { ...testSubmission };
316-
const wrapper = mount(ProjectForm, wrapperSettings(modifiedSubmission));
318+
const wrapper = mount(ProjectForm, wrapperSettings(testSubmission));
317319
await nextTick();
318320
await nextTick();
319321

@@ -340,8 +342,7 @@ describe('onRegisteredNameInput', () => {
340342

341343
searchOrgBookSpy.mockResolvedValue(mockResponse as AxiosResponse);
342344

343-
const modifiedSubmission = { ...testSubmission };
344-
const wrapper = mount(ProjectForm, wrapperSettings(modifiedSubmission));
345+
const wrapper = mount(ProjectForm, wrapperSettings(testSubmission));
345346
await nextTick();
346347
await nextTick();
347348

@@ -371,8 +372,7 @@ describe('onRegisteredNameInput', () => {
371372

372373
searchOrgBookSpy.mockResolvedValue(mockResponse as AxiosResponse);
373374

374-
const modifiedSubmission = { ...testSubmission };
375-
const wrapper = mount(ProjectForm, wrapperSettings(modifiedSubmission));
375+
const wrapper = mount(ProjectForm, wrapperSettings(testSubmission));
376376
await nextTick();
377377
await nextTick();
378378

@@ -407,8 +407,7 @@ describe('onRegisteredNameInput', () => {
407407

408408
searchOrgBookSpy.mockResolvedValue(mockResponse as AxiosResponse);
409409

410-
const modifiedSubmission = { ...testSubmission };
411-
const wrapper = mount(ProjectForm, wrapperSettings(modifiedSubmission));
410+
const wrapper = mount(ProjectForm, wrapperSettings(testSubmission));
412411
await nextTick();
413412
await nextTick();
414413

@@ -432,8 +431,7 @@ describe('onRegisteredNameInput', () => {
432431

433432
searchOrgBookSpy.mockResolvedValue(mockResponse as AxiosResponse);
434433

435-
const modifiedSubmission = { ...testSubmission };
436-
const wrapper = mount(ProjectForm, wrapperSettings(modifiedSubmission));
434+
const wrapper = mount(ProjectForm, wrapperSettings(testSubmission));
437435
await nextTick();
438436
await nextTick();
439437

@@ -462,8 +460,7 @@ describe('onRegisteredNameInput', () => {
462460

463461
searchOrgBookSpy.mockResolvedValue(mockResponse as AxiosResponse);
464462

465-
const modifiedSubmission = { ...testSubmission };
466-
const wrapper = mount(ProjectForm, wrapperSettings(modifiedSubmission));
463+
const wrapper = mount(ProjectForm, wrapperSettings(testSubmission));
467464
await nextTick();
468465
await nextTick();
469466

@@ -489,8 +486,7 @@ describe('onRegisteredNameInput', () => {
489486

490487
searchOrgBookSpy.mockResolvedValue(mockResponse as AxiosResponse);
491488

492-
const modifiedSubmission = { ...testSubmission };
493-
const wrapper = mount(ProjectForm, wrapperSettings(modifiedSubmission));
489+
const wrapper = mount(ProjectForm, wrapperSettings(testSubmission));
494490
await nextTick();
495491
await nextTick();
496492

0 commit comments

Comments
 (0)