mirror of
https://github.com/chaoticbackup/chaoticbackup.github.io.git
synced 2026-04-21 16:17:26 -05:00
allow excluding element search (wip)
This commit is contained in:
parent
8a20b2b5fc
commit
9e12aea855
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,9 +1,10 @@
|
|||
import React from 'react';
|
||||
import { observable } from "mobx";
|
||||
import { observer, inject } from 'mobx-react';
|
||||
import React from 'react';
|
||||
import Collapsible from 'react-collapsible';
|
||||
import API from '../../SpreadsheetData';
|
||||
|
||||
import { Loading } from '../../Snippets';
|
||||
import API from '../../SpreadsheetData';
|
||||
import search_api from './search';
|
||||
|
||||
@inject((stores, props, context) => props) @observer
|
||||
|
|
@ -282,7 +283,7 @@ export default class SearchCollection extends React.Component {
|
|||
<label className="none"><input type="checkbox" name="none" checked={this.input.elements.none} onChange={e => this.handleChange(e, "elements")} /><span>None</span></label>
|
||||
</div>
|
||||
<div className="centeredButtons">
|
||||
<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 ? "not" : "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}} />
|
||||
</div>
|
||||
<hr />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import loki from 'lokijs';
|
||||
|
||||
import API from '../../SpreadsheetData';
|
||||
|
||||
function cleanInputRegex(input, check=true) {
|
||||
|
|
@ -182,24 +183,45 @@ export default function search_api(input) {
|
|||
// Search by elements
|
||||
if (input.elements.none) {
|
||||
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 == (''))});
|
||||
const { fire, air, earth, water } = input.elements;
|
||||
|
||||
creatureResults = creatureResults
|
||||
.where(obj => (obj.gsx$elements == ''));
|
||||
if (fire || air || earth || water) {
|
||||
if (input.elements.fire) {
|
||||
attackResults = attackResults.where(obj => obj.gsx$fire == "");
|
||||
}
|
||||
if (input.elements.air) {
|
||||
attackResults = attackResults.where(obj => obj.gsx$air == "");
|
||||
}
|
||||
if (input.elements.earth) {
|
||||
attackResults = attackResults.where(obj => obj.gsx$earth == "");
|
||||
}
|
||||
if (input.elements.water) {
|
||||
attackResults = attackResults.where(obj => obj.gsx$water == "");
|
||||
}
|
||||
/// ^((?!fire).)*$
|
||||
// TODO ignore creature elements
|
||||
creatureResults = creatureResults
|
||||
.where(obj => (obj.gsx$elements == ''));
|
||||
} else {
|
||||
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 == (''))}
|
||||
(obj) => (input.elements.fire ? obj.gsx$fire != "" : obj.gsx$fire == "")
|
||||
).where(
|
||||
(obj) => {return (input.elements.air ? obj.gsx$air != ('') : obj.gsx$air == (''))}
|
||||
(obj) => (input.elements.air ? obj.gsx$air != "" : obj.gsx$air == "")
|
||||
).where(
|
||||
(obj) => {return (input.elements.earth ? obj.gsx$earth != ('') : obj.gsx$earth == (''))}
|
||||
(obj) => (input.elements.earth ? obj.gsx$earth != "" : obj.gsx$earth == "")
|
||||
).where(
|
||||
(obj) => {return (input.elements.water ? obj.gsx$water != ('') : obj.gsx$water == (''))}
|
||||
(obj) => (input.elements.water ? obj.gsx$water != "" : obj.gsx$water == "")
|
||||
);
|
||||
|
||||
let el = "";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user