mirror of
https://github.com/chaoticbackup/chaoticbackup.github.io.git
synced 2026-08-21 08:04:18 -05:00
added artists and search by artist
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -22,7 +22,7 @@ export default class SearchPortal extends React.Component {
|
||||
render() {
|
||||
return (<div className="search">
|
||||
<form onSubmit={this.search}>
|
||||
<input type="text" value={this.query} onChange={(e) => this.query = e.target.value} />
|
||||
<input type="text" value={this.query} autoFocus onChange={(e) => this.query = e.target.value} />
|
||||
<button type="submit"><SearchButton /></button>
|
||||
</form>
|
||||
<DBSearch string={this.input}/>
|
||||
@@ -49,8 +49,10 @@ class DBSearch extends React.Component {
|
||||
|
||||
render() {
|
||||
if (this.loaded == false) {
|
||||
API.LoadDB([{'portal': 'attacks'}, {'portal': 'battlegear'}, {'portal': 'creatures'}, {'portal': 'locations'}, {'portal': 'mugic'}])
|
||||
.then(() => {
|
||||
API.LoadDB([
|
||||
{'portal': 'attacks'}, {'portal': 'battlegear'}, {'portal': 'creatures'}, {'portal': 'locations'}, {'portal': 'mugic'},
|
||||
{'cards': 'attacks'}, {'cards': 'battlegear'}, {'cards': 'creatures'}, {'cards': 'locations'}, {'cards': 'mugic'}
|
||||
]).then(() => {
|
||||
this.loaded = true;
|
||||
});
|
||||
return (<span>Loading...</span>);
|
||||
@@ -167,15 +169,36 @@ class DBSearch extends React.Component {
|
||||
|
||||
let names = [].concat(attackResults, battlegearResults, creatureResults, locationResults, mugicResults).map(makeLink);
|
||||
|
||||
attackResults = API.cards.attacks.find({'gsx$artist': {'$regex': new RegExp(string, 'i')}});
|
||||
battlegearResults = API.cards.battlegear.find({'gsx$artist': {'$regex': new RegExp(string, 'i')}});
|
||||
creatureResults = API.cards.creatures.find({'gsx$artist': {'$regex': new RegExp(string, 'i')}});
|
||||
locationResults = API.cards.locations.find({'gsx$artist': {'$regex': new RegExp(string, 'i')}});
|
||||
mugicResults = API.cards.mugic.find({'gsx$artist': {'$regex': new RegExp(string, 'i')}});
|
||||
|
||||
let artists = [].concat(attackResults, battlegearResults, creatureResults, locationResults, mugicResults).map(makeLink);
|
||||
|
||||
let header;
|
||||
|
||||
if (results.length == 0) {
|
||||
content = (<div>No Results Found</div>);
|
||||
if (artists.length > 0) {
|
||||
header = `Art contributed by ${string}:`;
|
||||
content = artists;
|
||||
}
|
||||
else {
|
||||
header = 'No Results Found';
|
||||
}
|
||||
}
|
||||
else {
|
||||
header = `Results containing ${string}:`;
|
||||
}
|
||||
|
||||
return (<div className="results">
|
||||
<br />
|
||||
{names}
|
||||
<hr />
|
||||
<div>Results containing {string}:</div>
|
||||
{names.length > 0 && <React.Fragment>
|
||||
{names}
|
||||
<hr />
|
||||
</React.Fragment>}
|
||||
<div>{header}</div>
|
||||
{content}
|
||||
</div>);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import React from 'react';
|
||||
import {observable} from "mobx";
|
||||
import {observer, inject} from 'mobx-react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import API from '../../SpreadsheetData';
|
||||
import {Rarity, Unique, Ability} from '../../Snippets';
|
||||
import {Rarity, Ability} from '../../Snippets';
|
||||
import s from '../../../styles/app.style';
|
||||
|
||||
// own "name" display function
|
||||
function Name(props) {
|
||||
@@ -15,6 +17,14 @@ function Name(props) {
|
||||
</React.Fragment>);
|
||||
}
|
||||
|
||||
function Artist(props) {
|
||||
let artists = [];
|
||||
props.artist.split(/(?=, )/).forEach((artist, i) => {
|
||||
artists.push(<Link key={i} to={`/portal/Search/?${artist.replace(", ", "")}`}>{artist}</Link>);
|
||||
});
|
||||
return (<div className="ability">{artists}</div>)
|
||||
}
|
||||
|
||||
@inject((stores, props, context) => props) @observer
|
||||
export default class Single extends React.Component {
|
||||
@observable fullscreen = false;
|
||||
@@ -53,7 +63,7 @@ export default class Single extends React.Component {
|
||||
{card.gsx$artist && <React.Fragment>
|
||||
<div>
|
||||
<strong>Artist(s):</strong>
|
||||
<Ability ability={card.gsx$artist} />
|
||||
<Artist artist={card.gsx$artist} />
|
||||
</div>
|
||||
<hr />
|
||||
</React.Fragment>}
|
||||
|
||||
Reference in New Issue
Block a user