mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
fix: invalid Document types
fix: url deduction for page reload to apply new document type
This commit is contained in:
parent
aa9e42bd47
commit
fbc911721e
@ -310,10 +310,10 @@ export class DocSettingsPage extends Disposable {
|
|||||||
const currentDocType = docPageModel.type.get() as string;
|
const currentDocType = docPageModel.type.get() as string;
|
||||||
let currentDocTypeOption;
|
let currentDocTypeOption;
|
||||||
switch (currentDocType) {
|
switch (currentDocType) {
|
||||||
case "Template":
|
case "template":
|
||||||
currentDocTypeOption = DocTypeOption.Template;
|
currentDocTypeOption = DocTypeOption.Template;
|
||||||
break;
|
break;
|
||||||
case "Tutorial":
|
case "tutorial":
|
||||||
currentDocTypeOption = DocTypeOption.Tutorial;
|
currentDocTypeOption = DocTypeOption.Tutorial;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -328,12 +328,19 @@ export class DocSettingsPage extends Disposable {
|
|||||||
if (selected.get() === DocTypeOption.Regular) {
|
if (selected.get() === DocTypeOption.Regular) {
|
||||||
docType = "";
|
docType = "";
|
||||||
} else if (selected.get() === DocTypeOption.Template) {
|
} else if (selected.get() === DocTypeOption.Template) {
|
||||||
docType = "Template";
|
docType = "template";
|
||||||
} else {
|
} else {
|
||||||
docType = "Tutorial";
|
docType = "tutorial";
|
||||||
}
|
}
|
||||||
await persistType(docType, docId);
|
await persistType(docType, docId);
|
||||||
window.location.reload();
|
const currentUrl = window.location.href;
|
||||||
|
const urlId = currentUrl.split("/docs/")[1];
|
||||||
|
const cleanUrlId = urlId.match(/^doc\/.*/) ? urlId.split("/")[1] : urlId.split("/")[0];
|
||||||
|
const shortDocId = urlId?.split("~")[0];
|
||||||
|
const reloadUrl = urlId.match(/^doc\/.*/) ?
|
||||||
|
currentUrl.replace(`doc/${cleanUrlId}`, shortDocId) :
|
||||||
|
currentUrl.replace(cleanUrlId, shortDocId);
|
||||||
|
window.location.replace(reloadUrl ?? "");
|
||||||
};
|
};
|
||||||
|
|
||||||
const documentTypeOptions = () => [
|
const documentTypeOptions = () => [
|
||||||
|
Loading…
Reference in New Issue
Block a user