-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- implemented partial Business Fetch component - deleted BusinessLookup from store - used Business Fetch component when not logged in - implemented business lookup/fetch clear button
- Loading branch information
1 parent
511f7bd
commit 4a51cb8
Showing
12 changed files
with
104 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<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' | ||
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 { name: this.searchField } as BusinessLookupResultIF | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters