From 6e64f4f93d3a88247aad6afc64cdfa8e5e6db574 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Thu, 2 Feb 2023 17:52:50 +0530 Subject: [PATCH] incr: add pick columns modal --- src/importer.ts | 14 +-- src/pages/ImportWizard.vue | 226 ++++++++++++++++++++++++++++--------- 2 files changed, 179 insertions(+), 61 deletions(-) diff --git a/src/importer.ts b/src/importer.ts index d2d7af6e..7b41b32e 100644 --- a/src/importer.ts +++ b/src/importer.ts @@ -12,7 +12,7 @@ import { } from 'schemas/types'; import { generateCSV, parseCSV } from 'utils/csvParser'; -type TemplateField = Field & { +export type TemplateField = Field & { schemaName: string; schemaLabel: string; fieldKey: string; @@ -32,7 +32,7 @@ const skippedFieldsTypes: FieldType[] = [ ]; /** - * Tool that + * Tool that * - Can make bulk entries for any kind of Doc * - Takes in unstructured CSV data, converts it into Docs * - Saves and or Submits the converted Docs @@ -45,7 +45,7 @@ export class Importer { * List of template fields that have been assigned a column, in * the order they have been assigned. */ - assignedTemplateFields: string[]; + assignedTemplateFields: (string | null)[]; /** * Map of all the template fields that can be imported. @@ -59,11 +59,6 @@ export class Importer { */ templateFieldsPicked: Map; - /** - * Map of Fields that have been assigned columns - */ - templateFieldsAssigned: Map; - /** * Whether the schema type being imported has table fields */ @@ -91,12 +86,10 @@ export class Importer { this.assignedTemplateFields = templateFields.map((f) => f.fieldKey); this.templateFieldsMap = new Map(); this.templateFieldsPicked = new Map(); - this.templateFieldsAssigned = new Map(); templateFields.forEach((f, i) => { this.templateFieldsMap.set(f.fieldKey, f); this.templateFieldsPicked.set(f.fieldKey, true); - this.templateFieldsAssigned.set(f.fieldKey, i); }); } @@ -115,6 +108,7 @@ export class Importer { addRow() { const valueRow: ValueMatrix[number] = this.assignedTemplateFields.map( (key) => { + key ??= ''; const { fieldtype } = this.templateFieldsMap.get(key) ?? {}; let value = null; if (fieldtype) { diff --git a/src/pages/ImportWizard.vue b/src/pages/ImportWizard.vue index e007cc37..1d112023 100644 --- a/src/pages/ImportWizard.vue +++ b/src/pages/ImportWizard.vue @@ -32,10 +32,19 @@ p-4 " > -
@@ -115,21 +125,36 @@ v-for="(val, cidx) of row" :key="`cell-${ridx}-${cidx}`" > -
- {{ val.value }} -
+ + + + @@ -208,6 +233,8 @@
+ +
+ + + + +
+ + +
+ + +
+

+ {{ key }} +

+
+
+ +

*

+
+
+
+ + +
+
+

+ {{ t`${numColumnsPicked} fields selected` }} +

+ +
+
+