Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
</div>

<div ref="tabulator" class="tabulator-custom data-grid grid-height">
<div ref="tabulator" class="tabulator-custom data-grid grid-height" @keydown.delete="clearSelectedData">
</div>

<div ref="bottomToolbar" class="data-editor__footer d-flex align-items-center justify-content-end p-2">
Expand Down Expand Up @@ -168,8 +168,10 @@ export default {
headerSortClickElement:"icon",
ajaxURL: "http://fake",
ajaxRequestFunc: this.getTableData,
clipboard: "copy",
clipboard: true,
clipboardCopyRowRange: "range",
clipboardPasteParser:"range",
clipboardPasteAction: "range",
clipboardCopyConfig: {
columnHeaders: false, //do not include column headers in clipboard output
formatCells:false, //cell formatting on clipboard copy breaks rowFormatter's ability to colorize data grid rows
Expand All @@ -178,12 +180,12 @@ export default {

table.on("tableBuilt", () => {
this.tabulator = markRaw(table); // markRaw fixes problem with making tabulator proxy, that we don't need
this.tabulator.on("cellEditing", (cell) => { // Prevent Tabulator from hijacking left/right arrow keys and mouse click while editing
this.tabulator.on("cellEditing", (cell) => { // Prevent Tabulator from hijacking left/right arrow keys, delete key and mouse click while editing
this.$nextTick(() => {
const el = cell.getElement().querySelector("input");
if (!el) return;
el.addEventListener("keydown", (e) => {
if (["ArrowLeft", "ArrowRight"].includes(e.key)) e.stopPropagation();
if (["ArrowLeft", "ArrowRight", "Delete"].includes(e.key)) e.stopPropagation();
});
el.addEventListener("mousedown", (e) => {
e.stopPropagation();
Expand All @@ -192,6 +194,21 @@ export default {
});

this.tabulator.on("cellEdited", this.cellEdited);
this.tabulator.on("clipboardPasted", (clipboard, rowData, rows) => {
// manually trigger cellEdited on changed cells because clipboard paste doesn't do that
rows.forEach((row, rowIndex) => {
const rowValues = rowData[rowIndex];
if (!rowValues) return;

const cells = row.getCells();

cells.forEach((cell, cellIndex) => {
if (!(cellIndex in rowValues)) return; // no pasted data for this column

this.cellEdited(cell.getComponent())
});
});
});
this.knex = Knex({ client: mappedDialect || 'postgres'})
this.getTableColumns().then(() => {
this.addHeaderMenuOverlayElement();
Expand Down Expand Up @@ -855,6 +872,14 @@ export default {
e.preventDefault();
});
},
clearSelectedData() {
const range = last(this.tabulator.getRanges());
if (!range) return;

range.getCells().flat().forEach((cell) => {
cell.setValue(null);
})
},
},
watch: {
hasChanges() {
Expand Down