element only feature

This commit is contained in:
Daniel 2019-03-26 03:40:42 -04:00
parent 35d69ac19a
commit 1961edd7b7
4 changed files with 43 additions and 15 deletions

File diff suppressed because one or more lines are too long

View File

@ -244,8 +244,8 @@ export default class SearchCollection extends React.Component {
{elements} 
<label className="none"><input type="checkbox" name="none" checked={this.input.elements.none} onChange={e => this.handleChange(e, "elements")} /><span>None</span></label>
<br />
<input type="button" value="or" className="and" disabled={!this.input.elements.and} onClick={(e)=>{this.input.elements.and=false;}} />
<input type="button" value="and" className="and" disabled={this.input.elements.and} onClick={(e)=>{this.input.elements.and=true;}} />
<input type="button" value={this.input.elements.none ? "none" : "or"} className="and" disabled={!this.input.elements.and} onClick={(e)=>{this.input.elements.and=false;}} />
<input type="button" value={this.input.elements.none ? "only" : "and"} className="and" disabled={this.input.elements.and} onClick={(e)=>{this.input.elements.and=true;}} />
<br /> <hr />
{disciplines}
<br /> <hr />

View File

@ -79,7 +79,6 @@ export default function search_api(input) {
attackResults = attackResults.find({'$or': parm});
battlegearResults = battlegearResults.find({'$or': parm});
let cparm = parm.push
creatureResults = creatureResults.find({'$or':
(parm.concat([{'gsx$brainwashed': {"$or": textList}}]))
});
@ -146,17 +145,41 @@ export default function search_api(input) {
// Search by elements
if (input.elements.none) {
attackResults = attackResults.where(
(obj) => {return (obj.gsx$fire == ('') );}
).where(
(obj) => {return (obj.gsx$air == ('') );}
).where(
(obj) => {return (obj.gsx$earth == ('') );}
).where(
(obj) => {return (obj.gsx$water == ('') );}
);
if (!input.elements.and) {
attackResults = attackResults
.where((obj) => {return (obj.gsx$fire == (''))})
.where((obj) => {return (obj.gsx$air == (''))})
.where((obj) => {return (obj.gsx$earth == (''))})
.where((obj) => {return (obj.gsx$water == (''))});
creatureResults = creatureResults
.where(obj => (obj.gsx$elements == ''));
}
else {
attackResults = attackResults.where(
(obj) => {return (input.elements.fire ? obj.gsx$fire != ('') : obj.gsx$fire == (''));}
).where(
(obj) => {return (input.elements.air ? obj.gsx$air != ('') : obj.gsx$air == (''));}
).where(
(obj) => {return (input.elements.earth ? obj.gsx$earth != ('') : obj.gsx$earth == (''));}
).where(
(obj) => {return (input.elements.water ? obj.gsx$water != ('') : obj.gsx$water == (''));}
);
let el = "";
["fire", "air", "earth", "water"].forEach((element) => {
if (input.elements[element])
el += element + ", ";
});
if (el !== "") {
creatureResults = creatureResults.find({'gsx$elements':
{'$regex': new RegExp(el.substring(0, el.length-2), 'i')}
});
}
}
battlegearResults = battlegearResults.limit(0);
creatureResults = creatureResults.where(obj => (obj.gsx$elements == ''));
locationResults = locationResults.limit(0);
mugicResults = mugicResults.limit(0);
}
@ -179,6 +202,7 @@ export default function search_api(input) {
creatureResults = creatureResults.find({'gsx$elements': {'$or': elementsList} });
attackResults = attackResults.find({'$or': elementsList2});
}
battlegearResults = battlegearResults.limit(0);
locationResults = locationResults.limit(0);
mugicResults = mugicResults.limit(0);

View File

@ -25,6 +25,7 @@ export default class SingleBattlegear extends React.Component {
const battlegear = API.portal.battlegear.findOne({'gsx$name': name});
const card_data = API.cards.battlegear.findOne({'gsx$name': name});
if (battlegear) {
return (<Single
card={card_data}
@ -46,7 +47,7 @@ export default class SingleBattlegear extends React.Component {
</React.Fragment>}
/>);
}
else {
else if (card_data) {
if (card_data.gsx$splash) {
return (<Single card={card_data}/>);
}
@ -54,5 +55,8 @@ export default class SingleBattlegear extends React.Component {
return(<PageNotFound location={this.props.location}/>);
}
}
else {
return(<PageNotFound location={this.props.location}/>);
}
}
}