Browse Source

refactor(nc-gui): rename variables & props

pull/4135/head
Wing-Kam Wong 2 years ago
parent
commit
1a29bd0166
  1. 12
      packages/nc-gui/components/dlg/QuickImport.vue
  2. 2
      packages/nc-gui/components/smartsheet/toolbar/MoreActions.vue
  3. 2
      packages/nc-gui/components/smartsheet/toolbar/ViewActions.vue
  4. 12
      packages/nc-gui/components/template/Editor.vue
  5. 2
      packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts
  6. 2
      packages/nc-gui/utils/parsers/ExcelTemplateAdapter.ts
  7. 2
      packages/nc-gui/utils/parsers/JSONTemplateAdapter.ts

12
packages/nc-gui/components/dlg/QuickImport.vue

@ -27,10 +27,10 @@ import type { importFileList, streamImportFileList } from '~/lib'
interface Props {
modelValue: boolean
importType: 'csv' | 'json' | 'excel'
importOnly?: boolean
importDataOnly?: boolean
}
const { importType, importOnly = false, ...rest } = defineProps<Props>()
const { importType, importDataOnly = false, ...rest } = defineProps<Props>()
const emit = defineEmits(['update:modelValue'])
@ -69,7 +69,7 @@ const importState = reactive({
normalizeNested: true,
autoSelectFieldTypes: true,
firstRowAsHeaders: true,
importData: true,
shouldImportData: true,
},
})
@ -199,7 +199,7 @@ async function parseAndExtractData(val: UploadFile[] | ArrayBuffer | string) {
templateGenerator.parse(() => {
templateData.value = templateGenerator!.getTemplate()
if (importOnly) importColumns.value = templateGenerator!.getColumns()
if (importDataOnly) importColumns.value = templateGenerator!.getColumns()
importData.value = templateGenerator!.getData()
templateEditorModal.value = true
isParsingData.value = false
@ -342,7 +342,7 @@ const beforeUpload = (file: UploadFile) => {
:project-template="templateData"
:import-data="importData"
:import-columns="importColumns"
:import-only="importOnly"
:import-data-only="importDataOnly"
:quick-import-type="importType"
:max-rows-to-parse="importState.parserConfig.maxRowsToParse"
class="nc-quick-import-template-editor"
@ -448,7 +448,7 @@ const beforeUpload = (file: UploadFile) => {
<!-- Import Data -->
<a-form-item class="!my-2">
<a-checkbox v-model:checked="importState.parserConfig.importData">{{ $t('labels.importData') }}</a-checkbox>
<a-checkbox v-model:checked="importState.parserConfig.shouldImportData">{{ $t('labels.importData') }}</a-checkbox>
</a-form-item>
</div>
</div>

2
packages/nc-gui/components/smartsheet/toolbar/MoreActions.vue

@ -166,7 +166,7 @@ const exportFile = async (exportType: ExportTypes) => {
</template>
</a-dropdown>
<LazyDlgQuickImport v-if="quickImportDialog" v-model="quickImportDialog" import-type="csv" :import-only="true" />
<LazyDlgQuickImport v-if="quickImportDialog" v-model="quickImportDialog" import-type="csv" :import-data-only="true" />
<LazyWebhookDrawer v-if="showWebhookDrawer" v-model="showWebhookDrawer" />

2
packages/nc-gui/components/smartsheet/toolbar/ViewActions.vue

@ -228,7 +228,7 @@ const { isSqlView } = useSmartsheetStoreOrThrow()
</template>
</a-dropdown>
<LazyDlgQuickImport v-if="quickImportDialog" v-model="quickImportDialog" import-type="csv" :import-only="true" />
<LazyDlgQuickImport v-if="quickImportDialog" v-model="quickImportDialog" import-type="csv" :import-data-only="true" />
<LazyWebhookDrawer v-if="showWebhookDrawer" v-model="showWebhookDrawer" />

12
packages/nc-gui/components/template/Editor.vue

@ -28,7 +28,7 @@ import {
} from '#imports'
import { TabType } from '~/lib'
const { quickImportType, projectTemplate, importData, importColumns, importOnly, maxRowsToParse } = defineProps<Props>()
const { quickImportType, projectTemplate, importData, importColumns, importDataOnly, maxRowsToParse } = defineProps<Props>()
const emit = defineEmits(['import'])
@ -41,7 +41,7 @@ interface Props {
projectTemplate: Record<string, any>
importData: Record<string, any>
importColumns: any[]
importOnly: boolean
importDataOnly: boolean
maxRowsToParse: number
}
@ -123,7 +123,7 @@ const validators = computed(() =>
const { validate, validateInfos } = useForm(data, validators)
const isValid = computed(() => {
if (importOnly) {
if (importDataOnly) {
for (const record of srcDestMapping.value) {
if (!fieldsValidation(record)) {
return false
@ -362,7 +362,7 @@ function fieldsValidation(record: Record<string, any>) {
}
async function importTemplate() {
if (importOnly) {
if (importDataOnly) {
// validate required columns
if (!missingRequiredColumnsValidation()) return
@ -555,7 +555,7 @@ defineExpose({
})
onMounted(() => {
if (importOnly) {
if (importDataOnly) {
mapDefaultColumns()
}
})
@ -579,7 +579,7 @@ function isSelectDisabled(uidt: string, disableSelect = false) {
<template>
<a-spin :spinning="isImporting" :tip="importingTip" size="large">
<a-card v-if="importOnly">
<a-card v-if="importDataOnly">
<a-form :model="data" name="import-only">
<p v-if="data.tables && quickImportType === 'excel'" class="text-center">
{{ data.tables.length }} sheet{{ data.tables.length > 1 ? 's' : '' }}

2
packages/nc-gui/utils/parsers/CSVTemplateAdapter.ts

@ -243,7 +243,7 @@ export default class CSVTemplateAdapter {
that.updateTemplate(tableIdx)
// parse table data
if (that.config.importData) {
if (that.config.shouldImportData) {
steppers = 0
parse(file.originFileObj as File, {
worker: true,

2
packages/nc-gui/utils/parsers/ExcelTemplateAdapter.ts

@ -205,7 +205,7 @@ export default class ExcelTemplateAdapter extends TemplateGenerator {
this.project.tables.push(table)
this.data[tn] = []
if (this.config.importData) {
if (this.config.shouldImportData) {
let rowIndex = 0
for (const row of rows.slice(1)) {
const rowData: Record<string, any> = {}

2
packages/nc-gui/utils/parsers/JSONTemplateAdapter.ts

@ -64,7 +64,7 @@ export default class JSONTemplateAdapter extends TemplateGenerator {
table.columns.push(...columns)
}
if (this.config.importData) {
if (this.config.shouldImportData) {
this._parseTableData(table)
}

Loading…
Cancel
Save