Impor
-
+
diff --git a/src/js/app.js b/src/js/app.js
index 9ad2f38c..d3aa62a2 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -436,13 +436,40 @@ function app() {
this.allMonsters = this.allMonsters.concat(newMonsters);
- let environments = Object.values(this.environments);
+ let environments = {};
+ let creatureTypes = new Set();
+ let creatureSizes = new Set();
+ this.allMonsters.forEach(monster => {
+ monster.environments.split(',').forEach(environment => {
+ if(environment && !environments[environment]){
+ let label = environment = environment.trim();
+ label = label.slice(0,1).toUpperCase() + label.slice(1);
+ environments[environment] = {
+ value: environment,
+ label: label
+ }
+ }
+ });
+
+ creatureTypes.add(monster.data.type)
+ creatureSizes.add(monster.data.size)
+ });
+
+ environments = Object.values(environments);
environments.sort((a, b) => {
return a.value > b.label ? -1 : 1;
});
-
environments.unshift({ value: "any", label: "Any Environment" });
window.dispatchEvent(new CustomEvent('set-environments', { detail: environments }));
+
+ creatureTypes = Array.from(creatureTypes)
+ creatureTypes.sort();
+ creatureTypes = creatureTypes.map(type => ({
+ label: type,
+ value: type.toLowerCase(),
+ }));
+ creatureTypes.unshift({ value: "any", label: "Any Type" });
+ window.dispatchEvent(new CustomEvent('set-creature-types', { detail: creatureTypes }));
},
deleteImportedSource(sourceName){
diff --git a/src/js/importer.js b/src/js/importer.js
index b6c08299..725c7298 100644
--- a/src/js/importer.js
+++ b/src/js/importer.js
@@ -1,8 +1,8 @@
import * as helpers from './helpers';
export default class Importer {
- static key = 'AIzaSyCsGMnu4_lqVj1E0Hsyk7V8CbRpJJauSTM';
+ static key = 'AIzaSyCsGMnu4_lqVj1E0Hsyk7V8CbRpJJauSTM';
static loaders = {
'google-sheets': this._importGoogleSheets,
@@ -76,7 +76,7 @@ export default class Importer {
.then(response => response.json())
.then(jsonifiedBody => {
if (jsonifiedBody.error) {
- return [false, `Google responded with an error: "${jsonifiedBody.error.message}" - is your sheet public?`];
+ return [false, `Google responded with an error: "${jsonifiedBody.error.message}"`];
}
const monsters = jsonifiedBody.sheets.find(sheet => sheet.properties.title === 'Monsters');
@@ -246,13 +246,13 @@ export default class Importer {
static loadersHtml = {
'google-sheets': () => {
return `
-
+
`;
},
'json-raw': () => {
return `
-
+
@@ -260,13 +260,13 @@ export default class Importer {
},
'json-file': () => {
return `
-
+
`;
},
'csv-file': () => {
return `
-
+
diff --git a/src/js/monster.js b/src/js/monster.js
index 27ffddb2..879b1213 100644
--- a/src/js/monster.js
+++ b/src/js/monster.js
@@ -21,18 +21,6 @@ export default class Monster {
this.unique = !!this.data.unique;
this.alignment = this.data.alignment ? Monster.parseAlignment(this.data.alignment) : "";
- this.environments.split(',').forEach(environment => {
-
- if(environment && !this.app.environments[environment]){
- let label = environment = environment.trim();
- label = label.slice(0,1).toUpperCase() + label.slice(1);
- this.app.environments[environment] = {
- value: environment,
- label: label
- }
- }
- });
-
this.searchable = [
this.data.name,
this.data.section,