Skip to content

Commit

Permalink
Pass 2, missing some player-side stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Grygon committed Jun 19, 2021
1 parent 7944ef3 commit d459a90
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
15 changes: 12 additions & 3 deletions src/foundryvtt-adventure-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,22 @@ Hooks.once("setup", function () {
/* ------------------------------------ */
Hooks.once("ready", function () {
// Do anything once the module is ready
SetupManager.migrate();


// Clean up our stored data, removing folders that no longer exist
SetupManager.cleanupData();
SetupManager.createTemplates();
});

// Only run once, set up our render info
Hooks.once(
"renderJournalDirectory",
(app: Application, html: JQuery, data: EntityData) => {

// Need to move this down, ready is too late now...
SetupManager.migrate();

SetupManager.createTemplates();
});

/* ------------------------------------ */
/* For folder right click */
/* ------------------------------------ */
Expand Down
12 changes: 7 additions & 5 deletions src/module/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export class SetupManager {

customLog(`Current version is ${curVer}, last migrated on ${migVer}`);

// Let's just make sure we always migrate while shit's broken
// Remove in 0.3
// if (curVer === migVer) return;
if (curVer === migVer) return;

let journals = <Array<JournalEntry>>(<any>game.journal.entries);

Expand All @@ -38,7 +36,7 @@ export class SetupManager {
return;
}

if (migVer < 0.2) {
if (migVer <= 0.2) {
let templates = journals.filter((j) => j.data.flags.templateFolder);
let normJournals = journals.filter((j) => j.data.flags.template);

Expand Down Expand Up @@ -263,6 +261,10 @@ export class SetupManager {
* @param html Page HTML to add to
*/
static addNewFolderButton(html: JQuery) {
if (!game.user.isGM) {
customLog("User is not a GM!");
return;
}
const actionButtons = html.find(".action-buttons");

const newFolderHtml = `<button class="new-templated-folder">
Expand All @@ -289,7 +291,7 @@ export class SetupManager {
}

/**
* Assigns CSS classes to all templated folders
* Assigns CSS classes to all templated entries
* @param html HTML to search for templates in
*/
static setClasses(html: JQuery<HTMLElement>) {
Expand Down
13 changes: 3 additions & 10 deletions src/module/templ-folder-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class TemplFolderConfig extends FormApplication {
},
submitText: game.i18n.localize(
//@ts-ignore 0.8
this.object.data.id ? "FOLDER.Update" : "FOLDER.Create"
this.object.data._id ? "FOLDER.Update" : "FOLDER.Create"
),
editing: !(this.options.creating),
};
Expand All @@ -70,17 +70,10 @@ export class TemplFolderConfig extends FormApplication {
let created = false;
if (this.options.creating){
folder = await Folder.create(mergeObject(this.object.data, formData))
} else {
this.storeCustom(formData);
}
//@ts-ignore 0.8
folder.update(formData);
if(this.options.creating) {
//@ts-ignore Clunky but w/e
folder.update(formData);
this.object = await TemplatedFolder.convertFolder(folder);
this.storeCustom(formData);
}

this.storeCustom(formData);
}

storeCustom(formData: any) {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"experimentalDecorators": true,
"outDir": "./dist/",
"module": "ES6",
"sourceMap": true,
"inlineSourceMap": true /* Emit a single file with source maps instead of having a separate file. */,
//"inlineSources": true /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */,
"lib": [
"DOM",
"ES6",
Expand Down

0 comments on commit d459a90

Please sign in to comment.