Browse Source

fix: add links modal displayValue in header is not like cell format

pull/7361/head
Ramesh Mane 8 months ago
parent
commit
112f42d805
  1. 8
      packages/nc-gui/components/virtual-cell/components/ListChildItems.vue
  2. 10
      packages/nc-gui/components/virtual-cell/components/ListItem.vue
  3. 8
      packages/nc-gui/components/virtual-cell/components/ListItems.vue
  4. 41
      packages/nc-gui/composables/useLTARStore.ts

8
packages/nc-gui/components/virtual-cell/components/ListChildItems.vue

@ -49,7 +49,7 @@ const {
loadChildrenList, loadChildrenList,
childrenListPagination, childrenListPagination,
relatedTableDisplayValueProp, relatedTableDisplayValueProp,
relatedTableDisplayValueTypeAndFormatProp, displayValueTypeAndFormatProp,
unlink, unlink,
isChildrenListLoading, isChildrenListLoading,
isChildrenListLinked, isChildrenListLinked,
@ -58,7 +58,7 @@ const {
row, row,
link, link,
meta, meta,
displayValueProp, headerDisplayValue
} = useLTARStoreOrThrow() } = useLTARStoreOrThrow()
const { isNew, state, removeLTARRef, addLTARRef } = useSmartsheetRowStoreOrThrow() const { isNew, state, removeLTARRef, addLTARRef } = useSmartsheetRowStoreOrThrow()
@ -196,7 +196,7 @@ const linkOrUnLink = (rowRef: Record<string, string>, id: string) => {
:table-title="meta?.title" :table-title="meta?.title"
:header="$t('activity.linkedRecords')" :header="$t('activity.linkedRecords')"
:related-table-title="relatedTableMeta?.title" :related-table-title="relatedTableMeta?.title"
:display-value="row.row[displayValueProp]" :display-value="headerDisplayValue"
/> />
<div v-if="!isForm" class="flex mt-2 mb-2 items-center gap-2"> <div v-if="!isForm" class="flex mt-2 mb-2 items-center gap-2">
<div <div
@ -261,7 +261,7 @@ const linkOrUnLink = (rowRef: Record<string, string>, id: string) => {
data-testid="nc-child-list-item" data-testid="nc-child-list-item"
:attachment="attachmentCol" :attachment="attachmentCol"
:related-table-display-value-prop="relatedTableDisplayValueProp" :related-table-display-value-prop="relatedTableDisplayValueProp"
:related-table-display-value-type-and-format-prop="relatedTableDisplayValueTypeAndFormatProp" :display-value-type-and-format-prop="displayValueTypeAndFormatProp"
:is-linked="childrenList?.list ? isChildrenListLinked[Number.parseInt(id)] : true" :is-linked="childrenList?.list ? isChildrenListLinked[Number.parseInt(id)] : true"
:is-loading="isChildrenListLoading[Number.parseInt(id)]" :is-loading="isChildrenListLoading[Number.parseInt(id)]"
@expand="onClick(refRow)" @expand="onClick(refRow)"

10
packages/nc-gui/components/virtual-cell/components/ListItem.vue

@ -22,7 +22,7 @@ const props = defineProps<{
fields: any[] fields: any[]
attachment: any attachment: any
relatedTableDisplayValueProp: string relatedTableDisplayValueProp: string
relatedTableDisplayValueTypeAndFormatProp: { type: string; format: string } displayValueTypeAndFormatProp: { type: string; format: string }
isLoading: boolean isLoading: boolean
isLinked: boolean isLinked: boolean
}>() }>()
@ -73,13 +73,13 @@ const attachments: ComputedRef<Attachment[]> = computed(() => {
const displayValue = computed(() => { const displayValue = computed(() => {
if ( if (
row.value[props.relatedTableDisplayValueProp] && row.value[props.relatedTableDisplayValueProp] &&
props.relatedTableDisplayValueTypeAndFormatProp.type && props.displayValueTypeAndFormatProp.type &&
props.relatedTableDisplayValueTypeAndFormatProp.format props.displayValueTypeAndFormatProp.format
) { ) {
return parseStringDateTime( return parseStringDateTime(
row.value[props.relatedTableDisplayValueProp], row.value[props.relatedTableDisplayValueProp],
props.relatedTableDisplayValueTypeAndFormatProp.format, props.displayValueTypeAndFormatProp.format,
!(props.relatedTableDisplayValueTypeAndFormatProp.format === UITypes.Time), !(props.displayValueTypeAndFormatProp.format === UITypes.Time),
) )
} }
return row.value[props.relatedTableDisplayValueProp] return row.value[props.relatedTableDisplayValueProp]

8
packages/nc-gui/components/virtual-cell/components/ListItems.vue

@ -37,19 +37,19 @@ const {
childrenExcludedList, childrenExcludedList,
isChildrenExcludedListLinked, isChildrenExcludedListLinked,
isChildrenExcludedListLoading, isChildrenExcludedListLoading,
displayValueProp,
isChildrenExcludedLoading, isChildrenExcludedLoading,
childrenListCount, childrenListCount,
loadChildrenExcludedList, loadChildrenExcludedList,
loadChildrenList, loadChildrenList,
childrenExcludedListPagination, childrenExcludedListPagination,
relatedTableDisplayValueProp, relatedTableDisplayValueProp,
relatedTableDisplayValueTypeAndFormatProp, displayValueTypeAndFormatProp,
link, link,
relatedTableMeta, relatedTableMeta,
meta, meta,
unlink, unlink,
row, row,
headerDisplayValue
} = useLTARStoreOrThrow() } = useLTARStoreOrThrow()
const { addLTARRef, isNew, removeLTARRef, state: rowState } = useSmartsheetRowStoreOrThrow() const { addLTARRef, isNew, removeLTARRef, state: rowState } = useSmartsheetRowStoreOrThrow()
@ -236,7 +236,7 @@ const onCreatedRecord = (record: any) => {
:relation="relation" :relation="relation"
:table-title="meta?.title" :table-title="meta?.title"
:related-table-title="relatedTableMeta?.title" :related-table-title="relatedTableMeta?.title"
:display-value="row.row[displayValueProp]" :display-value="headerDisplayValue"
:header="$t('activity.addNewLink')" :header="$t('activity.addNewLink')"
/> />
<div class="flex mt-2 mb-2 items-center gap-2"> <div class="flex mt-2 mb-2 items-center gap-2">
@ -316,7 +316,7 @@ const onCreatedRecord = (record: any) => {
:fields="fields" :fields="fields"
:attachment="attachmentCol" :attachment="attachmentCol"
:related-table-display-value-prop="relatedTableDisplayValueProp" :related-table-display-value-prop="relatedTableDisplayValueProp"
:related-table-display-value-type-and-format-prop="relatedTableDisplayValueTypeAndFormatProp" :display-value-type-and-format-prop="displayValueTypeAndFormatProp"
:is-loading="isChildrenExcludedListLoading[Number.parseInt(id)]" :is-loading="isChildrenExcludedListLoading[Number.parseInt(id)]"
:is-linked="isChildrenExcludedListLinked[Number.parseInt(id)]" :is-linked="isChildrenExcludedListLinked[Number.parseInt(id)]"
@expand=" @expand="

41
packages/nc-gui/composables/useLTARStore.ts

@ -7,6 +7,7 @@ import {
type TableType, type TableType,
dateFormats, dateFormats,
timeFormats, timeFormats,
parseStringDateTime,
} from 'nocodb-sdk' } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import { import {
@ -131,8 +132,16 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
return (relatedTableMeta.value?.columns?.find((c) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title || '' return (relatedTableMeta.value?.columns?.find((c) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title || ''
}) })
const relatedTableDisplayValueTypeAndFormatProp = computed(() => { const relatedTablePrimaryKeyProps = computed(() => {
let dateOrDateTimeFieldTypeAndFormat = { return relatedTableMeta.value?.columns?.filter((c) => c.pk)?.map((c) => c.title) ?? []
})
const displayValueProp = computed(() => {
return (meta.value?.columns?.find((c: Required<ColumnType>) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title
})
const displayValueTypeAndFormatProp = computed(() => {
let displayValueTypeAndFormat = {
type: '', type: '',
format: '', format: '',
} }
@ -140,7 +149,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
if (currentColumn) { if (currentColumn) {
if (currentColumn?.uidt === UITypes.DateTime) { if (currentColumn?.uidt === UITypes.DateTime) {
dateOrDateTimeFieldTypeAndFormat = { displayValueTypeAndFormat = {
type: currentColumn?.uidt, type: currentColumn?.uidt,
format: `${parseProp(currentColumn?.meta)?.date_format ?? dateFormats[0]} ${ format: `${parseProp(currentColumn?.meta)?.date_format ?? dateFormats[0]} ${
parseProp(currentColumn?.meta)?.time_format ?? timeFormats[0] parseProp(currentColumn?.meta)?.time_format ?? timeFormats[0]
@ -148,21 +157,28 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
} }
} }
if (currentColumn?.uidt === UITypes.Time) { if (currentColumn?.uidt === UITypes.Time) {
dateOrDateTimeFieldTypeAndFormat = { displayValueTypeAndFormat = {
type: currentColumn?.uidt, type: currentColumn?.uidt,
format: `${timeFormats[0]}`, format: `${timeFormats[0]}`,
} }
} }
} }
return dateOrDateTimeFieldTypeAndFormat return displayValueTypeAndFormat
}) })
const relatedTablePrimaryKeyProps = computed(() => { const headerDisplayValue = computed(() => {
return relatedTableMeta.value?.columns?.filter((c) => c.pk)?.map((c) => c.title) ?? [] if (
}) row.value.row[displayValueProp.value] &&
displayValueTypeAndFormatProp.value.type &&
const displayValueProp = computed(() => { displayValueTypeAndFormatProp.value.format
return (meta.value?.columns?.find((c: Required<ColumnType>) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title ) {
return parseStringDateTime(
row.value.row[displayValueProp.value],
displayValueTypeAndFormatProp.value.format,
!(displayValueTypeAndFormatProp.value.format === UITypes.Time),
)
}
return row.value.row[displayValueProp.value]
}) })
const loadChildrenExcludedList = async (activeState?: any) => { const loadChildrenExcludedList = async (activeState?: any) => {
@ -507,7 +523,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
relatedTableMeta, relatedTableMeta,
loadRelatedTableMeta, loadRelatedTableMeta,
relatedTableDisplayValueProp, relatedTableDisplayValueProp,
relatedTableDisplayValueTypeAndFormatProp, displayValueTypeAndFormatProp,
childrenExcludedList, childrenExcludedList,
childrenList, childrenList,
childrenListCount, childrenListCount,
@ -529,6 +545,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
isChildrenExcludedLoading, isChildrenExcludedLoading,
deleteRelatedRow, deleteRelatedRow,
getRelatedTableRowId, getRelatedTableRowId,
headerDisplayValue
} }
}, },
'ltar-store', 'ltar-store',

Loading…
Cancel
Save