2021-06-10 13:30:39 +02:00
|
|
|
// Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
import "./change-notetype-base.css";
|
2022-01-16 06:05:35 +01:00
|
|
|
|
2022-02-04 09:36:34 +01:00
|
|
|
import { ModuleName, setupI18n } from "../lib/i18n";
|
|
|
|
import { checkNightMode } from "../lib/nightmode";
|
2022-02-27 08:35:07 +01:00
|
|
|
import { empty, Notetypes, notetypes } from "../lib/proto";
|
2021-06-10 13:30:39 +02:00
|
|
|
import ChangeNotetypePage from "./ChangeNotetypePage.svelte";
|
2022-02-04 09:36:34 +01:00
|
|
|
import { ChangeNotetypeState } from "./lib";
|
2021-06-10 13:30:39 +02:00
|
|
|
|
2022-01-21 12:32:39 +01:00
|
|
|
const notetypeNames = notetypes.getNotetypeNames(empty);
|
|
|
|
const i18n = setupI18n({
|
|
|
|
modules: [ModuleName.ACTIONS, ModuleName.CHANGE_NOTETYPE, ModuleName.KEYBOARD],
|
|
|
|
});
|
|
|
|
|
2022-01-16 06:05:35 +01:00
|
|
|
export async function setupChangeNotetypePage(
|
2021-06-10 13:30:39 +02:00
|
|
|
oldNotetypeId: number,
|
2021-10-19 01:06:00 +02:00
|
|
|
newNotetypeId: number,
|
2021-06-10 13:30:39 +02:00
|
|
|
): Promise<ChangeNotetypePage> {
|
2022-02-27 08:35:07 +01:00
|
|
|
const changeNotetypeInfo = notetypes.getChangeNotetypeInfo(
|
|
|
|
Notetypes.GetChangeNotetypeInfoRequest.create({
|
|
|
|
oldNotetypeId,
|
|
|
|
newNotetypeId,
|
|
|
|
}),
|
|
|
|
);
|
2022-01-21 12:32:39 +01:00
|
|
|
const [names, info] = await Promise.all([notetypeNames, changeNotetypeInfo, i18n]);
|
2021-06-10 13:30:39 +02:00
|
|
|
|
2021-11-24 22:17:41 +01:00
|
|
|
checkNightMode();
|
2021-06-10 13:30:39 +02:00
|
|
|
|
|
|
|
const state = new ChangeNotetypeState(names, info);
|
|
|
|
return new ChangeNotetypePage({
|
2022-01-16 06:05:35 +01:00
|
|
|
target: document.body,
|
2022-01-21 12:32:39 +01:00
|
|
|
props: { state },
|
2022-01-16 06:05:35 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// use #testXXXX where XXXX is notetype ID to test
|
|
|
|
if (window.location.hash.startsWith("#test")) {
|
|
|
|
const ntid = parseInt(window.location.hash.substr("#test".length), 10);
|
|
|
|
setupChangeNotetypePage(ntid, ntid);
|
2021-06-10 13:30:39 +02:00
|
|
|
}
|