(core) support a ?compare=<docId2> option in document landing pages

Summary:
If a `compare` query parameter is supplied, this diff will load
the difference between the referenced document and the current
document into an observable in the GristDoc.

Nothing is done with the comparison yet.  Comparisons are not
yet live - they don't get updated if either document changes.

For convenience, `window.gristDocPageModel` is set as an easy
way to access the DocPageModel from the browser console.

Test Plan: added test

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2615
This commit is contained in:
Paul Fitzpatrick 2020-09-21 15:27:49 -04:00
parent dfdb54fcbd
commit b33641dd0c

View File

@ -65,6 +65,7 @@ export interface IGristUrlState {
billingTask?: BillingTask; billingTask?: BillingTask;
embed?: boolean; embed?: boolean;
style?: InterfaceStyle; style?: InterfaceStyle;
compare?: string;
}; };
hash?: HashLink; // if present, this specifies an individual row within a section of a page. hash?: HashLink; // if present, this specifies an individual row within a section of a page.
} }
@ -256,6 +257,9 @@ export function decodeUrl(gristConfig: Partial<GristLoadConfig>, location: Locat
// Turn on light style if no style has been specified. // Turn on light style if no style has been specified.
if (embed && !state.params!.style) { state.params!.style = 'light'; } if (embed && !state.params!.style) { state.params!.style = 'light'; }
} }
if (sp.has('compare')) {
state.params!.compare = sp.get('compare')!;
}
if (location.hash) { if (location.hash) {
const hash = location.hash; const hash = location.hash;
const hashParts = hash.split('.'); const hashParts = hash.split('.');