Browse Source

fix/solved issues with rollup and lookup

pull/3057/head
Muhammed Mustafa 2 years ago committed by Pranav C
parent
commit
83e99a1baf
  1. 15
      packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue
  2. 29
      packages/nc-gui-v2/components/smartsheet-column/LookupOptions.vue
  3. 18
      packages/nc-gui-v2/components/smartsheet-column/RollupOptions.vue
  4. 3
      packages/nc-gui-v2/components/smartsheet-header/VirtualCellIcon.vue

15
packages/nc-gui-v2/components/smartsheet-column/EditOrAdd.vue

@ -35,6 +35,8 @@ const {
const columnToValidate = [UITypes.Email, UITypes.URL, UITypes.PhoneNumber] const columnToValidate = [UITypes.Email, UITypes.URL, UITypes.PhoneNumber]
const onlyNameUpdateOnEditColumns = [UITypes.LinkToAnotherRecord, UITypes.Lookup, UITypes.Rollup]
const uiTypesOptions = computed<typeof uiTypes>(() => { const uiTypesOptions = computed<typeof uiTypes>(() => {
return [ return [
...uiTypes.filter((t) => !isEdit.value || !t.virtual), ...uiTypes.filter((t) => !isEdit.value || !t.virtual),
@ -80,6 +82,8 @@ watchEffect(() => {
antInput.value.focus() antInput.value.focus()
antInput.value.select() antInput.value.select()
}, 300) }, 300)
advancedOptions.value = false
} }
}) })
@ -96,7 +100,7 @@ watch(
</script> </script>
<template> <template>
<div class="max-w-[450px] min-w-[350px] w-max max-h-[95vh] bg-white shadow p-4 overflow-auto" @click.stop> <div class="max-w-[550px] min-w-[450px] w-max max-h-[95vh] bg-white shadow p-4 overflow-auto" @click.stop>
<a-form v-model="formState" name="column-create-or-edit" layout="vertical"> <a-form v-model="formState" name="column-create-or-edit" layout="vertical">
<a-form-item :label="$t('labels.columnName')" v-bind="validateInfos.column_name"> <a-form-item :label="$t('labels.columnName')" v-bind="validateInfos.column_name">
<a-input <a-input
@ -107,7 +111,10 @@ watch(
@input="onAlter(8)" @input="onAlter(8)"
/> />
</a-form-item> </a-form-item>
<a-form-item :label="$t('labels.columnType')"> <a-form-item
v-if="!editColumnDropdown && onlyNameUpdateOnEditColumns.find((col) => col === formState.uidt)"
:label="$t('labels.columnType')"
>
<a-select <a-select
v-model:value="formState.uidt" v-model:value="formState.uidt"
show-search show-search
@ -129,9 +136,9 @@ watch(
<SmartsheetColumnDurationOptions v-if="formState.uidt === UITypes.Duration" /> <SmartsheetColumnDurationOptions v-if="formState.uidt === UITypes.Duration" />
<SmartsheetColumnRatingOptions v-if="formState.uidt === UITypes.Rating" /> <SmartsheetColumnRatingOptions v-if="formState.uidt === UITypes.Rating" />
<SmartsheetColumnCheckboxOptions v-if="formState.uidt === UITypes.Checkbox" /> <SmartsheetColumnCheckboxOptions v-if="formState.uidt === UITypes.Checkbox" />
<SmartsheetColumnLookupOptions v-if="formState.uidt === UITypes.Lookup" /> <SmartsheetColumnLookupOptions v-if="!editColumnDropdown && formState.uidt === UITypes.Lookup" />
<SmartsheetColumnDateOptions v-if="formState.uidt === UITypes.Date" /> <SmartsheetColumnDateOptions v-if="formState.uidt === UITypes.Date" />
<SmartsheetColumnRollupOptions v-if="formState.uidt === UITypes.Rollup" /> <SmartsheetColumnRollupOptions v-if="!editColumnDropdown && formState.uidt === UITypes.Rollup" />
<SmartsheetColumnLinkedToAnotherRecordOptions v-if="formState.uidt === UITypes.LinkToAnotherRecord" /> <SmartsheetColumnLinkedToAnotherRecordOptions v-if="formState.uidt === UITypes.LinkToAnotherRecord" />
<SmartsheetColumnSpecificDBTypeOptions v-if="formState.uidt === UITypes.SpecificDBType" /> <SmartsheetColumnSpecificDBTypeOptions v-if="formState.uidt === UITypes.SpecificDBType" />
<SmartsheetColumnPercentOptions v-if="formState.uidt === UITypes.Percent" /> <SmartsheetColumnPercentOptions v-if="formState.uidt === UITypes.Percent" />

29
packages/nc-gui-v2/components/smartsheet-column/LookupOptions.vue

@ -38,6 +38,14 @@ const refTables = $computed(() => {
})) }))
.filter((table: any) => table.col?.fk_related_model_id === table.id && !table.mm) ?? [] .filter((table: any) => table.col?.fk_related_model_id === table.id && !table.mm) ?? []
) )
return meta.columns
.filter((c) => c.uidt === UITypes.LinkToAnotherRecord && !c.system)
.map((c) => ({
col: c.colOptions,
column: c,
...tables.find((t) => t.id === c.colOptions.fk_related_model_id),
}))
.filter((table) => table.col.fk_related_model_id === table.id && !table.mm)
}) })
const columns = $computed(() => { const columns = $computed(() => {
@ -46,7 +54,7 @@ const columns = $computed(() => {
return [] return []
} }
return metas[selectedTable.id].columns.filter((c: any) => !isSystemColumn(c)) return metas[selectedTable.id].columns.filter((c) => !isSystemColumn(c))
}) })
</script> </script>
@ -54,17 +62,22 @@ const columns = $computed(() => {
<div class="p-4 w-full flex flex-col border-2 mb-2 mt-4"> <div class="p-4 w-full flex flex-col border-2 mb-2 mt-4">
<div class="w-full flex flex-row space-x-2"> <div class="w-full flex flex-row space-x-2">
<a-form-item class="flex w-1/2 pb-2" :label="$t('labels.childTable')" v-bind="validateInfos.fk_relation_column_id"> <a-form-item class="flex w-1/2 pb-2" :label="$t('labels.childTable')" v-bind="validateInfos.fk_relation_column_id">
<a-select v-model:value="formState.fk_relation_column_id" size="small" @change="onDataTypeChange"> <a-select
<a-select-option v-for="(table, index) of refTables" :key="index" :value="table.col.fk_column_id"> v-model:value="formState.fk_relation_column_id"
<div class="flex flex-row items-center space-x-0.5 h-full"> size="small"
<div class="font-weight-bold text-[0.7rem]">{{ table.column.title }}</div> dropdown-class-name="!w-64"
@change="onDataTypeChange"
<div class="text-[0.5rem]">({{ relationNames[table.col.type] }} {{ table.title || table.table_name }})</div> >
<a-select-option v-for="(table, index) in refTables" :key="index" :value="table.col.fk_column_id">
<div class="flex flex-row space-x-0.5 h-full pb-0.5 items-center justify-between">
<div class="font-semibold text-xs">{{ table.column.title }}</div>
<div class="text-[0.65rem] text-gray-600">
{{ relationNames[table.col.type] }} {{ table.title || table.table_name }}
</div>
</div> </div>
</a-select-option> </a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item class="flex w-1/2" :label="$t('labels.childColumn')" v-bind="validateInfos.fk_lookup_column_id"> <a-form-item class="flex w-1/2" :label="$t('labels.childColumn')" v-bind="validateInfos.fk_lookup_column_id">
<a-select <a-select
v-model:value="formState.fk_lookup_column_id" v-model:value="formState.fk_lookup_column_id"

18
packages/nc-gui-v2/components/smartsheet-column/RollupOptions.vue

@ -4,7 +4,6 @@ import { inject, useColumnCreateStoreOrThrow, useMetas, useProject } from '#impo
import { MetaInj } from '~/context' import { MetaInj } from '~/context'
const { formState, validateInfos, onDataTypeChange, setAdditionalValidations } = $(useColumnCreateStoreOrThrow()) const { formState, validateInfos, onDataTypeChange, setAdditionalValidations } = $(useColumnCreateStoreOrThrow())
const { tables } = $(useProject()) const { tables } = $(useProject())
const meta = $(inject(MetaInj)!) const meta = $(inject(MetaInj)!)
@ -69,11 +68,18 @@ const columns = $computed(() => {
<div class="p-4 w-full flex flex-col border-2 mb-2 mt-4"> <div class="p-4 w-full flex flex-col border-2 mb-2 mt-4">
<div class="w-full flex flex-row space-x-2"> <div class="w-full flex flex-row space-x-2">
<a-form-item class="flex w-1/2 pb-2" :label="$t('labels.childTable')" v-bind="validateInfos.fk_relation_column_id"> <a-form-item class="flex w-1/2 pb-2" :label="$t('labels.childTable')" v-bind="validateInfos.fk_relation_column_id">
<a-select v-model:value="formState.fk_relation_column_id" size="small" @change="onDataTypeChange"> <a-select
<a-select-option v-for="(table, index) of refTables" :key="index" :value="table.col.fk_column_id"> v-model:value="formState.fk_relation_column_id"
<div class="flex flex-row items-center space-x-0.5"> size="small"
<div class="font-weight-bold text-xs">{{ table.column.title }}</div> dropdown-class-name="!w-64"
<div class="text-[0.45rem]">({{ relationNames[table.col.type] }} {{ table.title || table.table_name }})</div> @change="onDataTypeChange"
>
<a-select-option v-for="(table, index) in refTables" :key="index" :value="table.col.fk_column_id">
<div class="flex flex-row space-x-0.5 h-full pb-0.5 items-center justify-between">
<div class="font-semibold text-xs">{{ table.column.title }}</div>
<div class="text-[0.65rem] text-gray-600">
({{ relationNames[table.col.type] }} {{ table.title || table.table_name }})
</div>
</div> </div>
</a-select-option> </a-select-option>
</a-select> </a-select>

3
packages/nc-gui-v2/components/smartsheet-header/VirtualCellIcon.vue

@ -11,6 +11,7 @@ import FormulaIcon from '~icons/mdi/math-integral'
import RollupIcon from '~icons/mdi/movie-roll' import RollupIcon from '~icons/mdi/movie-roll'
import CountIcon from '~icons/mdi/counter' import CountIcon from '~icons/mdi/counter'
import SpecificDBTypeIcon from '~icons/mdi/database-settings' import SpecificDBTypeIcon from '~icons/mdi/database-settings'
import TableColumnPlusBefore from '~icons/mdi/table-column-plus-before'
const props = defineProps<{ columnMeta?: ColumnType }>() const props = defineProps<{ columnMeta?: ColumnType }>()
const columnMeta = toRef(props, 'columnMeta') const columnMeta = toRef(props, 'columnMeta')
@ -34,7 +35,7 @@ const icon = computed(() => {
case UITypes.Formula: case UITypes.Formula:
return FormulaIcon return FormulaIcon
case UITypes.Lookup: case UITypes.Lookup:
return GenericIcon return TableColumnPlusBefore
case UITypes.Rollup: case UITypes.Rollup:
return RollupIcon return RollupIcon
case UITypes.Count: case UITypes.Count:

Loading…
Cancel
Save