mirror of https://github.com/nocodb/nocodb
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.
669 lines
19 KiB
669 lines
19 KiB
2 years ago
|
<script lang="ts" setup>
|
||
2 years ago
|
import type { ColumnType } from 'nocodb-sdk'
|
||
2 years ago
|
import { UITypes, isVirtualCol } from 'nocodb-sdk'
|
||
2 years ago
|
import { message } from 'ant-design-vue'
|
||
2 years ago
|
import { useI18n } from 'vue-i18n'
|
||
2 years ago
|
import {
|
||
2 years ago
|
ActiveViewInj,
|
||
|
ChangePageInj,
|
||
|
FieldsInj,
|
||
|
IsFormInj,
|
||
2 years ago
|
IsGalleryInj,
|
||
2 years ago
|
IsGridInj,
|
||
|
IsLockedInj,
|
||
|
MetaInj,
|
||
|
OpenNewRecordFormHookInj,
|
||
|
PaginationDataInj,
|
||
|
ReadonlyInj,
|
||
|
ReloadViewDataHookInj,
|
||
2 years ago
|
createEventHook,
|
||
2 years ago
|
enumColor,
|
||
2 years ago
|
inject,
|
||
2 years ago
|
onClickOutside,
|
||
2 years ago
|
onMounted,
|
||
|
provide,
|
||
2 years ago
|
reactive,
|
||
|
ref,
|
||
2 years ago
|
useEventListener,
|
||
2 years ago
|
useGridViewColumnWidth,
|
||
2 years ago
|
useSmartsheetStoreOrThrow,
|
||
2 years ago
|
useUIPermission,
|
||
2 years ago
|
useViewData,
|
||
2 years ago
|
watch,
|
||
2 years ago
|
} from '#imports'
|
||
2 years ago
|
import type { Row } from '~/composables'
|
||
2 years ago
|
import { NavigateDir } from '~/lib'
|
||
2 years ago
|
|
||
2 years ago
|
const { t } = useI18n()
|
||
|
|
||
2 years ago
|
const meta = inject(MetaInj)
|
||
2 years ago
|
|
||
2 years ago
|
const view = inject(ActiveViewInj)
|
||
2 years ago
|
|
||
2 years ago
|
// keep a root fields variable and will get modified from
|
||
|
// fields menu and get used in grid and gallery
|
||
2 years ago
|
const fields = inject(FieldsInj, ref([]))
|
||
2 years ago
|
const readOnly = inject(ReadonlyInj, false)
|
||
2 years ago
|
const isLocked = inject(IsLockedInj, ref(false))
|
||
2 years ago
|
|
||
2 years ago
|
const reloadViewDataHook = inject(ReloadViewDataHookInj, createEventHook())
|
||
|
const openNewRecordFormHook = inject(OpenNewRecordFormHookInj, createEventHook())
|
||
2 years ago
|
|
||
2 years ago
|
const { isUIAllowed } = useUIPermission()
|
||
2 years ago
|
const hasEditPermission = isUIAllowed('xcDatatableEditable')
|
||
2 years ago
|
|
||
2 years ago
|
// todo: get from parent ( inject or use prop )
|
||
2 years ago
|
const isView = false
|
||
2 years ago
|
|
||
2 years ago
|
const selected = reactive<{ row: number | null; col: number | null }>({ row: null, col: null })
|
||
2 years ago
|
|
||
2 years ago
|
let editEnabled = $ref(false)
|
||
2 years ago
|
|
||
2 years ago
|
const { xWhere, isPkAvail, cellRefs, isSqlView } = useSmartsheetStoreOrThrow()
|
||
2 years ago
|
|
||
2 years ago
|
const addColumnDropdown = ref(false)
|
||
2 years ago
|
|
||
2 years ago
|
const _contextMenu = ref(false)
|
||
|
const contextMenu = computed({
|
||
|
get: () => _contextMenu.value,
|
||
|
set: (val) => {
|
||
2 years ago
|
if (hasEditPermission) {
|
||
2 years ago
|
_contextMenu.value = val
|
||
|
}
|
||
|
},
|
||
|
})
|
||
2 years ago
|
|
||
2 years ago
|
const contextMenuTarget = ref<{ row: number; col: number } | null>(null)
|
||
2 years ago
|
const expandedFormDlg = ref(false)
|
||
2 years ago
|
const expandedFormRow = ref<Row>()
|
||
2 years ago
|
const expandedFormRowState = ref<Record<string, any>>()
|
||
2 years ago
|
|
||
2 years ago
|
const visibleColLength = $computed(() => fields.value?.length)
|
||
2 years ago
|
|
||
|
const {
|
||
2 years ago
|
isLoading,
|
||
2 years ago
|
loadData,
|
||
|
paginationData,
|
||
|
formattedData: data,
|
||
2 years ago
|
updateOrSaveRow,
|
||
2 years ago
|
changePage,
|
||
2 years ago
|
addEmptyRow,
|
||
|
deleteRow,
|
||
|
deleteSelectedRows,
|
||
2 years ago
|
selectedAllRecords,
|
||
2 years ago
|
removeLastEmptyRow,
|
||
2 years ago
|
} = useViewData(meta, view as any, xWhere)
|
||
2 years ago
|
|
||
2 years ago
|
const { loadGridViewColumns, updateWidth, resizingColWidth, resizingCol } = useGridViewColumnWidth(view as any)
|
||
2 years ago
|
onMounted(loadGridViewColumns)
|
||
2 years ago
|
|
||
2 years ago
|
provide(IsFormInj, ref(false))
|
||
2 years ago
|
|
||
2 years ago
|
provide(IsGalleryInj, ref(false))
|
||
|
|
||
|
provide(IsGridInj, ref(true))
|
||
2 years ago
|
|
||
2 years ago
|
provide(PaginationDataInj, paginationData)
|
||
2 years ago
|
|
||
2 years ago
|
provide(ChangePageInj, changePage)
|
||
2 years ago
|
|
||
2 years ago
|
provide(ReadonlyInj, !hasEditPermission)
|
||
2 years ago
|
|
||
2 years ago
|
reloadViewDataHook?.on(async () => {
|
||
|
await loadData()
|
||
2 years ago
|
})
|
||
2 years ago
|
|
||
2 years ago
|
const expandForm = (row: Row, state?: Record<string, any>) => {
|
||
|
expandedFormRow.value = row
|
||
|
expandedFormRowState.value = state
|
||
|
expandedFormDlg.value = true
|
||
|
}
|
||
|
|
||
|
openNewRecordFormHook?.on(async () => {
|
||
|
const newRow = await addEmptyRow()
|
||
|
expandForm(newRow)
|
||
|
})
|
||
|
|
||
2 years ago
|
const selectCell = (row: number, col: number) => {
|
||
2 years ago
|
selected.row = row
|
||
|
selected.col = col
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
watch(
|
||
2 years ago
|
() => (view?.value as any)?.id,
|
||
2 years ago
|
async (n?: string, o?: string) => {
|
||
2 years ago
|
if (n && o && n !== o) {
|
||
2 years ago
|
await loadData()
|
||
|
}
|
||
|
},
|
||
|
{ immediate: true },
|
||
|
)
|
||
2 years ago
|
|
||
2 years ago
|
const onresize = (colID: string, event: any) => {
|
||
|
updateWidth(colID, event.detail)
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
const onXcResizing = (cn: string, event: any) => {
|
||
|
resizingCol.value = cn
|
||
|
resizingColWidth.value = event.detail
|
||
|
}
|
||
|
|
||
2 years ago
|
defineExpose({
|
||
|
loadData,
|
||
|
})
|
||
2 years ago
|
|
||
2 years ago
|
// reset context menu target on hide
|
||
2 years ago
|
watch(contextMenu, () => {
|
||
2 years ago
|
if (!contextMenu.value) {
|
||
2 years ago
|
contextMenuTarget.value = null
|
||
2 years ago
|
}
|
||
|
})
|
||
|
|
||
2 years ago
|
const clearCell = async (ctx: { row: number; col: number }) => {
|
||
|
const rowObj = data.value[ctx.row]
|
||
|
const columnObj = fields.value[ctx.col]
|
||
|
|
||
|
if (isVirtualCol(columnObj)) {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
rowObj.row[columnObj.title] = null
|
||
|
// update/save cell value
|
||
|
await updateOrSaveRow(rowObj, columnObj.title)
|
||
|
}
|
||
|
|
||
2 years ago
|
const { copy } = useClipboard()
|
||
|
|
||
2 years ago
|
const makeEditable = (row: Row, col: ColumnType) => {
|
||
2 years ago
|
if (!hasEditPermission || editEnabled || isView) {
|
||
2 years ago
|
return
|
||
|
}
|
||
|
if (!isPkAvail.value && !row.rowMeta.new) {
|
||
2 years ago
|
// Update not allowed for table which doesn't have primary Key
|
||
|
message.info(t('msg.info.updateNotAllowedWithoutPK'))
|
||
2 years ago
|
return
|
||
|
}
|
||
|
if (col.ai) {
|
||
2 years ago
|
// Auto Increment field is not editable
|
||
|
message.info(t('msg.info.autoIncFieldNotEditable'))
|
||
2 years ago
|
return
|
||
|
}
|
||
|
if (col.pk && !row.rowMeta.new) {
|
||
2 years ago
|
// Editing primary key not supported
|
||
|
message.info(t('msg.info.editingPKnotSupported'))
|
||
2 years ago
|
return
|
||
|
}
|
||
|
return (editEnabled = true)
|
||
|
}
|
||
|
|
||
2 years ago
|
/** handle keypress events */
|
||
2 years ago
|
const onKeyDown = async (e: KeyboardEvent) => {
|
||
2 years ago
|
if (selected.row === null || selected.col === null) return
|
||
|
/** on tab key press navigate through cells */
|
||
|
switch (e.key) {
|
||
|
case 'Tab':
|
||
|
e.preventDefault()
|
||
|
if (e.shiftKey) {
|
||
|
if (selected.col > 0) {
|
||
|
selected.col--
|
||
|
} else if (selected.row > 0) {
|
||
|
selected.row--
|
||
|
selected.col = visibleColLength - 1
|
||
2 years ago
|
}
|
||
2 years ago
|
} else {
|
||
|
if (selected.col < visibleColLength - 1) {
|
||
|
selected.col++
|
||
|
} else if (selected.row < data.value.length - 1) {
|
||
|
selected.row++
|
||
|
selected.col = 0
|
||
|
}
|
||
|
}
|
||
|
break
|
||
|
/** on enter key press make cell editable */
|
||
|
case 'Enter':
|
||
|
e.preventDefault()
|
||
2 years ago
|
makeEditable(data.value[selected.row], fields.value[selected.col])
|
||
2 years ago
|
break
|
||
|
/** on delete key press clear cell */
|
||
|
case 'Delete':
|
||
2 years ago
|
if (!editEnabled) {
|
||
|
e.preventDefault()
|
||
|
await clearCell(selected as { row: number; col: number })
|
||
|
}
|
||
2 years ago
|
break
|
||
|
/** on arrow key press navigate through cells */
|
||
|
case 'ArrowRight':
|
||
|
e.preventDefault()
|
||
|
if (selected.col < visibleColLength - 1) selected.col++
|
||
|
break
|
||
|
case 'ArrowLeft':
|
||
|
e.preventDefault()
|
||
|
if (selected.col > 0) selected.col--
|
||
|
break
|
||
|
case 'ArrowUp':
|
||
|
e.preventDefault()
|
||
|
if (selected.row > 0) selected.row--
|
||
|
break
|
||
|
case 'ArrowDown':
|
||
|
e.preventDefault()
|
||
|
if (selected.row < data.value.length - 1) selected.row++
|
||
|
break
|
||
2 years ago
|
default:
|
||
|
{
|
||
|
const rowObj = data.value[selected.row]
|
||
|
const columnObj = fields.value[selected.col]
|
||
|
|
||
|
if ((!editEnabled && e.metaKey) || e.ctrlKey) {
|
||
|
switch (e.keyCode) {
|
||
|
// copy - ctrl/cmd +c
|
||
|
case 67:
|
||
|
await copy(rowObj.row[columnObj.title] || '')
|
||
|
break
|
||
|
}
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
if (editEnabled || e.ctrlKey || e.altKey || e.metaKey) {
|
||
|
return
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
|
/** on letter key press make cell editable and empty */
|
||
|
if (e?.key?.length === 1) {
|
||
|
if (!isPkAvail && !rowObj.rowMeta.new) {
|
||
2 years ago
|
// Update not allowed for table which doesn't have primary Key
|
||
|
return message.info(t('msg.info.updateNotAllowedWithoutPK'))
|
||
2 years ago
|
}
|
||
|
if (makeEditable(rowObj, columnObj)) {
|
||
|
rowObj.row[columnObj.title] = ''
|
||
|
}
|
||
|
// editEnabled = true
|
||
2 years ago
|
}
|
||
2 years ago
|
}
|
||
|
break
|
||
2 years ago
|
}
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
useEventListener(document, 'keydown', onKeyDown)
|
||
2 years ago
|
|
||
|
/** On clicking outside of table reset active cell */
|
||
|
const smartTable = ref(null)
|
||
2 years ago
|
onClickOutside(smartTable, () => {
|
||
2 years ago
|
if (selected.col === null) return
|
||
|
|
||
|
const activeCol = fields.value[selected.col]
|
||
|
|
||
|
if (editEnabled && (isVirtualCol(activeCol) || activeCol.uidt === UITypes.JSON)) return
|
||
|
|
||
2 years ago
|
selected.row = null
|
||
|
selected.col = null
|
||
2 years ago
|
})
|
||
2 years ago
|
|
||
|
const onNavigate = (dir: NavigateDir) => {
|
||
|
if (selected.row === null || selected.col === null) return
|
||
|
switch (dir) {
|
||
|
case NavigateDir.NEXT:
|
||
2 years ago
|
if (selected.row < data.value.length - 1) {
|
||
2 years ago
|
selected.row++
|
||
2 years ago
|
} else {
|
||
|
editEnabled = false
|
||
2 years ago
|
}
|
||
|
break
|
||
|
case NavigateDir.PREV:
|
||
2 years ago
|
if (selected.row > 0) {
|
||
2 years ago
|
selected.row--
|
||
2 years ago
|
} else {
|
||
|
editEnabled = false
|
||
2 years ago
|
}
|
||
|
break
|
||
|
}
|
||
|
}
|
||
2 years ago
|
|
||
|
const showContextMenu = (e: MouseEvent, target?: { row: number; col: number }) => {
|
||
|
if (isSqlView.value) return
|
||
|
e.preventDefault()
|
||
|
if (target) {
|
||
|
contextMenuTarget.value = target
|
||
|
}
|
||
|
}
|
||
2 years ago
|
</script>
|
||
|
|
||
2 years ago
|
<template>
|
||
2 years ago
|
<div class="flex flex-col h-full min-h-0 w-full">
|
||
2 years ago
|
<div v-if="isLoading" class="flex items-center justify-center h-full w-full">
|
||
2 years ago
|
<a-spin size="large" />
|
||
|
</div>
|
||
|
<div v-else class="nc-grid-wrapper min-h-0 flex-1 scrollbar-thin-dull">
|
||
2 years ago
|
<a-dropdown v-model:visible="contextMenu" :trigger="isSqlView ? [] : ['contextmenu']">
|
||
2 years ago
|
<table
|
||
2 years ago
|
ref="smartTable"
|
||
2 years ago
|
class="xc-row-table nc-grid backgroundColorDefault !h-auto bg-white"
|
||
2 years ago
|
@contextmenu="showContextMenu"
|
||
2 years ago
|
>
|
||
2 years ago
|
<thead>
|
||
2 years ago
|
<tr class="nc-grid-header border-1 bg-gray-100 sticky top[-1px]">
|
||
|
<th>
|
||
|
<div class="w-full h-full bg-gray-100 flex min-w-[70px] pl-5 pr-1 items-center">
|
||
|
<template v-if="!readOnly">
|
||
|
<div class="nc-no-label text-gray-500" :class="{ hidden: selectedAllRecords }">#</div>
|
||
|
<div
|
||
|
:class="{ hidden: !selectedAllRecords, flex: selectedAllRecords }"
|
||
|
class="nc-check-all w-full items-center"
|
||
|
>
|
||
|
<a-checkbox v-model:checked="selectedAllRecords" />
|
||
2 years ago
|
|
||
2 years ago
|
<span class="flex-1" />
|
||
|
</div>
|
||
|
</template>
|
||
|
<template v-else>
|
||
|
<div class="text-gray-500">#</div>
|
||
|
</template>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</th>
|
||
|
<th
|
||
|
v-for="col in fields"
|
||
|
:key="col.title"
|
||
|
v-xc-ver-resize
|
||
|
:data-col="col.id"
|
||
|
:data-title="col.title"
|
||
|
@xcresize="onresize(col.id, $event)"
|
||
|
@xcresizing="onXcResizing(col.title, $event)"
|
||
|
@xcresized="resizingCol = null"
|
||
|
>
|
||
|
<div class="w-full h-full bg-gray-100 flex items-center">
|
||
|
<SmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" :hide-menu="readOnly" />
|
||
|
|
||
|
<SmartsheetHeaderCell v-else :column="col" :hide-menu="readOnly" />
|
||
|
</div>
|
||
|
</th>
|
||
|
<th
|
||
2 years ago
|
v-if="!readOnly && !isLocked && isUIAllowed('add-column') && !isSqlView"
|
||
2 years ago
|
v-t="['c:column:add']"
|
||
|
class="cursor-pointer"
|
||
|
@click.stop="addColumnDropdown = true"
|
||
|
>
|
||
|
<a-dropdown v-model:visible="addColumnDropdown" :trigger="['click']">
|
||
|
<div class="h-full w-[60px] flex items-center justify-center">
|
||
|
<MdiPlus class="text-sm nc-column-add" />
|
||
|
</div>
|
||
2 years ago
|
|
||
2 years ago
|
<template #overlay>
|
||
|
<SmartsheetColumnEditOrAddProvider
|
||
|
v-if="addColumnDropdown"
|
||
|
@submit="addColumnDropdown = false"
|
||
|
@cancel="addColumnDropdown = false"
|
||
|
@click.stop
|
||
|
@keydown.stop
|
||
|
/>
|
||
|
</template>
|
||
|
</a-dropdown>
|
||
|
</th>
|
||
|
</tr>
|
||
2 years ago
|
</thead>
|
||
|
<tbody>
|
||
2 years ago
|
<SmartsheetRow v-for="(row, rowIndex) of data" :key="rowIndex" :row="row">
|
||
|
<template #default="{ state }">
|
||
|
<tr class="nc-grid-row">
|
||
|
<td key="row-index" class="caption nc-grid-cell pl-5 pr-1">
|
||
|
<div class="items-center flex gap-1 min-w-[55px]">
|
||
|
<div
|
||
|
v-if="!readOnly || !isLocked"
|
||
|
class="nc-row-no text-xs text-gray-500"
|
||
2 years ago
|
:class="{ toggle: !readOnly, hidden: row.rowMeta.selected }"
|
||
2 years ago
|
>
|
||
|
{{ rowIndex + 1 }}
|
||
|
</div>
|
||
|
<div
|
||
|
v-if="!readOnly"
|
||
|
:class="{ hidden: !row.rowMeta.selected, flex: row.rowMeta.selected }"
|
||
|
class="nc-row-expand-and-checkbox"
|
||
|
>
|
||
|
<a-checkbox v-model:checked="row.rowMeta.selected" />
|
||
|
</div>
|
||
|
<span class="flex-1" />
|
||
|
<div v-if="!readOnly && !isLocked" class="nc-expand" :class="{ 'nc-comment': row.rowMeta?.commentCount }">
|
||
2 years ago
|
<span
|
||
|
v-if="row.rowMeta?.commentCount"
|
||
|
class="py-1 px-3 rounded-full text-xs cursor-pointer select-none transform hover:(scale-110)"
|
||
|
:style="{ backgroundColor: enumColor.light[row.rowMeta.commentCount % enumColor.light.length] }"
|
||
|
@click="expandForm(row, state)"
|
||
|
>
|
||
|
{{ row.rowMeta.commentCount }}
|
||
|
</span>
|
||
2 years ago
|
<div
|
||
|
v-else
|
||
|
class="cursor-pointer flex items-center border-1 active:ring rounded p-1 hover:(bg-primary bg-opacity-10)"
|
||
|
>
|
||
|
<MdiArrowExpand
|
||
|
class="select-none transform hover:(text-accent scale-120) nc-row-expand"
|
||
|
@click="expandForm(row, state)"
|
||
|
/>
|
||
|
</div>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</td>
|
||
|
<td
|
||
|
v-for="(columnObj, colIndex) of fields"
|
||
|
:ref="cellRefs.set"
|
||
|
:key="columnObj.id"
|
||
|
class="cell relative cursor-pointer nc-grid-cell"
|
||
|
:class="{
|
||
2 years ago
|
active: isUIAllowed('xcDatatableEditable') && selected.col === colIndex && selected.row === rowIndex,
|
||
2 years ago
|
}"
|
||
2 years ago
|
:data-key="rowIndex + columnObj.id"
|
||
|
:data-col="columnObj.id"
|
||
|
:data-title="columnObj.title"
|
||
|
@click="selectCell(rowIndex, colIndex)"
|
||
|
@dblclick="makeEditable(row, columnObj)"
|
||
2 years ago
|
@contextmenu="showContextMenu($event, { row: rowIndex, col: colIndex })"
|
||
2 years ago
|
>
|
||
|
<div class="w-full h-full">
|
||
|
<SmartsheetVirtualCell
|
||
|
v-if="isVirtualCol(columnObj)"
|
||
|
v-model="row.row[columnObj.title]"
|
||
|
:column="columnObj"
|
||
|
:active="selected.col === colIndex && selected.row === rowIndex"
|
||
|
:row="row"
|
||
|
@navigate="onNavigate"
|
||
|
/>
|
||
|
|
||
|
<SmartsheetCell
|
||
|
v-else
|
||
|
v-model="row.row[columnObj.title]"
|
||
|
:column="columnObj"
|
||
|
:edit-enabled="
|
||
2 years ago
|
isUIAllowed('xcDatatableEditable') &&
|
||
|
editEnabled &&
|
||
|
selected.col === colIndex &&
|
||
|
selected.row === rowIndex
|
||
|
"
|
||
2 years ago
|
:row-index="rowIndex"
|
||
|
:active="selected.col === colIndex && selected.row === rowIndex"
|
||
|
@update:edit-enabled="editEnabled = false"
|
||
|
@save="updateOrSaveRow(row, columnObj.title)"
|
||
|
@navigate="onNavigate"
|
||
|
@cancel="editEnabled = false"
|
||
|
/>
|
||
|
</div>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</template>
|
||
|
</SmartsheetRow>
|
||
2 years ago
|
|
||
2 years ago
|
<!--
|
||
2 years ago
|
TODO: add relationType !== 'bt' ?
|
||
|
v1: <tr v-if="!isView && !isLocked && !isPublicView && isEditable && relationType !== 'bt'">
|
||
|
-->
|
||
|
<tr v-if="!isView && !isLocked && isUIAllowed('xcDatatableEditable') && !isSqlView">
|
||
2 years ago
|
<td
|
||
|
v-t="['c:row:add:grid-bottom']"
|
||
|
:colspan="visibleColLength + 1"
|
||
|
class="text-left pointer nc-grid-add-new-cell cursor-pointer"
|
||
|
@click="addEmptyRow()"
|
||
|
>
|
||
|
<div class="px-2 w-full flex items-center text-gray-500">
|
||
|
<MdiPlus class="text-pint-500 text-xs ml-2 text-primary" />
|
||
|
|
||
|
<span class="ml-1">
|
||
2 years ago
|
{{ $t('activity.addRow') }}
|
||
|
</span>
|
||
2 years ago
|
</div>
|
||
|
</td>
|
||
|
</tr>
|
||
2 years ago
|
</tbody>
|
||
2 years ago
|
</table>
|
||
2 years ago
|
|
||
2 years ago
|
<template v-if="!isLocked && isUIAllowed('xcDatatableEditable')" #overlay>
|
||
2 years ago
|
<a-menu class="shadow !rounded !py-0" @click="contextMenu = false">
|
||
|
<a-menu-item v-if="contextMenuTarget" @click="deleteRow(contextMenuTarget.row)">
|
||
|
<div class="nc-project-menu-item">
|
||
2 years ago
|
<!-- Delete Row -->
|
||
|
{{ $t('activity.deleteRow') }}
|
||
2 years ago
|
</div>
|
||
|
</a-menu-item>
|
||
|
|
||
|
<a-menu-item @click="deleteSelectedRows">
|
||
|
<div class="nc-project-menu-item">
|
||
2 years ago
|
<!-- Delete Selected Rows -->
|
||
|
{{ $t('activity.deleteSelectedRow') }}
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</a-menu-item>
|
||
2 years ago
|
|
||
2 years ago
|
<!-- Clear cell -->
|
||
2 years ago
|
<a-menu-item v-if="contextMenuTarget" @click="clearCell(contextMenuTarget)">
|
||
2 years ago
|
<div class="nc-project-menu-item">{{ $t('activity.clearCell') }}</div>
|
||
2 years ago
|
</a-menu-item>
|
||
|
|
||
2 years ago
|
<a-menu-item v-if="contextMenuTarget" @click="addEmptyRow(contextMenuTarget.row + 1)">
|
||
2 years ago
|
<div class="nc-project-menu-item">
|
||
2 years ago
|
<!-- Insert New Row -->
|
||
|
{{ $t('activity.insertRow') }}
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</a-menu-item>
|
||
|
</a-menu>
|
||
2 years ago
|
</template>
|
||
|
</a-dropdown>
|
||
|
</div>
|
||
|
|
||
2 years ago
|
<SmartsheetPagination />
|
||
2 years ago
|
|
||
2 years ago
|
<SmartsheetExpandedForm
|
||
2 years ago
|
v-if="expandedFormRow && expandedFormDlg"
|
||
2 years ago
|
v-model="expandedFormDlg"
|
||
|
:row="expandedFormRow"
|
||
|
:state="expandedFormRowState"
|
||
2 years ago
|
:meta="meta"
|
||
2 years ago
|
@cancel="removeLastEmptyRow"
|
||
2 years ago
|
/>
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</template>
|
||
|
|
||
2 years ago
|
<style scoped lang="scss">
|
||
2 years ago
|
.nc-grid-wrapper {
|
||
2 years ago
|
@apply h-full w-full overflow-auto;
|
||
2 years ago
|
|
||
2 years ago
|
td,
|
||
2 years ago
|
th {
|
||
2 years ago
|
min-height: 41px !important;
|
||
|
height: 41px !important;
|
||
2 years ago
|
position: relative;
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
td:not(:first-child) > div {
|
||
2 years ago
|
overflow: hidden;
|
||
2 years ago
|
@apply flex items-center h-auto px-1;
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
table,
|
||
|
td,
|
||
|
th {
|
||
2 years ago
|
@apply !border-1;
|
||
2 years ago
|
border-collapse: collapse;
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
td {
|
||
|
text-overflow: ellipsis;
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
td.active::after,
|
||
|
td.active::before {
|
||
|
content: '';
|
||
|
position: absolute;
|
||
|
z-index: 3;
|
||
|
height: calc(100% + 2px);
|
||
|
width: calc(100% + 2px);
|
||
|
left: -1px;
|
||
|
top: -1px;
|
||
|
pointer-events: none;
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
// todo: replace with css variable
|
||
|
td.active::after {
|
||
2 years ago
|
@apply border-2 border-solid border-primary;
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
td.active::before {
|
||
2 years ago
|
@apply bg-primary bg-opacity-5;
|
||
2 years ago
|
}
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
|
:deep {
|
||
|
.resizer:hover,
|
||
|
.resizer:active,
|
||
|
.resizer:focus {
|
||
|
// todo: replace with primary color
|
||
|
@apply bg-blue-500/50;
|
||
|
cursor: col-resize;
|
||
|
}
|
||
|
}
|
||
2 years ago
|
|
||
|
.nc-grid-row {
|
||
|
.nc-row-expand-and-checkbox {
|
||
2 years ago
|
@apply w-full items-center justify-between;
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
.nc-expand {
|
||
2 years ago
|
&:not(.nc-comment) {
|
||
|
@apply hidden;
|
||
|
}
|
||
2 years ago
|
|
||
2 years ago
|
&.nc-comment {
|
||
|
display: flex;
|
||
|
}
|
||
2 years ago
|
}
|
||
|
|
||
|
&:hover {
|
||
2 years ago
|
.nc-row-no.toggle {
|
||
2 years ago
|
@apply hidden;
|
||
|
}
|
||
|
|
||
|
.nc-expand {
|
||
|
@apply flex;
|
||
|
}
|
||
|
|
||
|
.nc-row-expand-and-checkbox {
|
||
|
@apply flex;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
.nc-grid-header {
|
||
2 years ago
|
position: sticky;
|
||
2 years ago
|
top: -1px;
|
||
2 years ago
|
|
||
|
@apply z-1;
|
||
|
|
||
2 years ago
|
&:hover {
|
||
|
.nc-no-label {
|
||
|
@apply hidden;
|
||
|
}
|
||
|
|
||
|
.nc-check-all {
|
||
|
@apply flex;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
2 years ago
|
|
||
|
tbody tr:hover {
|
||
|
@apply bg-gray-100 bg-opacity-50;
|
||
|
}
|
||
2 years ago
|
</style>
|