mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 04:44:16 +02:00
Updated excludedPacks with another layer of TypedObjectField
This commit is contained in:
parent
a6e9f2cac2
commit
4bfb2cc63c
3 changed files with 28 additions and 22 deletions
|
|
@ -50,12 +50,11 @@ export default class CompendiumBrowserSettings extends HandlebarsApplicationMixi
|
||||||
const excludedSourceData = this.browserSettings.excludedSources;
|
const excludedSourceData = this.browserSettings.excludedSources;
|
||||||
const excludedPackData = this.browserSettings.excludedPacks;
|
const excludedPackData = this.browserSettings.excludedPacks;
|
||||||
context.typePackCollections = game.packs.reduce((acc, pack) => {
|
context.typePackCollections = game.packs.reduce((acc, pack) => {
|
||||||
const { type, label, packageType, packageName: basePackageName, id: baseId } = pack.metadata;
|
const { type, label, packageType, packageName: basePackageName, name, id } = pack.metadata;
|
||||||
if (!CompendiumBrowserSettings.#browserPackTypes.includes(type)) return acc;
|
if (!CompendiumBrowserSettings.#browserPackTypes.includes(type)) return acc;
|
||||||
|
|
||||||
const id = baseId.slugify();
|
|
||||||
const isWorldPack = packageType === 'world';
|
const isWorldPack = packageType === 'world';
|
||||||
const packageName = isWorldPack ? 'world' : basePackageName.slugify();
|
const packageName = isWorldPack ? 'world' : basePackageName;
|
||||||
const sourceChecked =
|
const sourceChecked =
|
||||||
!excludedSourceData[packageName] ||
|
!excludedSourceData[packageName] ||
|
||||||
!excludedSourceData[packageName].excludedDocumentTypes.includes(type);
|
!excludedSourceData[packageName].excludedDocumentTypes.includes(type);
|
||||||
|
|
@ -69,10 +68,12 @@ export default class CompendiumBrowserSettings extends HandlebarsApplicationMixi
|
||||||
if (!acc[type].sources[packageName])
|
if (!acc[type].sources[packageName])
|
||||||
acc[type].sources[packageName] = { label: sourceLabel, checked: sourceChecked, packs: [] };
|
acc[type].sources[packageName] = { label: sourceLabel, checked: sourceChecked, packs: [] };
|
||||||
|
|
||||||
const checked = !excludedPackData[id] || !excludedPackData[id].excludedDocumentTypes.includes(type);
|
const checked =
|
||||||
|
!excludedPackData[packageName] ||
|
||||||
|
!excludedPackData[packageName][name]?.excludedDocumentTypes.includes(type);
|
||||||
|
|
||||||
acc[type].sources[packageName].packs.push({
|
acc[type].sources[packageName].packs.push({
|
||||||
pack: id,
|
name,
|
||||||
type,
|
type,
|
||||||
label: id === game.system.id ? game.system.title : game.i18n.localize(label),
|
label: id === game.system.id ? game.system.title : game.i18n.localize(label),
|
||||||
checked: checked
|
checked: checked
|
||||||
|
|
@ -107,16 +108,20 @@ export default class CompendiumBrowserSettings extends HandlebarsApplicationMixi
|
||||||
toggleTypedPack(event) {
|
toggleTypedPack(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
const { type, pack } = event.target.dataset;
|
const { type, source, packName } = event.target.dataset;
|
||||||
const currentlyExcluded = this.browserSettings.excludedPacks[pack]
|
const currentlyExcluded = this.browserSettings.excludedPacks[source]?.[packName]
|
||||||
? this.browserSettings.excludedPacks[pack].excludedDocumentTypes.includes(type)
|
? this.browserSettings.excludedPacks[source][packName].excludedDocumentTypes.includes(type)
|
||||||
: false;
|
: false;
|
||||||
|
|
||||||
if (!this.browserSettings.excludedPacks[pack])
|
if (!this.browserSettings.excludedPacks[source]?.[packName]) {
|
||||||
this.browserSettings.excludedPacks[pack] = { excludedDocumentTypes: [] };
|
if (!this.browserSettings.excludedPacks[source]) this.browserSettings.excludedPacks[source] = {};
|
||||||
this.browserSettings.excludedPacks[pack].excludedDocumentTypes = currentlyExcluded
|
|
||||||
? this.browserSettings.excludedPacks[pack].excludedDocumentTypes.filter(x => x !== type)
|
this.browserSettings.excludedPacks[source][packName] = { excludedDocumentTypes: [] };
|
||||||
: [...(this.browserSettings.excludedPacks[pack]?.excludedDocumentTypes ?? []), type];
|
}
|
||||||
|
|
||||||
|
this.browserSettings.excludedPacks[source][packName].excludedDocumentTypes = currentlyExcluded
|
||||||
|
? this.browserSettings.excludedPacks[source][packName].excludedDocumentTypes.filter(x => x !== type)
|
||||||
|
: [...(this.browserSettings.excludedPacks[source][packName]?.excludedDocumentTypes ?? []), type];
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,14 @@ export default class CompendiumBrowserSettings extends foundry.abstract.DataMode
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
excludedPacks: new fields.TypedObjectField(
|
excludedPacks: new fields.TypedObjectField(
|
||||||
|
new fields.TypedObjectField(
|
||||||
new fields.SchemaField({
|
new fields.SchemaField({
|
||||||
excludedDocumentTypes: new fields.ArrayField(
|
excludedDocumentTypes: new fields.ArrayField(
|
||||||
new fields.StringField({ required: true, choices: CONST.SYSTEM_SPECIFIC_COMPENDIUM_TYPES })
|
new fields.StringField({ required: true, choices: CONST.SYSTEM_SPECIFIC_COMPENDIUM_TYPES })
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -24,12 +26,11 @@ export default class CompendiumBrowserSettings extends foundry.abstract.DataMode
|
||||||
const pack = game.packs.get(item.pack);
|
const pack = game.packs.get(item.pack);
|
||||||
if (!pack) return false;
|
if (!pack) return false;
|
||||||
|
|
||||||
const packageName = pack.metadata.packageType === 'world' ? 'world' : pack.metadata.packageName.slugify();
|
const packageName = pack.metadata.packageType === 'world' ? 'world' : pack.metadata.packageName;
|
||||||
const excludedSourceData = this.excludedSources[packageName];
|
const excludedSourceData = this.excludedSources[packageName];
|
||||||
if (excludedSourceData && excludedSourceData.excludedDocumentTypes.includes(pack.metadata.type)) return true;
|
if (excludedSourceData && excludedSourceData.excludedDocumentTypes.includes(pack.metadata.type)) return true;
|
||||||
|
|
||||||
const packName = item.pack.slugify();
|
const excludedPackData = this.excludedPacks[packageName]?.[pack.metadata.name];
|
||||||
const excludedPackData = this.excludedPacks[packName];
|
|
||||||
if (excludedPackData && excludedPackData.excludedDocumentTypes.includes(pack.metadata.type)) return true;
|
if (excludedPackData && excludedPackData.excludedDocumentTypes.includes(pack.metadata.type)) return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
<div class="checks-container {{#unless source.checked}}collapsed{{/unless}}">
|
<div class="checks-container {{#unless source.checked}}collapsed{{/unless}}">
|
||||||
{{#each source.packs as |pack|}}
|
{{#each source.packs as |pack|}}
|
||||||
<div class="check-container">
|
<div class="check-container">
|
||||||
<input type="checkbox" class="pack-checkbox" data-type="{{pack.type}}" data-pack="{{pack.pack}}" {{checked pack.checked}} />
|
<input type="checkbox" class="pack-checkbox" data-type="{{pack.type}}" data-source="{{@../key}}" data-pack-name="{{pack.name}}" {{checked pack.checked}} />
|
||||||
<label>{{pack.label}}</label>
|
<label>{{pack.label}}</label>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue