Browse Source

MapView: 'Mapped by' column values should always be delivered - new approach - WIP

pull/4749/head
Daniel Spaude 2 years ago
parent
commit
e9425e280f
No known key found for this signature in database
GPG Key ID: 654A3D1FA4F35FFE
  1. 46
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
  2. 3
      packages/nc-gui/components/smartsheet/toolbar/MappedBy.vue
  3. 2
      packages/nc-gui/composables/useViewColumns.ts
  4. 1
      packages/nc-gui/lib/enums.ts

46
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -56,6 +56,10 @@ eventBus.on((event) => {
if (event === SmartsheetStoreEvents.FIELD_RELOAD) {
loadViewColumns()
}
else if (event === SmartsheetStoreEvents.MAPPED_BY_COLUMN_CHANGE) {
// alert('SmartsheetStoreEvents.MAPPED_BY_COLUMN_CHANGE')
loadViewColumns()
}
})
watch(
@ -120,13 +124,13 @@ const coverImageColumnId = computed({
...activeView.value?.view,
fk_cover_image_col_id: val,
})
;(activeView.value.view as GalleryType).fk_cover_image_col_id = val
; (activeView.value.view as GalleryType).fk_cover_image_col_id = val
} else if (activeView.value?.type === ViewTypes.KANBAN) {
await $api.dbView.kanbanUpdate(activeView.value?.id, {
...activeView.value?.view,
fk_cover_image_col_id: val,
})
;(activeView.value.view as KanbanType).fk_cover_image_col_id = val
; (activeView.value.view as KanbanType).fk_cover_image_col_id = val
}
reloadViewMetaHook?.trigger()
}
@ -163,21 +167,11 @@ useMenuCloseOnEsc(open)
<template #overlay>
<div
class="p-3 min-w-[280px] bg-gray-50 shadow-lg nc-table-toolbar-menu max-h-[max(80vh,500px)] overflow-auto !border"
data-testid="nc-fields-menu"
@click.stop
>
<a-card
v-if="activeView.type === ViewTypes.GALLERY || activeView.type === ViewTypes.KANBAN"
size="small"
title="Cover image"
>
<a-select
v-model:value="coverImageColumnId"
class="w-full"
:options="coverOptions"
dropdown-class-name="nc-dropdown-cover-image"
@click.stop
/>
data-testid="nc-fields-menu" @click.stop>
<a-card v-if="activeView.type === ViewTypes.GALLERY || activeView.type === ViewTypes.KANBAN" size="small"
title="Cover image">
<a-select v-model:value="coverImageColumnId" class="w-full" :options="coverOptions"
dropdown-class-name="nc-dropdown-cover-image" @click.stop />
</a-card>
<div class="p-1" @click.stop>
@ -187,20 +181,10 @@ useMenuCloseOnEsc(open)
<div class="nc-fields-list py-1">
<Draggable v-model="fields" item-key="id" @change="onMove($event)">
<template #item="{ element: field, index: index }">
<div
v-show="filteredFieldList.includes(field)"
:key="field.id"
class="px-2 py-1 flex items-center"
:data-testid="`nc-fields-menu-${field.title}`"
@click.stop
>
<a-checkbox
v-model:checked="field.show"
v-e="['a:fields:show-hide']"
class="shrink"
:disabled="field.isViewEssentialField"
@change="saveOrUpdate(field, index)"
>
<div v-show="filteredFieldList.includes(field)" :key="field.id" class="px-2 py-1 flex items-center"
:data-testid="`nc-fields-menu-${field.title}`" @click.stop>
<a-checkbox v-model:checked="field.show" v-e="['a:fields:show-hide']" class="shrink"
:disabled="field.isViewEssentialField" @change="saveOrUpdate(field, index)">
<div class="flex items-center">
<component :is="getIcon(metaColumnById[field.fk_column_id])" />

3
packages/nc-gui/components/smartsheet/toolbar/MappedBy.vue

@ -14,6 +14,8 @@ import {
watch,
} from '#imports'
const { eventBus } = useSmartsheetStoreOrThrow()
const meta = inject(MetaInj, ref())
const activeView = inject(ActiveViewInj, ref())
@ -48,6 +50,7 @@ const geoDataMappingFieldColumnId = computed({
await loadMapMeta()
await loadMapData()
;(activeView.value?.view as MapType).fk_geo_data_col_id = val
eventBus.emit(SmartsheetStoreEvents.MAPPED_BY_COLUMN_CHANGE)
}
},
})

2
packages/nc-gui/composables/useViewColumns.ts

@ -1,4 +1,4 @@
import { isSystemColumn } from 'nocodb-sdk'
import { isSystemColumn, MapType, ViewTypes } from 'nocodb-sdk'
import type { ColumnType, TableType, ViewType } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue'
import { IsPublicInj, computed, inject, ref, useNuxtApp, useProject, useUIPermission, watch } from '#imports'

1
packages/nc-gui/lib/enums.ts

@ -88,6 +88,7 @@ export enum SmartsheetStoreEvents {
DATA_RELOAD = 'data-reload',
FIELD_RELOAD = 'field-reload',
FIELD_ADD = 'field-add',
MAPPED_BY_COLUMN_CHANGE = 'mapped-by-column-change',
}
export enum DataSourcesSubTab {

Loading…
Cancel
Save