mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
6f00106d7c
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
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
import {DocModel, IRowModel, refRecord, ViewRec} from 'app/client/models/DocModel';
|
|
import * as ko from 'knockout';
|
|
|
|
// Represents a page entry in the tree of pages.
|
|
export interface PageRec extends IRowModel<"_grist_Pages"> {
|
|
view: ko.Computed<ViewRec>;
|
|
isHidden: ko.Computed<boolean>;
|
|
}
|
|
|
|
export function createPageRec(this: PageRec, docModel: DocModel): void {
|
|
this.view = refRecord(docModel.views, this.viewRef);
|
|
this.isHidden = ko.pureComputed(() => {
|
|
const name = this.view().name();
|
|
const isTableHidden = () => {
|
|
const viewId = this.view().id();
|
|
const tables = docModel.rawTables.all();
|
|
const primaryTable = tables.find(t => t.primaryViewId() === viewId);
|
|
return !!primaryTable && primaryTable.isHidden();
|
|
};
|
|
// Page is hidden when any of this is true:
|
|
// - It has an empty name (or no name at all)
|
|
// - It is GristDocTour (unless user wants to see it)
|
|
// - It is a page generated for a hidden table TODO: Follow up - don't create
|
|
// pages for hidden tables.
|
|
// This is used currently only the left panel, to hide pages from the user.
|
|
return !name || (name === 'GristDocTour' && !docModel.showDocTourTable) || isTableHidden();
|
|
});
|
|
}
|