Files
Foundry-VTT-Docker/resources/app/client/data/collections/compendium-packs.js
2025-01-04 00:34:03 +01:00

31 lines
854 B
JavaScript

class CompendiumPacks extends DirectoryCollectionMixin(Collection) {
/**
* Get a Collection of Folders which contain Compendium Packs
* @returns {Collection<Folder>}
*/
get folders() {
return game.folders.reduce((collection, folder) => {
if ( folder.type === "Compendium" ) {
collection.set(folder.id, folder);
}
return collection;
}, new foundry.utils.Collection());
}
/* -------------------------------------------- */
/** @override */
_getVisibleTreeContents() {
return this.contents.filter(pack => pack.visible);
}
/* -------------------------------------------- */
/** @override */
static _sortAlphabetical(a, b) {
if ( a.metadata && b.metadata ) return a.metadata.label.localeCompare(b.metadata.label, game.i18n.lang);
else return super._sortAlphabetical(a, b);
}
}