Skip to content

Commit

Permalink
Corrected an issue that prevented Actor or Item default sheets from u…
Browse files Browse the repository at this point in the history
…pdating when the library wasn't enabled for those document types.

Resolves: #7
  • Loading branch information
zeel01 committed Aug 20, 2021
1 parent 3c29240 commit 1fb5edb
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions scripts/document-sheet-registrar.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ export default class DocumentSheetRegistrar {
static get name() { return "_document-sheet-registrar"; }


/**
* Names of documents that should always be updated even if they are disabled
*
* @static
* @memberof DocumentSheetRegistrar
*/
static alwaysUpdate = ["Actor", "Item"];


/**
* A function to filter the CONFIG...Document object for only
* documents that have either the sheetClass or sheetClasses property
Expand All @@ -58,6 +67,9 @@ export default class DocumentSheetRegistrar {
* A list of booleans for each document type that indicates whether
* or not the sheet registration is enabled.
*
* DEBUG: Setting the Boolean in the last line to `true` will
* enable all documents, this may be useful for debugging.
*
* @type {object<string, boolean>}
*
* @static
Expand All @@ -66,7 +78,7 @@ export default class DocumentSheetRegistrar {
static settings = Object.fromEntries(
Object.entries(CONFIG)
.filter(this.filterDocs)
.map(([key, config]) => [key, true])
.map(([key, config]) => [key, false])
);

/**
Expand Down Expand Up @@ -408,7 +420,14 @@ export default class DocumentSheetRegistrar {
*/
static updateDefaultSheets(setting = {}) {
if (!Object.keys(setting).length) return;
const documents = DocumentSheetRegistrar.documentTypes.filter(doc => doc.enabled).map(doc => doc.name);

// Get a list of document names that the updater should dun on
const documents = DocumentSheetRegistrar.documentTypes
// Enabled documents, and any that are always updated like Actor or Item
.filter(doc => doc.enabled || DocumentSheetRegistrar.alwaysUpdate.includes(doc.name))
// We just need an array of the names
.map(doc => doc.name);

for (let documentName of documents) {
const cfg = CONFIG[documentName];
const classes = cfg.sheetClasses;
Expand Down

0 comments on commit 1fb5edb

Please sign in to comment.