{
:relation="relation"
:table-title="meta?.title"
:related-table-title="relatedTableMeta?.title"
- :display-value="row.row[displayValueProp]"
+ :display-value="headerDisplayValue"
:header="$t('activity.addNewLink')"
/>
@@ -315,6 +316,7 @@ const onCreatedRecord = (record: any) => {
:fields="fields"
:attachment="attachmentCol"
:related-table-display-value-prop="relatedTableDisplayValueProp"
+ :display-value-type-and-format-prop="displayValueTypeAndFormatProp"
:is-loading="isChildrenExcludedListLoading[Number.parseInt(id)]"
:is-linked="isChildrenExcludedListLinked[Number.parseInt(id)]"
@expand="
diff --git a/packages/nc-gui/composables/useLTARStore.ts b/packages/nc-gui/composables/useLTARStore.ts
index abf2a544e7..623dd8008a 100644
--- a/packages/nc-gui/composables/useLTARStore.ts
+++ b/packages/nc-gui/composables/useLTARStore.ts
@@ -1,4 +1,14 @@
-import type { ColumnType, LinkToAnotherRecordType, PaginatedType, RequestParams, TableType } from 'nocodb-sdk'
+import {
+ UITypes,
+ type ColumnType,
+ type LinkToAnotherRecordType,
+ type PaginatedType,
+ type RequestParams,
+ type TableType,
+ dateFormats,
+ timeFormats,
+ parseStringDateTime,
+} from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue'
import {
IsPublicInj,
@@ -20,6 +30,7 @@ import {
useRouter,
useSharedView,
watch,
+ parseProp,
} from '#imports'
import type { Row } from '#imports'
@@ -124,10 +135,52 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
const relatedTablePrimaryKeyProps = computed(() => {
return relatedTableMeta.value?.columns?.filter((c) => c.pk)?.map((c) => c.title) ?? []
})
+
const displayValueProp = computed(() => {
return (meta.value?.columns?.find((c: Required) => c.pv) || relatedTableMeta?.value?.columns?.[0])?.title
})
+ const displayValueTypeAndFormatProp = computed(() => {
+ let displayValueTypeAndFormat = {
+ type: '',
+ format: '',
+ }
+ let currentColumn = relatedTableMeta.value?.columns?.find((c) => c.pv) || relatedTableMeta?.value?.columns?.[0]
+
+ if (currentColumn) {
+ if (currentColumn?.uidt === UITypes.DateTime) {
+ displayValueTypeAndFormat = {
+ type: currentColumn?.uidt,
+ format: `${parseProp(currentColumn?.meta)?.date_format ?? dateFormats[0]} ${
+ parseProp(currentColumn?.meta)?.time_format ?? timeFormats[0]
+ }`,
+ }
+ }
+ if (currentColumn?.uidt === UITypes.Time) {
+ displayValueTypeAndFormat = {
+ type: currentColumn?.uidt,
+ format: `${timeFormats[0]}`,
+ }
+ }
+ }
+ return displayValueTypeAndFormat
+ })
+
+ const headerDisplayValue = computed(() => {
+ if (
+ row.value.row[displayValueProp.value] &&
+ displayValueTypeAndFormatProp.value.type &&
+ displayValueTypeAndFormatProp.value.format
+ ) {
+ 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) => {
if (activeState) newRowState.state = activeState
try {
@@ -470,6 +523,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
relatedTableMeta,
loadRelatedTableMeta,
relatedTableDisplayValueProp,
+ displayValueTypeAndFormatProp,
childrenExcludedList,
childrenList,
childrenListCount,
@@ -491,6 +545,7 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
isChildrenExcludedLoading,
deleteRelatedRow,
getRelatedTableRowId,
+ headerDisplayValue
}
},
'ltar-store',
diff --git a/packages/nc-gui/context/index.ts b/packages/nc-gui/context/index.ts
index a6f1106d99..240adb3e8d 100644
--- a/packages/nc-gui/context/index.ts
+++ b/packages/nc-gui/context/index.ts
@@ -13,6 +13,7 @@ export const IsFormInj: InjectionKey[> = Symbol('is-form-injection')
export const IsSurveyFormInj: InjectionKey][> = Symbol('is-survey-form-injection')
export const IsGridInj: InjectionKey][> = Symbol('is-grid-injection')
export const IsGroupByInj: InjectionKey][> = Symbol('is-group-by-injection')
+export const IsGroupByLabelInj: InjectionKey][> = Symbol('is-group-by-label-injection')
export const IsGalleryInj: InjectionKey][> = Symbol('is-gallery-injection')
export const IsKanbanInj: InjectionKey][> = Symbol('is-kanban-injection')
export const IsLockedInj: InjectionKey][> = Symbol('is-locked-injection')
diff --git a/packages/nocodb-sdk/src/lib/dateTimeHelper.ts b/packages/nocodb-sdk/src/lib/dateTimeHelper.ts
index 7d98d29c75..e0652f13b3 100644
--- a/packages/nocodb-sdk/src/lib/dateTimeHelper.ts
+++ b/packages/nocodb-sdk/src/lib/dateTimeHelper.ts
@@ -79,14 +79,17 @@ export function parseStringDate(v: string, dateFormat: string) {
export function parseStringDateTime(
v: string,
- dateTimeFormat: string = `${dateFormats[0]} ${timeFormats[0]}`
+ dateTimeFormat: string = `${dateFormats[0]} ${timeFormats[0]}`,
+ toLocal: boolean = true
) {
- const dayjsObj = dayjs(v).local();
+ const dayjsObj = toLocal ? dayjs(v).local() : dayjs(v);
if (dayjsObj.isValid()) {
v = dayjsObj.format(dateTimeFormat);
} else {
- v = dayjs(v, dateTimeFormat).local().format(dateTimeFormat);
+ v = toLocal
+ ? dayjs(v, dateTimeFormat).local().format(dateTimeFormat)
+ : dayjs(v, dateTimeFormat).format(dateTimeFormat);
}
return v;
]