mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Raw renames
Summary: A new way for renaming tables. - There is a new popup to rename section (where you can also rename the table) - Renaming/Deleting page doesn't modify/delete the table. - Renaming table can rename a page if the names match (and the page contains a section with that table). - User can rename table in Raw Data UI in two ways - either on the listing or by using the section name popup - As before, there is no way to change tableId - it is derived from a table name. - When the section name is empty the table name is shown instead. - White space for section name is allowed (to discuss) - so the user can just paste ' '. - Empty name for a page is not allowed (but white space is). - Some bugs related to deleting tables with attached summary tables (and with undoing this operation) were fixed (but not all of them yet). Test Plan: Updated tests. Reviewers: georgegevoian Reviewed By: georgegevoian Subscribers: georgegevoian Differential Revision: https://phab.getgrist.com/D3360
This commit is contained in:
@@ -3,12 +3,10 @@ import { duplicatePage } from "app/client/components/duplicatePage";
|
||||
import { GristDoc } from "app/client/components/GristDoc";
|
||||
import { PageRec } from "app/client/models/DocModel";
|
||||
import { urlState } from "app/client/models/gristUrlState";
|
||||
import { isHiddenTable } from 'app/common/isHiddenTable';
|
||||
import * as MetaTableModel from "app/client/models/MetaTableModel";
|
||||
import { find as findInTree, fromTableData, TreeItemRecord, TreeRecord,
|
||||
TreeTableData} from "app/client/models/TreeModel";
|
||||
import { TreeViewComponent } from "app/client/ui/TreeViewComponent";
|
||||
import { confirmModal } from 'app/client/ui2018/modals';
|
||||
import { buildPageDom, PageActions } from "app/client/ui2018/pages";
|
||||
import { mod } from 'app/common/gutil';
|
||||
import { Computed, Disposable, dom, fromKo, observable, Observable } from "grainjs";
|
||||
@@ -52,7 +50,7 @@ export function buildPagesDom(owner: Disposable, activeDoc: GristDoc, isOpen: Ob
|
||||
}
|
||||
|
||||
function buildDomFromTable(pagesTable: MetaTableModel<PageRec>, activeDoc: GristDoc, id: number) {
|
||||
const {docModel, isReadonly} = activeDoc;
|
||||
const {isReadonly} = activeDoc;
|
||||
const pageName = pagesTable.rowModels[id].view.peek().name;
|
||||
const viewId = pagesTable.rowModels[id].view.peek().id.peek();
|
||||
const docData = pagesTable.tableData.docData;
|
||||
@@ -61,33 +59,11 @@ function buildDomFromTable(pagesTable: MetaTableModel<PageRec>, activeDoc: Grist
|
||||
onRemove: () => docData.sendAction(['RemoveRecord', '_grist_Views', viewId]),
|
||||
// TODO: duplicate should prompt user for confirmation
|
||||
onDuplicate: () => duplicatePage(activeDoc, id),
|
||||
isRemoveDisabled: () => false,
|
||||
// Can't remove last visible page
|
||||
isRemoveDisabled: () => activeDoc.docModel.visibleDocPages.peek().length <= 1,
|
||||
isReadonly
|
||||
};
|
||||
|
||||
// find a table with a matching primary view
|
||||
const tableRef = docModel.tables.tableData.findRow('primaryViewId', viewId);
|
||||
|
||||
if (tableRef) {
|
||||
function doRemove() {
|
||||
const tableId = docModel.tables.tableData.getValue(tableRef, 'tableId');
|
||||
return docData.sendAction(['RemoveTable', tableId]);
|
||||
}
|
||||
|
||||
// if user removes a primary view, let's confirm first, because this will remove the
|
||||
// corresponding table and also all pages that are using this table.
|
||||
// TODO: once we have raw table view, removing page should remove just the view (not the
|
||||
// table), but for now this is the only way to remove a table in the newui.
|
||||
actions.onRemove = () => confirmModal(
|
||||
`Delete ${pageName()} data, and remove it from all pages?`, 'Delete', doRemove);
|
||||
|
||||
// Disable removing the last page. Sometimes hidden pages end up showing in the side panel
|
||||
// (e.g. GristHidden_import* for aborted imports); those aren't listed in allTables, and we
|
||||
// should allow removing them.
|
||||
actions.isRemoveDisabled = () => (docModel.allTables.all().length <= 1) &&
|
||||
!isHiddenTable(docModel.tables.tableData, tableRef);
|
||||
}
|
||||
|
||||
return buildPageDom(fromKo(pageName), actions, urlState().setLinkUrl({docPage: viewId}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user