+
+
+
+
+
+ {{ meta.title }}
+
+
+ {{ table }}
+
+ : {{ primaryValue }}
+
diff --git a/packages/nc-gui-v2/composables/useExpandedFormStore.ts b/packages/nc-gui-v2/composables/useExpandedFormStore.ts
index 2e846307e4..4882035ba0 100644
--- a/packages/nc-gui-v2/composables/useExpandedFormStore.ts
+++ b/packages/nc-gui-v2/composables/useExpandedFormStore.ts
@@ -1,3 +1,4 @@
+import { UITypes } from 'nocodb-sdk'
import type { ColumnType, TableType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import { message } from 'ant-design-vue'
@@ -7,6 +8,7 @@ import { useApi } from '~/composables/useApi'
import { useViewData } from '~/composables/useViewData'
import { ActiveViewInj } from '~/context'
import { extractPkFromRow } from '~/utils'
+import dayjs from 'dayjs'
const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState(
(meta: Ref
, row: Ref>) => {
@@ -24,6 +26,39 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState(
const { updateOrSaveRow, insertRow } = useViewData(meta, activeView as any)
+
+
+ // getters
+ const primaryValue = computed(() => {
+ if (row?.value?.row) {
+ const value= '';
+ const col = meta?.value?.columns?.find(c => c.pv);
+ if (!col) {
+ return;
+ }
+ const uidt = col.uidt;
+ if (uidt == UITypes.Date) {
+ return (/^\d+$/.test(value) ? dayjs(+value) : dayjs(value)).format('YYYY-MM-DD');
+ } else if (uidt == UITypes.DateTime) {
+ return (/^\d+$/.test(value) ? dayjs(+value) : dayjs(value)).format('YYYY-MM-DD HH:mm');
+ } else if (uidt == UITypes.Time) {
+ let dateTime = dayjs(value);
+ if (!dateTime.isValid()) {
+ dateTime = dayjs(value, 'HH:mm:ss');
+ }
+ if (!dateTime.isValid()) {
+ dateTime = dayjs(`1999-01-01 ${value}`);
+ }
+ if (!dateTime.isValid()) {
+ return value;
+ }
+ return dateTime.format('HH:mm:ss');
+ }
+ return value;
+ }
+ })
+
+
// actions
const loadCommentsAndLogs = async () => {
if (!row.value) return
@@ -58,7 +93,7 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState(
comment.value = ''
message.success('Comment added successfully')
await loadCommentsAndLogs()
- } catch (e) {
+ } catch (e: any) {
message.error(e.message)
}
@@ -74,6 +109,8 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState(
comment,
isYou,
commentsDrawer,
+ row,
+ primaryValue
}
},
'expanded-form-store',