Skip to content

Commit

Permalink
Added warning to tell the user if there isn't a module to render a pa…
Browse files Browse the repository at this point in the history
…rticular document.
  • Loading branch information
zeel01 committed Aug 8, 2021
1 parent f2bb39e commit 247e887
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
download: https://github.com/${{github.repository}}/releases/download/${{github.event.release.tag_name}}/_document-sheet-registrar.zip

# Create a zip file with all files required by the module to add to the release
- run: zip -r ./_document-sheet-registrar.zip module.json LICENSE scripts/
- run: zip -r ./_document-sheet-registrar.zip module.json LICENSE scripts/ lang/

# Create a release for this specific version
- name: Update Release with Files
Expand Down
15 changes: 15 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"_document-sheet-registrar": {
"title": "Lib: Document Sheet Registrar",
"ui": {
"warn": {
"no-sheet-found": "There is not a sheet `{sheet}` registered to display this document. You may need to enable an associated module."
}
},
"console": {
"log": {
"init": "Document Sheet Registrar: Initialized"
}
}
}
}
7 changes: 7 additions & 0 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
"manifestPlusVersion": "1.1.0",
"minimumCoreVersion": "0.8.8",
"compatibleCoreVersion": "0.8.8",
"languages": [
{
"lang": "en",
"name": "English",
"path": "lang/en.json"
}
],
"authors": [
{
"name": "zeel",
Expand Down
9 changes: 8 additions & 1 deletion scripts/document-sheet-registrar.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export default class DocumentSheetRegistrar {
* @memberof DocumentSheetRegistrar
*/
static initializeDocumentSheets() {
console.log(game.i18n.localize("_document-sheet-registrar.console.log.init"));

for (let doc of this.documentTypes) {
// Skip any collection that already has a sheet registration method
if (doc.collection.registerSheet) continue;
Expand Down Expand Up @@ -297,7 +299,12 @@ export default class DocumentSheetRegistrar {
const override = this.getFlag("core", "sheetClass");
if (sheets[override]) return sheets[override].cls;
const classes = Object.values(sheets);
if (!classes.length) return null;
if (!classes.length) {
ui.notifications.warn(
game.i18n.format("_document-sheet-registrar.ui.warn.no-sheet-found", { sheet: override })
);
return null;
}
return (classes.find(s => s.default) ?? classes.pop()).cls;
}

Expand Down

0 comments on commit 247e887

Please sign in to comment.