-
Notifications
You must be signed in to change notification settings - Fork 42
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
17489 Partial Business Fetch component + clear button #661
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<template> | ||
<!-- once in Summary state, need to re-mount to reuse this component --> | ||
<div id="business-fetch" v-if="state !== States.SUMMARY"> | ||
<v-text-field | ||
append-icon="mdi-magnify" | ||
autocomplete="chrome-off" | ||
autofocus | ||
filled | ||
@change="onItemSelected()" | ||
@click:append="onItemSelected()" | ||
:loading="state === States.SEARCHING" | ||
:name="Math.random()" | ||
hide-details="auto" | ||
hint="Enter registration number of existing business" | ||
label="Fetch an existing business" | ||
persistent-hint | ||
ref="searchField" | ||
:rules="rules" | ||
v-model="searchField" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue' | ||
import { Component, Emit } from 'vue-property-decorator' | ||
import { BusinessLookupResultIF, FormType } from '@/interfaces' | ||
import { Sleep } from '@/plugins' | ||
import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' | ||
import { EntityStates } from '@bcrs-shared-components/enums' | ||
|
||
enum States { | ||
INITIAL = 'initial', | ||
SEARCHING = 'searching', | ||
SUMMARY = 'summary' | ||
} | ||
|
||
/* | ||
* See PPR's BusinessSearchAutocomplete.vue for a Composition API example. | ||
*/ | ||
@Component({}) | ||
export default class BusinessFetch extends Vue { | ||
// Refs | ||
$refs!: { | ||
searchField: FormType | ||
} | ||
|
||
// enum for template | ||
readonly States = States | ||
|
||
/** V-model for search field. */ | ||
searchField = '' | ||
|
||
/** State of this component. */ | ||
state = States.INITIAL | ||
|
||
/** Validation rules. */ | ||
rules = [ | ||
v => !!v || 'Required field', | ||
v => (!v || v.length === 9) || 'Please enter a valid registration number' | ||
] | ||
|
||
/** When an item has been selected, emits event with business object. */ | ||
@Emit('business') | ||
async onItemSelected (): Promise<BusinessLookupResultIF> { | ||
const valid = this.$refs.searchField.validate() | ||
if (!valid) return | ||
|
||
// set state and perform search | ||
this.state = States.SEARCHING | ||
await Sleep(1000) // *** TODO: perform search here | ||
|
||
// set state and return result | ||
this.state = States.SUMMARY | ||
return { | ||
identifier: this.searchField, | ||
legalType: CorpTypeCd.BC_COMPANY, | ||
bn: '', | ||
status: EntityStates.ACTIVE, | ||
name: this.searchField | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For testing, using a business ID as search field. |
||
} | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,10 +96,24 @@ | |
</v-tooltip> | ||
</v-col> | ||
|
||
<!-- Business Lookup --> | ||
<!-- Business Lookup/Fetch --> | ||
<v-col v-if="showBusinessLookup" cols="12" md="6"> | ||
<BusinessLookup v-if="!business" @business="business=$event"/> | ||
<v-text-field v-else clearable disabled filled hide-details :value="business.name" /> | ||
<template v-if="!business"> | ||
<BusinessLookup v-if="getIsAuthenticated" @business="business=$event"/> | ||
<BusinessFetch v-else @business="business=$event"/> | ||
</template> | ||
<div v-else class="d-flex justify-space-between align-center"> | ||
<v-text-field | ||
append-outer-icon="mdi-close" | ||
disabled | ||
filled | ||
hide-details | ||
:value="business.name" | ||
/> | ||
<div @click="business=null"> | ||
<v-icon color="primary">mdi-close</v-icon> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a usable clear/retry button, but I'm still waiting for Janis' design on it. |
||
</div> | ||
</div> | ||
</v-col> | ||
|
||
<!-- once an entity type is selected (or Federal)... --> | ||
|
@@ -262,14 +276,11 @@ | |
import { Component, Mixins, Vue, Watch } from 'vue-property-decorator' | ||
import { Action, Getter } from 'vuex-class' | ||
|
||
// bcregistry common | ||
import { SessionStorageKeys } from 'sbc-common-components/src/util/constants' | ||
|
||
import BusinessLookup from '@/components/new-request/business-lookup.vue' | ||
|
||
// Components | ||
import NameInput from './name-input.vue' | ||
import NestedSelect from '../common/nested-select.vue' | ||
import BusinessLookup from '@/components/new-request/business-lookup.vue' | ||
import BusinessFetch from '@/components/new-request/business-fetch.vue' | ||
|
||
// Interfaces / Enums / List Data | ||
import { BusinessLookupResultIF, ConversionTypesI, EntityI, FormType, RequestActionsI } from '@/interfaces' | ||
|
@@ -278,12 +289,13 @@ import { AccountType, CompanyType, EntityType, Location, NrRequestActionCodes, N | |
import { CommonMixin, NrAffiliationMixin } from '@/mixins' | ||
import { CanJurisdictions, ConversionTypes, Designations, IntlJurisdictions, RequestActions } from '@/list-data' | ||
import { GetFeatureFlag, Navigate } from '@/plugins' | ||
import { SessionStorageKeys } from 'sbc-common-components/src/util/constants' | ||
|
||
/** | ||
* This is the component that displays the new NR menus and flows. | ||
*/ | ||
@Component({ | ||
components: { BusinessLookup, NameInput, NestedSelect } | ||
components: { BusinessLookup, BusinessFetch, NameInput, NestedSelect } | ||
}) | ||
export default class Search extends Mixins(CommonMixin, NrAffiliationMixin) { | ||
// Refs | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import { | |
AnalysisJSONI, ApplicantI, ConversionTypesI, ExistingRequestSearchI, NameRequestI, | ||
RequestNameI, SelectOptionsI, StatsI, SubmissionTypeT, WaitingAddressSearchI | ||
} from '@/interfaces/models' | ||
import { BusinessLookupResultIF, NameChoicesIF, NrDataIF, RequestOrConsentIF } from '@/interfaces' | ||
import { NameChoicesIF, NrDataIF, RequestOrConsentIF } from '@/interfaces' | ||
import { EntityType, Location, NrAffiliationErrors, NrRequestActionCodes } from '@/enums' | ||
|
||
interface RequestNameMapI extends RequestNameI {} | ||
|
@@ -15,7 +15,6 @@ export interface NewRequestIF { | |
analysisJSON: AnalysisJSONI | ||
applicant: ApplicantI | ||
assumedNameOriginal: string | ||
businessLookup: BusinessLookupResultIF | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need this in the store -- its lifespan is only while doing a business lookup on the Search page. After that, other variables are set from the data. |
||
conditionsModalVisible: boolean | ||
conflictId: string | ||
conversionType: EntityType | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIP but partly usable :)