Examples
importOK is a reusable custom web component that embeds an import wizard into your app. You can follow this installation guide to use it as a Vue.js component.
For the sake of simplicity, we are going to install and configure importOK to import a list of Contacts. Our app will be expecting four fields: first name
last name
email
and phone
First, import the importOK package for Vue.js:
1npm install @importok/vue
To embed the wizard, add the following into your page. The wizard will be added as a child element to the first argument provided, so make sure to adjust that accordingly.
1<script> 2import ImportokWizard from "@importok/vue"; 3 4export default { 5 components: { 6 ImportokWizard 7 }, 8 9 methods: {10 /**11 * Push the provided record to the API12 * Check https://importok.io/docs/webhooks for more details13 */14 async saveRecord(record, meta) {15 return await fetch('https://httpstat.us/200');16 }17 },18 19 data() {20 return {21 /**22 * Import fields to be mapped23 * Check https://importok.io/docs/fields for more details24 */25 fields: {26 first_name: {27 label: 'First Name',28 transformers: 'capitalize|trim'29 },30 last_name: {31 label: 'Last Name',32 validators: 'required|length:5',33 transformers: 'capitalize|trim'34 },35 company_name: {36 label: 'Company Name',37 transformers: 'trim'38 },39 email: {40 label: 'Email',41 validators: 'email|required',42 transformers: 'lowercase|trim'43 },44 phone: {45 label: 'Phone',46 transformers: 'trim'47 },48 country: {49 label: 'Country',50 validators: 'in:CY,GR,UK',51 transformers: 'uppercase|trim',52 },53 }54 };55 }56};57</script>58<template>59 <ImportokWizard60 title="ImportOK Example for Vue"61 :fields="fields"62 sample-file="/sample.csv"63 @record-ready="saveRecord"64 />65</template>
That's all! You can now open your page and give a try. Keep in mind that that there is a limit of 20 records for each import during the trial. Once subscribed, you will receive access to the private packages and lift the trial limits.
title
Description | Primary text to be displayed at the top of the wizard, across all steps. |
---|---|
Type | string |
Default | Import |
subtitles
Description | Secondary text to be displayed at each wizard step. |
---|---|
Type | string[] |
Default | [ 'Upload your file to get started', 'Match source to target columns', 'Review validation errors and fix your data', 'Please do not close this window during the import process.', ] |
fields
Description | Fields to be mapped - refer to Fields for more details. |
---|---|
Type | { [key: string]: ImportField; } |
Default | {} |
transformers
Description | Custom transformers - refer to Build your own transformers for more details. |
---|---|
Type | { [key: string]: (record: ImportRecord, key: string, ...args: string[]); } |
Default | {} |
validators
Description | Custom validators - refer to Build your own validators for more details. |
---|---|
Type | { [key: string]: (record: ImportRecord, key: string, ...args: string[]); } |
Default | {} |
providers
Description | Custom providers - refer to Data providers for more details. |
---|---|
Type | { [key: string]: DataProvider; } |
Default | {} |
mapper
Description | Custom mapping strategy - refer to Mapping strategy for more details. |
---|---|
Type | MapperStrategy |
Default | LevenshteinMappingStrategy |
style
Description | Custom CSS rules. Please refer to Styling for more details. |
---|---|
Type | string |
Default | undefined |
locale
Description | The locale to use. Please refer to Internalization for more details. |
---|---|
Type | string |
Default | en |
translations
Description | Provide additional translations, or overwrite the existing ones. Please refer to Internalization for more details. |
---|---|
Type | { [key: string]: { [key: string]: string } } |
sampleFile
Description | Example file that can be download in the first step as an example. |
---|---|
Type | string |
Default | '' |
uploadedFile
Description | Raw file to be imported. Useful if your application already offers an upload area. |
---|---|
Type | File |
Default | undefined |
throttle
Description | Throttle the import process - applicable when used with onRecordReady |
---|---|
Type | number |
Default | 0 (no throttle) |
meta
Description | Meta data to be passed to onRecordReady and onImportReady . |
---|---|
Type | object |
Default | {} |
onRecordReady
Description | Callback to import a single record. |
---|---|
Type | function(record: ImportRecord, meta: object): Promise<any> |
Event props |
|
Default | undefined |
onImportReady
Description | Callback to import multiple records at once. |
---|---|
Type | function(records: ImportRecord[], meta: object): Promise<any> |
Event props |
|
Default | undefined |
onImportProgress
Description | Triggered when the progress changes. |
---|---|
Event props |
|
onStepEnter
Description | Triggered when the user enters a new step of the wizard. |
---|---|
Event props |
|
onStepExit
Description | Triggered when the user is about to exit the current step. |
---|---|
Event props |
|