多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

479 lines
13 KiB

import type { AuditType, ColumnType, CommentType, TableType } from 'nocodb-sdk'
import { UITypes, ViewTypes, isVirtualCol } from 'nocodb-sdk'
import type { Ref } from 'vue'
import dayjs from 'dayjs'
const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((meta: Ref<TableType>, _row: Ref<Row>) => {
const { $e, $state, $api } = useNuxtApp()
const { t } = useI18n()
const isPublic = inject(IsPublicInj, ref(false))
const comments = ref<
Array<
CommentType & {
created_display_name: string
}
>
>([])
const audits = ref<Array<AuditType>>([])
const isCommentsLoading = ref(false)
const isAuditLoading = ref(false)
const comment = ref('')
const commentsDrawer = ref(true)
const saveRowAndStay = ref(0)
const changedColumns = ref(new Set<string>())
const basesStore = useBases()
const { basesUser } = storeToRefs(basesStore)
const { base } = storeToRefs(useBase())
const baseUsers = computed(() => (meta.value.base_id ? basesUser.value.get(meta.value.base_id) || [] : []))
const { sharedView } = useSharedView()
const row = ref<Row>(
!sharedView.value ||
sharedView.value?.type === ViewTypes.GALLERY ||
sharedView.value?.type === ViewTypes.KANBAN ||
_row.value?.rowMeta?.new
? _row.value
: ({ row: {}, oldRow: {}, rowMeta: {} } as Row),
)
if (row.value?.rowMeta?.fromExpandedForm) {
row.value.rowMeta.fromExpandedForm = true
}
const rowStore = useProvideSmartsheetRowStore(row)
const activeView = inject(ActiveViewInj, ref())
const { addUndo, clone, defineViewScope } = useUndoRedo()
const reloadTrigger = inject(ReloadRowDataHookInj, createEventHook())
const { isUIAllowed } = useRoles()
feat: Improved UI (#6222) * feat: Improved ui (#6156) * refactor: revert Signed-off-by: Pranav C <pranavxc@gmail.com> feat: shared base Signed-off-by: Pranav C <pranavxc@gmail.com> fix: remove duplicate import statement Signed-off-by: Pranav C <pranavxc@gmail.com> fix: disable starred & license menu Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: fix airtable wait issue Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: enable mysql in ci Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: fix checkbox order for sqlite Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: disable quick tests Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: fix dbType env variable for CI Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: workspace API access error fix Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: enable SQLite CI CD Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: use DB_TYPE env variable Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: enable SQLite UT Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: isHub cleanup Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: add check for EE Timezone spec Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> chore: cleanup Signed-off-by: Pranav C <pranavxc@gmail.com> chore: cleanup Signed-off-by: Pranav C <pranavxc@gmail.com> test: EE check fix Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> chore: test correction Signed-off-by: Pranav C <pranavxc@gmail.com> chore: sync latest changes Signed-off-by: Pranav C <pranavxc@gmail.com> test: set EE=false Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> test: set NC Edition to community in workflow file Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> chore: update sdk build command Signed-off-by: Pranav C <pranavxc@gmail.com> refactor: i18n and other changes Signed-off-by: Pranav C <pranavxc@gmail.com> feat: new ui Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: sync tests Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: lint Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: shared view/base related bugs Signed-off-by: Pranav C <pranavxc@gmail.com> * test: checkbox verification sort order fix Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: fix sqlite reset Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: enable selfhosted runners Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * docs: table ops (draft) Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * Docs: screenshots for table-operations.md * refactor: introduce missing buttons Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: get all fields Signed-off-by: Pranav C <pranavxc@gmail.com> * test: UT fix- new data API response Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: EE is false Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: webhook lookup as string in CE Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * fix: include created_at and updated_at Signed-off-by: Pranav C <pranavxc@gmail.com> * test: fix UT newDataAPI response for PG Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * fix: separate api for webhook related plugins Signed-off-by: Pranav C <pranavxc@gmail.com> * test: msyql filter corrections Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: mysql group by test corrections Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: fix datatype for rating field in groupby spec for pg Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: kanban datatype correction Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: column edit for mysql- rating field Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: misc fixes Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: enable 4 workers Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: enable 2 workers per shard only Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * docs: table CRUD * Rename table-operations.md to table-crud.md * Create column-crud.md * docs: row CRUD * Rename row.md to row-crud.md * docs: project crud * docs: toolbar (skeleton) * refactor: single page UI and bug fixes Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: sync tests playwright Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: add missing dependency Signed-off-by: Pranav C <pranavxc@gmail.com> * feat: single page ui, test corrections Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: tests Signed-off-by: Pranav C <pranavxc@gmail.com> * test: project rename test correction Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: remove only Signed-off-by: Pranav C <pranavxc@gmail.com> * test: remove wrong import statement Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: delete option not visible in project context menu Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: move ws access within isEE() Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: fix groupby * test: groupby fix Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * docs: signup & landing page * docs: project crud * docs: project-crud misc * docs: toolbar fields * docs: toolbar / filters * docs: toolbar / group by * docs: toolbar / sort * docs: toolbar / row height * docs: filters additional options * docs: file re-order Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * docs: add links to column types * docs: code snippets * docs: links * docs: lookup * docs: rollup * docs: formula * docs: primary key * docs: display value * docs: development setup * docs: swagger * fix(nc-gui): encodeURIComponent for row id - closes: #6202 * docs: language * docs: expanded record * docs: import airtable * docs: airtable * docs: webhook * docs: revert file rename Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * docs: account settings * docs: audit * docs: meta management * docs: project settings * docs: shared base * docs: shared view * docs: meta sync * docs: team-auth * docs: views * docs: fix URL * docs: URL corrections * fix: shared base, view related bugs Signed-off-by: Pranav C <pranavxc@gmail.com> * test: EE check for WSaccess Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * test: exclude EE tests Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> * fix: missing project delete closes #6215 Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: merge existing project meta if found closes #6216 Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: merge existing project meta if found closes #6216 Signed-off-by: Pranav C <pranavxc@gmail.com> --------- Signed-off-by: Pranav C <pranavxc@gmail.com> Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com> Co-authored-by: DarkPhoenix2704 <anbarasun123@gmail.com> Co-authored-by: Wing-Kam Wong <wingkwong.code@gmail.com> * refactor: docs and other bug fixes Signed-off-by: Pranav C <pranavxc@gmail.com> * feat: populate default project on super admin signup Signed-off-by: Pranav C <pranavxc@gmail.com> * fix: include created project details in signup response if avail, missing Dockerfile Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: use custom function for resolving ts path aliases Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: add missing generate script Signed-off-by: Pranav C <pranavxc@gmail.com> * chore: webpack build correction - ts path resolve Signed-off-by: Pranav C <pranavxc@gmail.com> --------- Signed-off-by: Pranav C <pranavxc@gmail.com> Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> Co-authored-by: mertmit <mertmit99@gmail.com> Co-authored-by: Raju Udava <86527202+dstala@users.noreply.github.com> Co-authored-by: DarkPhoenix2704 <anbarasun123@gmail.com> Co-authored-by: Wing-Kam Wong <wingkwong.code@gmail.com>
1 year ago
// getters
const displayValue = computed(() => {
if (row?.value?.row) {
const col = meta?.value?.columns?.find((c) => c.pv)
if (!col) {
return
}
const value = row.value.row?.[col.title as string]
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
}
})
const primaryKey = computed(() => {
return extractPkFromRow(row.value.row, meta.value.columns as ColumnType[])
})
const loadComments = async () => {
if (!isUIAllowed('commentList') || !row.value) return
const rowId = extractPkFromRow(row.value.row, meta.value.columns as ColumnType[])
if (!rowId) return
try {
isCommentsLoading.value = true
const res = ((
await $api.utils.commentList({
row_id: rowId,
fk_model_id: meta.value.id as string,
})
).list || []) as Array<
CommentType & {
created_display_name: string
}
>
comments.value = res.map((comment) => {
const user = baseUsers.value.find((u) => u.id === comment.created_by)
return {
...comment,
created_display_name: user?.display_name ?? (user?.email ?? '').split('@')[0],
}
})
} catch (e: any) {
message.error(e.message)
} finally {
isCommentsLoading.value = false
}
}
const deleteComment = async (commentId: string) => {
if (!isUIAllowed('commentDelete')) return
try {
await $api.utils.commentDelete(commentId)
await loadComments()
} catch (e: any) {
message.error(e.message)
}
}
const loadAudits = async () => {
if (!isUIAllowed('auditList') || !row.value) return
const rowId = extractPkFromRow(row.value.row, meta.value.columns as ColumnType[])
if (!rowId) return
try {
isAuditLoading.value = true
audits.value =
(
await $api.utils.auditList({
row_id: rowId,
fk_model_id: meta.value.id as string,
})
).list?.reverse?.() || []
} catch (e: any) {
message.error(e.message)
} finally {
isAuditLoading.value = false
}
}
const isYou = (email: string) => {
return $state.user?.value?.email === email
}
const loadKanbanData = async () => {
if (activeView.value?.type === ViewTypes.KANBAN) {
const { loadKanbanData: _loadKanbanData } = useKanbanViewStoreOrThrow()
await _loadKanbanData()
}
}
const saveComment = async () => {
try {
if (!row.value || !comment.value) return
const rowId = extractPkFromRow(row.value.row, meta.value.columns as ColumnType[])
if (!rowId) return
await $api.utils.commentRow({
fk_model_id: meta.value?.id as string,
row_id: rowId,
comment: `${comment.value}`,
})
reloadTrigger?.trigger()
await Promise.all([loadComments(), loadAudits()])
comment.value = ''
} catch (e: any) {
message.error(e.message)
}
$e('a:row-expand:comment')
}
const save = async (
ltarState: Record<string, any> = {},
undo = false,
// TODO: Hack. Remove this when kanban injection store issue is resolved
{
kanbanClbk,
}: {
kanbanClbk?: (row: Row, isNewRow: boolean) => void
} = {},
) => {
if (!meta.value.id) return
let data
const isNewRow = row.value.rowMeta?.new ?? false
if (isNewRow) {
const { getMeta } = useMetas()
const { missingRequiredColumns, insertObj } = await populateInsertObject({
meta: meta.value,
ltarState,
getMeta,
row: row.value.row,
throwError: true,
})
if (missingRequiredColumns.size) return
data = await $api.dbTableRow.create('noco', base.value.id as string, meta.value.id, {
...insertObj,
...(ltarState || {}),
})
Object.assign(row.value, {
row: data,
rowMeta: {},
oldRow: { ...data },
})
if (!undo) {
const id = extractPkFromRow(data, meta.value?.columns as ColumnType[])
const pkData = rowPkData(row.value.row, meta.value?.columns as ColumnType[])
// TODO remove linked record
addUndo({
redo: {
fn: async (rowData: any) => {
await $api.dbTableRow.create('noco', base.value.id as string, meta.value.id, { ...pkData, ...rowData })
await loadKanbanData()
reloadTrigger?.trigger()
},
args: [clone(insertObj)],
},
undo: {
fn: async (id: string) => {
const res: any = await $api.dbViewRow.delete(
'noco',
base.value.id as string,
meta.value?.id as string,
activeView.value?.id as string,
encodeURIComponent(id),
)
if (res.message) {
throw new Error(res.message)
}
await loadKanbanData()
reloadTrigger?.trigger()
},
args: [id],
},
scope: defineViewScope({ view: activeView.value }),
})
}
} else {
const updateOrInsertObj = [...changedColumns.value].reduce((obj, col) => {
obj[col] = row.value.row[col]
return obj
}, {} as Record<string, any>)
if (Object.keys(updateOrInsertObj).length) {
const id = extractPkFromRow(row.value.row, meta.value.columns as ColumnType[])
if (!id) {
return message.info("Update not allowed for table which doesn't have primary Key")
}
await $api.dbTableRow.update(NOCO, base.value.id as string, meta.value.id, encodeURIComponent(id), updateOrInsertObj)
if (!undo) {
const undoObject = [...changedColumns.value].reduce((obj, col) => {
obj[col] = row.value.oldRow[col]
return obj
}, {} as Record<string, any>)
addUndo({
redo: {
fn: async (id: string, data: Record<string, any>) => {
await $api.dbTableRow.update(NOCO, base.value.id as string, meta.value.id!, encodeURIComponent(id), data)
await loadKanbanData()
reloadTrigger?.trigger()
},
args: [id, clone(updateOrInsertObj)],
},
undo: {
fn: async (id: string, data: Record<string, any>) => {
await $api.dbTableRow.update(NOCO, base.value.id as string, meta.value.id!, encodeURIComponent(id), data)
await loadKanbanData()
reloadTrigger?.trigger()
},
args: [id, clone(undoObject)],
},
scope: defineViewScope({ view: activeView.value }),
})
}
if (commentsDrawer.value) {
await Promise.all([loadComments(), loadAudits()])
}
} else {
// No columns to update
message.info(t('msg.info.noColumnsToUpdate'))
return
}
}
if (activeView.value?.type === ViewTypes.KANBAN && kanbanClbk) {
kanbanClbk(row.value, isNewRow)
}
changedColumns.value = new Set()
$e('a:row-expand:add')
return data
}
const clearColumns = () => {
changedColumns.value = new Set()
}
Nc fix/expanded for UI changes (#8452) * fix(nc-gui): expanded form new UI changes setup * fix(nc-gui): update expanded form fields panel style * fix(nc-gui): update expanded form header * fix(nc-gui): update expanded form footer * fix(nc-gui): update expanded form comment section * fix(nc-gui): expanded form comment section ui changes * fix(nc-gui): incorrect duplicate icon * fix(nc-gui): add table icon & title in expanded form header * fix(nc-gui): allow multiline comment display in expanded form * fix(nc-gui): add column header menu & edit column option in exapanded form * fix(nc-gui): updated header cell component * fix(nc-gui): update field context menu for expanded form * fix(nc-gui): expanded form column duplidate issue * fix(nc-gui): pr review changes * fix(nc-gui): update expanded form field menu option icon & text * fix(nc-gui): expanded form field rename, show hidden field data update issue * fix(nc-gui): small changes * fix(nc-gui): update comment section * fix(nc-gui): show expanded form field menu only if user has the permission * fix(nc-gui): add expanded form comment input shadow * fix(nc-gui): hide expanded form field menu options in mobile screen * fix(nc-gui): use drawer insted of modal for expanded form in mobile view * fix(nc-gui): expanded form responsive issue * fix(nc-gui): expanded form skeleton issue * fix(nc-gui): some review comments * fix(nc-gui): increase font size of field label from expanded form * fix(nc-gui): reduce expanded form field width * fix(nc-gui): add comment and audit icons * fix(nc-gui): comment box style * fix(nc-gui): some pr review comments * fix(nc-gui): add tooltip for navigation btns * fix(nc-gui): expanded form field menu placement issue * fix(nc-gui): add box shodow on expanded form input boxes * fix(nc-gui): reduce height of field icon from expanded form * fix(nc-gui): expanded form test fail issue * chore(nc-gui): lint * fix(nc-gui): role access test fail issue * fix(nc-gui): review changes * fix(nc-gui): small changes * fix(nc-gui): overflow issue * fix(nc-gui): navigation btn style issue * fix(nc-gui): expanded form field row max width * fix(nc-gui): update comment item user name color and font weight * fix(nc-gui): increase comment input box padding
6 months ago
const loadRow = async (rowId?: string, onlyVirtual = false, onlyNewColumns = false) => {
if (row?.value?.rowMeta?.new || isPublic.value || !meta.value?.id) return
const recordId = rowId ?? extractPkFromRow(row.value.row, meta.value.columns as ColumnType[])
if (!recordId) return
let record: Record<string, any> = {}
try {
record = await $api.dbTableRow.read(
NOCO,
// todo: base_id missing on view type
((base?.value?.id ?? meta.value?.base_id) || (sharedView.value?.view as any)?.base_id) as string,
meta.value.id as string,
encodeURIComponent(recordId),
{
getHiddenColumn: true,
},
)
} catch (err: any) {
if (err.response?.status === 404) {
const router = useRouter()
message.error(t('msg.noRecordFound'))
router.replace({ query: {} })
} else {
message.error(`${await extractSdkResponseErrorMsg(err)}`)
}
}
try {
// update only virtual columns value if `onlyVirtual` is true
if (onlyVirtual) {
record = {
...row.value.row,
...(meta.value.columns ?? []).reduce((partialRecord, col) => {
if (isVirtualCol(col) && col.title && col.title in record) {
partialRecord[col.title] = (record as Record<string, any>)[col.title as string]
}
return partialRecord
}, {} as Record<string, any>),
Nc fix/expanded for UI changes (#8452) * fix(nc-gui): expanded form new UI changes setup * fix(nc-gui): update expanded form fields panel style * fix(nc-gui): update expanded form header * fix(nc-gui): update expanded form footer * fix(nc-gui): update expanded form comment section * fix(nc-gui): expanded form comment section ui changes * fix(nc-gui): incorrect duplicate icon * fix(nc-gui): add table icon & title in expanded form header * fix(nc-gui): allow multiline comment display in expanded form * fix(nc-gui): add column header menu & edit column option in exapanded form * fix(nc-gui): updated header cell component * fix(nc-gui): update field context menu for expanded form * fix(nc-gui): expanded form column duplidate issue * fix(nc-gui): pr review changes * fix(nc-gui): update expanded form field menu option icon & text * fix(nc-gui): expanded form field rename, show hidden field data update issue * fix(nc-gui): small changes * fix(nc-gui): update comment section * fix(nc-gui): show expanded form field menu only if user has the permission * fix(nc-gui): add expanded form comment input shadow * fix(nc-gui): hide expanded form field menu options in mobile screen * fix(nc-gui): use drawer insted of modal for expanded form in mobile view * fix(nc-gui): expanded form responsive issue * fix(nc-gui): expanded form skeleton issue * fix(nc-gui): some review comments * fix(nc-gui): increase font size of field label from expanded form * fix(nc-gui): reduce expanded form field width * fix(nc-gui): add comment and audit icons * fix(nc-gui): comment box style * fix(nc-gui): some pr review comments * fix(nc-gui): add tooltip for navigation btns * fix(nc-gui): expanded form field menu placement issue * fix(nc-gui): add box shodow on expanded form input boxes * fix(nc-gui): reduce height of field icon from expanded form * fix(nc-gui): expanded form test fail issue * chore(nc-gui): lint * fix(nc-gui): role access test fail issue * fix(nc-gui): review changes * fix(nc-gui): small changes * fix(nc-gui): overflow issue * fix(nc-gui): navigation btn style issue * fix(nc-gui): expanded form field row max width * fix(nc-gui): update comment item user name color and font weight * fix(nc-gui): increase comment input box padding
6 months ago
}
}
// update only new/duplicated/renamed columns value if `onlyNewColumns` is true
if (onlyNewColumns) {
record = Object.keys(record).reduce((acc, curr) => {
if (!Object.prototype.hasOwnProperty.call(row.value.row, curr)) {
acc[curr] = record[curr]
} else {
acc[curr] = row.value.row[curr]
}
return acc
}, {} as Record<string, any>)
}
Nc fix/expanded for UI changes (#8452) * fix(nc-gui): expanded form new UI changes setup * fix(nc-gui): update expanded form fields panel style * fix(nc-gui): update expanded form header * fix(nc-gui): update expanded form footer * fix(nc-gui): update expanded form comment section * fix(nc-gui): expanded form comment section ui changes * fix(nc-gui): incorrect duplicate icon * fix(nc-gui): add table icon & title in expanded form header * fix(nc-gui): allow multiline comment display in expanded form * fix(nc-gui): add column header menu & edit column option in exapanded form * fix(nc-gui): updated header cell component * fix(nc-gui): update field context menu for expanded form * fix(nc-gui): expanded form column duplidate issue * fix(nc-gui): pr review changes * fix(nc-gui): update expanded form field menu option icon & text * fix(nc-gui): expanded form field rename, show hidden field data update issue * fix(nc-gui): small changes * fix(nc-gui): update comment section * fix(nc-gui): show expanded form field menu only if user has the permission * fix(nc-gui): add expanded form comment input shadow * fix(nc-gui): hide expanded form field menu options in mobile screen * fix(nc-gui): use drawer insted of modal for expanded form in mobile view * fix(nc-gui): expanded form responsive issue * fix(nc-gui): expanded form skeleton issue * fix(nc-gui): some review comments * fix(nc-gui): increase font size of field label from expanded form * fix(nc-gui): reduce expanded form field width * fix(nc-gui): add comment and audit icons * fix(nc-gui): comment box style * fix(nc-gui): some pr review comments * fix(nc-gui): add tooltip for navigation btns * fix(nc-gui): expanded form field menu placement issue * fix(nc-gui): add box shodow on expanded form input boxes * fix(nc-gui): reduce height of field icon from expanded form * fix(nc-gui): expanded form test fail issue * chore(nc-gui): lint * fix(nc-gui): role access test fail issue * fix(nc-gui): review changes * fix(nc-gui): small changes * fix(nc-gui): overflow issue * fix(nc-gui): navigation btn style issue * fix(nc-gui): expanded form field row max width * fix(nc-gui): update comment item user name color and font weight * fix(nc-gui): increase comment input box padding
6 months ago
Object.assign(row.value, {
row: record,
oldRow: { ...record },
rowMeta: {},
})
} catch (e: any) {
message.error(`${t('msg.error.errorLoadingRecord')}`)
}
}
const deleteRowById = async (rowId?: string) => {
try {
const recordId = rowId ?? extractPkFromRow(row.value.row, meta.value.columns as ColumnType[])
const res: { message?: string[] } | number = await $api.dbTableRow.delete(
NOCO,
base.value.id as string,
meta.value.id as string,
encodeURIComponent(recordId),
)
if (res.message) {
message.info(
`Record delete failed: ${`Unable to delete record with ID ${rowId} because of the following:
\n${res.message.join('\n')}.\n
Clear the data first & try again`})}`,
)
return false
}
} catch (e: any) {
message.error(`${t('msg.error.deleteFailed')}: ${await extractSdkResponseErrorMsg(e)}`)
}
}
const updateComment = async (commentId: string, comment: Partial<CommentType>) => {
return await $api.utils.commentUpdate(commentId, comment)
}
return {
...rowStore,
loadComments,
deleteComment,
loadAudits,
comments,
audits,
isAuditLoading,
isCommentsLoading,
saveComment,
comment,
isYou,
commentsDrawer,
row,
deleteRowById,
displayValue,
save,
changedColumns,
loadRow,
primaryKey,
saveRowAndStay,
updateComment,
clearColumns,
}
}, 'expanded-form-store')
export { useProvideExpandedFormStore }
export function useExpandedFormStoreOrThrow() {
const expandedFormStore = useExpandedFormStore()
if (expandedFormStore == null) throw new Error('Please call `useExpandedFormStore` on the appropriate parent component')
return expandedFormStore
}