search by rarity

This commit is contained in:
Daniel 2017-11-17 03:24:56 -05:00
parent fd1aef642a
commit 045ca13d80
3 changed files with 48 additions and 18 deletions

File diff suppressed because one or more lines are too long

View File

@ -23,9 +23,10 @@ export default class Creature extends React.Component {
<div style={{verticalAlign: 'text-top', float: 'left', width: "50%"}}>
<img height="20" className="icon" src={"/src/img/icons/tribes/"+creature.gsx$tribe.toLowerCase()+".png"}></img>
<span>{creature.gsx$name}</span><br />
<span>{creature.gsx$rarity}</span><br />
<span>Creature - {creature.gsx$tribe} {creature.gsx$types}</span><br />
<span>{elements}</span><br />
<span>Energy: {creature.gsx$energy}</span><br />
<span>{creature.gsx$ability}</span>
</div>
<div style={{verticalAlign: 'text-top', float: 'left'}}>
<span>{creature.gsx$courage}&nbsp;<img height="16" className="icon" src={"/src/img/icons/disciplines/courage.png"}></img></span><br />

View File

@ -63,12 +63,13 @@ export default class CollectionHome extends React.Component {
return (
<div>
<p>
This page is under construction. <br />
In the meantime, you can check out&nbsp;
This page is under construction. In the meantime, you can check out&nbsp;
<a style={{textDecoration: "underline"}} href="http://www.tradecardsonline.com/im/editCollection/collection_type/1">Trade Cards Online</a>
.
</p><br />
{this.searchForm()}<br />
</p>
<hr />
{this.searchForm()}
<hr />
{this.navigation()}<br />
{output()}
</div>
@ -79,6 +80,7 @@ export default class CollectionHome extends React.Component {
let stones = {};
let tribes = {};
let elements = {};
let rarity = {};
// TODO advanced filters
let search = (e) => {
@ -93,7 +95,10 @@ export default class CollectionHome extends React.Component {
// Search by name
if (stones.name.value) {
baseResultset = baseResultset.find({'gsx$name': {'$regex': new RegExp(stones.name.value, 'i')} });
baseResultset = baseResultset.find({'$or': [
{'gsx$name': {'$regex': new RegExp(stones.name.value, 'i')}},
{'gsx$tags': {'$regex': new RegExp(stones.name.value, 'i')}}
]});
}
// Search by tribe
@ -120,7 +125,6 @@ export default class CollectionHome extends React.Component {
}
}
if (elementsList.length > 0) {
console.log(this.swamp);
if (this.swamp == "or") {
baseResultset = baseResultset.find({'gsx$elements': {'$or': elementsList} });
}
@ -130,6 +134,16 @@ export default class CollectionHome extends React.Component {
}
}
let rarityList = [];
for (const key in rarity) {
if (rarity[key].checked) {
rarityList.push({'$eq': key});
}
}
if (rarityList.length > 0) {
baseResultset = baseResultset.find({'gsx$rarity': {'$or': rarityList} });
}
// Sort data descending alphabetically
let results = baseResultset.simplesort('gsx$name').data();
if (results.length > 0) this.content = results;
@ -140,7 +154,6 @@ export default class CollectionHome extends React.Component {
return (
<div>
<form onSubmit={search}>
<label>Show all cards:<input type="checkbox" ref={(input) => stones.allCards = input}/></label><br />
<label>Card Name:<input type="text" ref={(input) => stones.name = input} /></label>
<br /><br />
<div>
@ -161,7 +174,22 @@ export default class CollectionHome extends React.Component {
<input type="checkbox" ref={(input) => stones.noElements = input}/><span>No Elements</span>
</div>
<br />
<input type="submit" value="Search" />
<div>
<label><input type="checkbox" ref={(input) => rarity["Common"] = input}/>Common</label>&nbsp;
<label><input type="checkbox" ref={(input) => rarity["Uncommon"] = input}/>Uncommon</label>&nbsp;
<label><input type="checkbox" ref={(input) => rarity["Rare"] = input}/>Rare</label>&nbsp;
<label><input type="checkbox" ref={(input) => rarity["Super Rare"] = input}/>Super Rare</label>&nbsp;
<label><input type="checkbox" ref={(input) => rarity["Ultra Rare"] = input}/>Ultra Rare</label>&nbsp;
<label><input type="checkbox" ref={(input) => rarity["Promo"] = input}/>Promo</label>
</div>
<br />
<p>
Since not all data has been entered not all cards are listed,<br />
to see incomplete cards, click&nbsp;
<label>"Show all cards":<input type="checkbox" ref={(input) => stones.allCards = input}/></label>
</p>
<br />
<input type="submit" value="Search" />&nbsp;&nbsp;<input type="button" disabled value="Reset" />
</form>
</div>
);