0.4.5 15-Mar-2021
Fixed; Issue #10 ( Spells from non-system compendium show up in items tab.) compendium-browser.js - loadAndFilterItems(): Refactor test on content to switch on tab (spells, feats, items) and if on item type - getFilterResult() -> passesFilter()features_update
parent
280c0bcb44
commit
f724d8fb4e
|
@ -5,7 +5,7 @@
|
||||||
* @version 0.2.0
|
* @version 0.2.0
|
||||||
*/
|
*/
|
||||||
/** @author Jeffrey Pugh aka @spetzel2020
|
/** @author Jeffrey Pugh aka @spetzel2020
|
||||||
* @version 0.4.0
|
* @version 0.4
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
4-Feb-2020 0.4.0 Switch to not pre-loading the indexes, and instead do that at browsing time, to reduce server load and memory usage
|
4-Feb-2020 0.4.0 Switch to not pre-loading the indexes, and instead do that at browsing time, to reduce server load and memory usage
|
||||||
|
@ -35,12 +35,14 @@
|
||||||
10-Mar-2021 0.4.3: activateItemListListeners(): Remove spurious li.parents (wasn't being used anyway)
|
10-Mar-2021 0.4.3: activateItemListListeners(): Remove spurious li.parents (wasn't being used anyway)
|
||||||
11-Mar-2021 0.4.3 Fixed: Reset Filters doesn't clear the on-screen filter fields (because it is not completely re-rendering like it used to) Issue #4
|
11-Mar-2021 0.4.3 Fixed: Reset Filters doesn't clear the on-screen filter fields (because it is not completely re-rendering like it used to) Issue #4
|
||||||
Hack solution is to re-render whole dialog which unfortunately loses filter settings on other tabs as well
|
Hack solution is to re-render whole dialog which unfortunately loses filter settings on other tabs as well
|
||||||
0.4.3b: Clear all filters to match displayed
|
0.4.3b: Clear all filters to match displayed
|
||||||
|
15-Mar-2021 0.4.5: Fix: Spells from non-system compendium show up in items tab. Issue#10
|
||||||
|
loadAndFilterItems(): Changed tests to switch + more explicit tests
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const CMPBrowser = {
|
const CMPBrowser = {
|
||||||
MODULE_NAME : "compendium-browser",
|
MODULE_NAME : "compendium-browser",
|
||||||
MODULE_VERSION : "0.4.3",
|
MODULE_VERSION : "0.4.5",
|
||||||
MAXLOAD : 500, //Default for the maximum number to load before displaying a message that you need to filter to see more
|
MAXLOAD : 500, //Default for the maximum number to load before displaying a message that you need to filter to see more
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,41 +476,55 @@ class CompendiumBrowser extends Application {
|
||||||
//Filter the full list, but only save the core compendium information + level
|
//Filter the full list, but only save the core compendium information + level
|
||||||
for (let pack of game.packs) {
|
for (let pack of game.packs) {
|
||||||
if (pack['metadata']['entity'] === "Item" && this.settings.loadedSpellCompendium[pack.collection].load) {
|
if (pack['metadata']['entity'] === "Item" && this.settings.loadedSpellCompendium[pack.collection].load) {
|
||||||
//FIXME: How much could we do with the loaded index rather than all content?
|
//FIXME: How much could we do with the loaded index rather than all content?
|
||||||
|
//OR filter the content up front for the decoratedItem.type??
|
||||||
await pack.getContent().then(content => {
|
await pack.getContent().then(content => {
|
||||||
for (let item5e of content) {
|
for (let item5e of content) {
|
||||||
let compactItem = null;
|
let compactItem = null;
|
||||||
const decoratedItem = this.decorateItem(item5e);
|
const decoratedItem = this.decorateItem(item5e);
|
||||||
if (decoratedItem) {
|
if (decoratedItem) {
|
||||||
if ((browserTab === "spell") && (decoratedItem.type === "spell")) {
|
switch (browserTab) {
|
||||||
if (this.getFilterResult(decoratedItem, this.spellFilters.activeFilters)) {
|
case "spell":
|
||||||
compactItem = {
|
if ((decoratedItem.type === "spell") && this.passesFilter(decoratedItem, this.spellFilters.activeFilters)) {
|
||||||
compendium : pack.collection,
|
compactItem = {
|
||||||
name : decoratedItem.name,
|
compendium : pack.collection,
|
||||||
img: decoratedItem.img,
|
name : decoratedItem.name,
|
||||||
data : {
|
img: decoratedItem.img,
|
||||||
level : decoratedItem.data?.level,
|
data : {
|
||||||
components : decoratedItem.data?.components
|
level : decoratedItem.data?.level,
|
||||||
|
components : decoratedItem.data?.components
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if ((browserTab === "feat") && ((decoratedItem.type === "feat") || (decoratedItem.type === "class"))) {
|
|
||||||
if (this.getFilterResult(decoratedItem, this.featFilters.activeFilters)) {
|
case "feat":
|
||||||
compactItem = {
|
if (["feat","class"].includes(decoratedItem.type) && this.passesFilter(decoratedItem, this.featFilters.activeFilters)) {
|
||||||
compendium : pack.collection,
|
compactItem = {
|
||||||
name : decoratedItem.name,
|
compendium : pack.collection,
|
||||||
img: decoratedItem.img,
|
name : decoratedItem.name,
|
||||||
classRequirementString : decoratedItem.classRequirementString
|
img: decoratedItem.img,
|
||||||
|
classRequirementString : decoratedItem.classRequirementString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "item":
|
||||||
|
//0.4.5: Itm type for true items could be many things (weapon, consumable, etc) so we just look for everything except spells, feats, classes
|
||||||
|
if (!["spell","feat","class"].includes(decoratedItem.type) && this.passesFilter(decoratedItem, this.itemFilters.activeFilters)) {
|
||||||
|
compactItem = {
|
||||||
|
compendium : pack.collection,
|
||||||
|
name : decoratedItem.name,
|
||||||
|
img: decoratedItem.img,
|
||||||
|
type : decoratedItem.type
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
} else if ((browserTab === "item") && this.getFilterResult(decoratedItem, this.itemFilters.activeFilters)) {
|
|
||||||
compactItem = {
|
default:
|
||||||
compendium : pack.collection,
|
break;
|
||||||
name : decoratedItem.name,
|
|
||||||
img: decoratedItem.img,
|
|
||||||
type : decoratedItem.type
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compactItem) { //Indicates it passed the filters
|
if (compactItem) { //Indicates it passed the filters
|
||||||
compactItems[decoratedItem._id] = compactItem;
|
compactItems[decoratedItem._id] = compactItem;
|
||||||
if (numItemsLoaded++ >= maxLoad) break;
|
if (numItemsLoaded++ >= maxLoad) break;
|
||||||
|
@ -692,7 +708,7 @@ class CompendiumBrowser extends Application {
|
||||||
for (let npc of content) {
|
for (let npc of content) {
|
||||||
let compactNpc = null;
|
let compactNpc = null;
|
||||||
const decoratedNpc = this.decorateNpc(npc);
|
const decoratedNpc = this.decorateNpc(npc);
|
||||||
if (decoratedNpc && this.getFilterResult(decoratedNpc, this.npcFilters.activeFilters)) {
|
if (decoratedNpc && this.passesFilter(decoratedNpc, this.npcFilters.activeFilters)) {
|
||||||
//0.4.2: Don't store all the details - just the display elements
|
//0.4.2: Don't store all the details - just the display elements
|
||||||
compactNpc = {
|
compactNpc = {
|
||||||
compendium : pack.collection,
|
compendium : pack.collection,
|
||||||
|
@ -1106,7 +1122,7 @@ class CompendiumBrowser extends Application {
|
||||||
filterElements(list, subjects, filters) {
|
filterElements(list, subjects, filters) {
|
||||||
for (let element of list) {
|
for (let element of list) {
|
||||||
let subject = subjects[element.dataset.entryId];
|
let subject = subjects[element.dataset.entryId];
|
||||||
if (this.getFilterResult(subject, filters) == false) {
|
if (this.passesFilter(subject, filters) == false) {
|
||||||
$(element).hide();
|
$(element).hide();
|
||||||
} else {
|
} else {
|
||||||
$(element).show();
|
$(element).show();
|
||||||
|
@ -1114,7 +1130,7 @@ class CompendiumBrowser extends Application {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getFilterResult(subject, filters) {
|
passesFilter(subject, filters) {
|
||||||
for (let filter of Object.values(filters)) {
|
for (let filter of Object.values(filters)) {
|
||||||
let prop = getProperty(subject, filter.path);
|
let prop = getProperty(subject, filter.path);
|
||||||
if (filter.type === 'numberCompare') {
|
if (filter.type === 'numberCompare') {
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
"name": "compendium-browser",
|
"name": "compendium-browser",
|
||||||
"title": "Compendium Browser",
|
"title": "Compendium Browser",
|
||||||
"description": "<p>Easily browse and filter spells, feats, items, and npcs loaded from compendia!</p><strong>NEW! Compendium Browser is faster and better-behaved;</strong> it no longer loads all the compendia into memory on start-up (which sometimes hung servers because of memory or CPU requirements). Instead, it filters and loads on-demand, as well as giving you a Module Setting to control how many rows are loaded at a time.<br>Changes in v0.4.3:<ul><li>Fixed: Error on dragging item from Compendium Browser (<a href='https://github.com/League-of-Foundry-Developers/compendium-browser/issues/9'>Issue #9</a>)</li><li>Fixed: Reset Filters doesn't clear the onscreen filters (<a href='https://github.com/League-of-Foundry-Developers/compendium-browser/issues/4'>Issue #4</a>)</li></ul>",
|
"description": "<p>Easily browse and filter spells, feats, items, and npcs loaded from compendia!</p><strong>NEW! Compendium Browser is faster and better-behaved;</strong> it no longer loads all the compendia into memory on start-up (which sometimes hung servers because of memory or CPU requirements). Instead, it filters and loads on-demand, as well as giving you a Module Setting to control how many rows are loaded at a time.<br>Changes in v0.4.3:<ul><li>Fixed: Error on dragging item from Compendium Browser (<a href='https://github.com/League-of-Foundry-Developers/compendium-browser/issues/9'>Issue #9</a>)</li><li>Fixed: Reset Filters doesn't clear the onscreen filters (<a href='https://github.com/League-of-Foundry-Developers/compendium-browser/issues/4'>Issue #4</a>)</li></ul>",
|
||||||
"version": "0.4.3",
|
"version": "0.4.5",
|
||||||
"author": "Felix#6196",
|
"author": "Spetzel#0103",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Spetzel#0103",
|
"name": "Spetzel#0103",
|
||||||
|
|
Loading…
Reference in New Issue