mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Allow duplicating tables from Raw Data page
Summary: Adds a "Duplicate Table" menu option to the tables listed on the Raw Data page. Clicking it opens a dialog that allows you to make a copy of the table (with or without its data). Test Plan: Python, server, and browser tests. Reviewers: jarek, paulfitz Reviewed By: jarek, paulfitz Subscribers: jarek Differential Revision: https://phab.getgrist.com/D3619
This commit is contained in:
@@ -3,6 +3,7 @@ import {copyToClipboard} from 'app/client/lib/copyToClipboard';
|
||||
import {setTestState} from 'app/client/lib/testState';
|
||||
import {TableRec} from 'app/client/models/DocModel';
|
||||
import {docListHeader, docMenuTrigger} from 'app/client/ui/DocMenuCss';
|
||||
import {duplicateTable, DuplicateTableResponse} from 'app/client/ui/DuplicateTable';
|
||||
import {showTransientTooltip} from 'app/client/ui/tooltips';
|
||||
import {buildTableName} from 'app/client/ui/WidgetTitle';
|
||||
import * as css from 'app/client/ui2018/cssVars';
|
||||
@@ -121,6 +122,16 @@ export class DataTables extends Disposable {
|
||||
private _menuItems(table: TableRec) {
|
||||
const {isReadonly, docModel} = this._gristDoc;
|
||||
return [
|
||||
menuItem(
|
||||
() => this._duplicateTable(table),
|
||||
'Duplicate Table',
|
||||
testId('menu-duplicate-table'),
|
||||
dom.cls('disabled', use =>
|
||||
use(isReadonly) ||
|
||||
use(table.isHidden) ||
|
||||
use(table.summarySourceTable) !== 0
|
||||
),
|
||||
),
|
||||
menuItem(
|
||||
() => this._removeTable(table),
|
||||
'Remove',
|
||||
@@ -134,6 +145,13 @@ export class DataTables extends Disposable {
|
||||
];
|
||||
}
|
||||
|
||||
private _duplicateTable(t: TableRec) {
|
||||
duplicateTable(this._gristDoc, t.tableId(), {
|
||||
onSuccess: ({raw_section_id}: DuplicateTableResponse) =>
|
||||
this._gristDoc.viewModel.activeSectionId(raw_section_id),
|
||||
});
|
||||
}
|
||||
|
||||
private _removeTable(t: TableRec) {
|
||||
const {docModel} = this._gristDoc;
|
||||
function doRemove() {
|
||||
|
||||
Reference in New Issue
Block a user