mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 04:44:16 +02:00
* Fixed so that CompendiumBrowserSettings saves source/pack names as slugified version to avoid foundrdy not saving names with dots in the middle * Updated excludedPacks with another layer of TypedObjectField * Renmamed variable * Update module/applications/dialogs/CompendiumBrowserSettings.mjs Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com> --------- Co-authored-by: Carlos Fernandez <CarlosFdez@users.noreply.github.com>
38 lines
1.5 KiB
JavaScript
38 lines
1.5 KiB
JavaScript
export default class CompendiumBrowserSettings extends foundry.abstract.DataModel {
|
|
static defineSchema() {
|
|
const fields = foundry.data.fields;
|
|
|
|
return {
|
|
excludedSources: new fields.TypedObjectField(
|
|
new fields.SchemaField({
|
|
excludedDocumentTypes: new fields.ArrayField(
|
|
new fields.StringField({ required: true, choices: CONST.SYSTEM_SPECIFIC_COMPENDIUM_TYPES })
|
|
)
|
|
})
|
|
),
|
|
excludedPacks: new fields.TypedObjectField(
|
|
new fields.TypedObjectField(
|
|
new fields.SchemaField({
|
|
excludedDocumentTypes: new fields.ArrayField(
|
|
new fields.StringField({ required: true, choices: CONST.SYSTEM_SPECIFIC_COMPENDIUM_TYPES })
|
|
)
|
|
})
|
|
)
|
|
)
|
|
};
|
|
}
|
|
|
|
isEntryExcluded(item) {
|
|
const pack = game.packs.get(item.pack);
|
|
if (!pack) return false;
|
|
|
|
const packageName = pack.metadata.packageType === 'world' ? 'world' : pack.metadata.packageName;
|
|
const excludedSourceData = this.excludedSources[packageName];
|
|
if (excludedSourceData && excludedSourceData.excludedDocumentTypes.includes(pack.metadata.type)) return true;
|
|
|
|
const excludedPackData = this.excludedPacks[packageName]?.[pack.metadata.name];
|
|
if (excludedPackData && excludedPackData.excludedDocumentTypes.includes(pack.metadata.type)) return true;
|
|
|
|
return false;
|
|
}
|
|
}
|