mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
adds name of page into title of tab in browser
This commit is contained in:
parent
05c89fb65a
commit
dcb72a8e13
@ -53,6 +53,7 @@ export interface DocPageModel {
|
||||
currentOrg: Observable<Organization|null>;
|
||||
currentOrgName: Observable<string>;
|
||||
currentDocTitle: Observable<string>;
|
||||
currentDocPageName: Observable<string>;
|
||||
isReadonly: Observable<boolean>;
|
||||
isPrefork: Observable<boolean>;
|
||||
isFork: Observable<boolean>;
|
||||
@ -93,6 +94,7 @@ export class DocPageModelImpl extends Disposable implements DocPageModel {
|
||||
public readonly currentOrgName = Computed.create(this, this.currentOrg,
|
||||
(use, org) => getOrgNameOrGuest(org, this.appModel.currentUser));
|
||||
public readonly currentDocTitle = Computed.create(this, this.currentDoc, (use, doc) => doc ? doc.name : '');
|
||||
public readonly currentDocPageName = Observable.create(this, '');
|
||||
public readonly isReadonly = Computed.create(this, this.currentDoc, (use, doc) => doc ? doc.isReadonly : false);
|
||||
public readonly isPrefork = Computed.create(this, this.currentDoc, (use, doc) => doc ? doc.isPreFork : false);
|
||||
public readonly isFork = Computed.create(this, this.currentDoc, (use, doc) => doc ? doc.isFork : false);
|
||||
@ -134,6 +136,7 @@ export class DocPageModelImpl extends Disposable implements DocPageModel {
|
||||
this._openerDocKey = docKey;
|
||||
this.gristDoc.set(null);
|
||||
this.currentDoc.set(null);
|
||||
this.currentDocPageName.set('');
|
||||
this.undoState.set(null);
|
||||
if (!urlId) {
|
||||
this._openerHolder.clear();
|
||||
@ -284,6 +287,9 @@ export class DocPageModelImpl extends Disposable implements DocPageModel {
|
||||
|
||||
// Move ownership of docComm to GristDoc.
|
||||
gristDoc.autoDispose(flow.release(docComm));
|
||||
gristDoc.autoDispose(subscribe(gristDoc.currentPageName, (use, pageName) => {
|
||||
this.currentDocPageName.set(pageName);
|
||||
}));
|
||||
|
||||
// Move ownership of GristDoc to its final owner.
|
||||
this.gristDoc.autoDispose(flow.release(gristDoc));
|
||||
|
@ -122,8 +122,12 @@ function pagePanelsDoc(owner: IDisposableOwner, appModel: AppModel, appObj: App)
|
||||
gristDoc ? RightPanel.create(use.owner, gristDoc, rightPanelOpen) : null);
|
||||
|
||||
// Set document title to strings like "DocName - Grist"
|
||||
owner.autoDispose(subscribe(pageModel.currentDocTitle, (use, docName) => {
|
||||
document.title = `${docName} - Grist`;
|
||||
owner.autoDispose(subscribe(pageModel.currentDocTitle, pageModel.currentDocPageName, (use, docName, pageName) => {
|
||||
if (pageName) {
|
||||
document.title = `${pageName} - ${docName} - Grist`;
|
||||
} else {
|
||||
document.title = `${docName} - Grist`;
|
||||
}
|
||||
}));
|
||||
|
||||
// Called after either panel is closed, opened, or resized.
|
||||
|
Loading…
Reference in New Issue
Block a user