Browse Source

refactor: render elements horizontally

pull/6987/head
Pranav C 10 months ago
parent
commit
2ee55a824c
  1. 13
      packages/nc-gui/components/smartsheet/grid/GroupBy.vue
  2. 11
      packages/nc-gui/components/smartsheet/grid/GroupByLabel.vue
  3. 6
      packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
  4. 2
      packages/nc-gui/composables/useViewGroupBy.ts

13
packages/nc-gui/components/smartsheet/grid/GroupBy.vue

@ -49,8 +49,6 @@ const fullPage = computed<boolean>(() => {
return props.fullPage ?? (tableHeader.value?.offsetWidth ?? 0) > (props.viewWidth ?? 0) return props.fullPage ?? (tableHeader.value?.offsetWidth ?? 0) > (props.viewWidth ?? 0)
}) })
const { isUIAllowed } = useRoles()
const _activeGroupKeys = ref<string[] | string>() const _activeGroupKeys = ref<string[] | string>()
const activeGroups = computed<string[]>(() => { const activeGroups = computed<string[]>(() => {
@ -154,6 +152,9 @@ const parseKey = (group) => {
} }
return [key] return [key]
} }
const shouldRenderCell = (column) =>
[UITypes.Lookup, UITypes.Attachment, UITypes.Barcode, UITypes.QrCode, UITypes.Links].includes(column?.uidt)
</script> </script>
<template> <template>
@ -247,6 +248,9 @@ const parseKey = (group) => {
</span> </span>
</a-tag> </a-tag>
</template> </template>
<div v-else-if="shouldRenderCell(grp.column)" class="flex min-w-[100px] flex-wrap">
<GroupByLabel v-for="(val, ind) of parseKey(grp)" :key="ind" :model-value="val" :column="grp.column" />
</div>
<a-tag <a-tag
v-else v-else
:key="`panel-tag-${grp.column.id}-${grp.key}`" :key="`panel-tag-${grp.column.id}-${grp.key}`"
@ -270,8 +274,9 @@ const parseKey = (group) => {
<template v-if="grp.key in GROUP_BY_VARS.VAR_TITLES">{{ <template v-if="grp.key in GROUP_BY_VARS.VAR_TITLES">{{
GROUP_BY_VARS.VAR_TITLES[grp.key] GROUP_BY_VARS.VAR_TITLES[grp.key]
}}</template> }}</template>
<template v-else>
<GroupByLabel v-for="(val, ind) of parseKey(grp)" v-else :key="ind" :model-value="val" :column="grp.column"/> {{ parseKey(grp)?.join(', ') }}
</template>
</span> </span>
</a-tag> </a-tag>
</div> </div>

11
packages/nc-gui/components/smartsheet/grid/GroupByLabel.vue

@ -1,22 +1,18 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ColumnType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import { UITypes, isVirtualCol } from 'nocodb-sdk' import { isVirtualCol } from 'nocodb-sdk'
const props = defineProps<{ defineProps<{
column: ColumnType column: ColumnType
modelValue: any modelValue: any
}>() }>()
provide(ReadonlyInj, true) provide(ReadonlyInj, true)
const renderCell = computed(() =>
[UITypes.Lookup, UITypes.Attachment, UITypes.Barcode, UITypes.QrCode, UITypes.Links].includes(props.column?.uidt),
)
</script> </script>
<template> <template>
<div class="pointer-events-none"> <div class="pointer-events-none">
<LazySmartsheetRow v-if="renderCell" :row="{ row: { [column.title]: modelValue }, rowMeta: {} }"> <LazySmartsheetRow :row="{ row: { [column.title]: modelValue }, rowMeta: {} }">
<LazySmartsheetVirtualCell v-if="isVirtualCol(column)" :model-value="modelValue" class="!text-gray-600" :column="column" /> <LazySmartsheetVirtualCell v-if="isVirtualCol(column)" :model-value="modelValue" class="!text-gray-600" :column="column" />
<LazySmartsheetCell <LazySmartsheetCell
@ -28,6 +24,5 @@ const renderCell = computed(() =>
:read-only="true" :read-only="true"
/> />
</LazySmartsheetRow> </LazySmartsheetRow>
<template v-else>{{ modelValue }}</template>
</div> </div>
</template> </template>

6
packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue

@ -158,15 +158,11 @@ const loadAllowedLookups = async () => {
if (col.uidt !== UITypes.Lookup) continue if (col.uidt !== UITypes.Lookup) continue
let nextCol = col let nextCol = col
// check the lookup column is supported type or not // check the lookup column is supported type or not
while (btLookup && nextCol && nextCol.uidt === UITypes.Lookup) { while (nextCol && nextCol.uidt === UITypes.Lookup) {
const lookupRelation = (await getMeta(nextCol.fk_model_id))?.columns?.find( const lookupRelation = (await getMeta(nextCol.fk_model_id))?.columns?.find(
(c) => c.id === (nextCol.colOptions as LookupType).fk_relation_column_id, (c) => c.id === (nextCol.colOptions as LookupType).fk_relation_column_id,
) )
if ((lookupRelation.colOptions as LinkToAnotherRecordType).type !== RelationTypes.BELONGS_TO) {
continue
}
const relatedTableMeta = await getMeta((lookupRelation.colOptions as LinkToAnotherRecordType).fk_related_model_id) const relatedTableMeta = await getMeta((lookupRelation.colOptions as LinkToAnotherRecordType).fk_related_model_id)

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

@ -91,7 +91,7 @@ export const useViewGroupBy = (view: Ref<ViewType | undefined>, where?: Computed
} }
// convert to JSON string if non-string value // convert to JSON string if non-string value
if(value && typeof value === 'object') { if (value && typeof value === 'object') {
value = JSON.stringify(value) value = JSON.stringify(value)
} }

Loading…
Cancel
Save