-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add item sets to API * Add item sets to web client
- Loading branch information
1 parent
1ea7346
commit ea472ba
Showing
15 changed files
with
263 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import DBCEntity from '../dbc/Entity'; | ||
import { contains } from '../utils/string'; | ||
|
||
import Item from './Item'; | ||
|
||
class ItemSet extends DBCEntity { | ||
static get dbc() { | ||
return 'ItemSet'; | ||
} | ||
|
||
static search(query, searchQuery) { | ||
query.filter(itemSet => contains(itemSet.name, searchQuery)); | ||
} | ||
|
||
async quality() { | ||
const item = await this.items().first().execute(); | ||
return item.quality; | ||
} | ||
|
||
items() { | ||
const itemIDs = this.data.itemIDs.filter(id => id); | ||
return Item.query.whereIn('entry', itemIDs); | ||
} | ||
} | ||
|
||
export default ItemSet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/spelunker-api/src/lib/graph/schema/entities/ItemSetType.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { | ||
GraphQLInt, | ||
GraphQLNonNull, | ||
GraphQLObjectType, | ||
GraphQLString, | ||
} from '../../../graphql'; | ||
|
||
import CollectionType from '../CollectionType'; | ||
|
||
import ItemQualityType from './ItemQualityType'; | ||
import ItemType from './ItemType'; | ||
|
||
export default new GraphQLObjectType({ | ||
name: 'ItemSet', | ||
fields: () => ({ | ||
id: { type: new GraphQLNonNull(GraphQLInt) }, | ||
name: { type: new GraphQLNonNull(GraphQLString) }, | ||
quality: { type: ItemQualityType }, | ||
|
||
items: CollectionType.definitionFor(ItemType), | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
packages/spelunker-web/src/components/entities/ItemSet/List.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import gql from 'graphql-tag'; | ||
|
||
import { Box, Collection, Table, Title } from '../../core'; | ||
|
||
import itemSetColumns from './columns'; | ||
|
||
const listItemSets = gql` | ||
query($offset: Int) { | ||
itemSets(offset: $offset) { | ||
totalCount | ||
results { | ||
...itemSetColumns | ||
} | ||
} | ||
} | ||
${itemSetColumns.fragment} | ||
`; | ||
|
||
const ItemSetList = () => ( | ||
<Box> | ||
<Title path={['Item Sets']} /> | ||
|
||
<Collection | ||
accessor="itemSets" | ||
query={listItemSets} | ||
> | ||
{({ results }) => ( | ||
<Table | ||
data={results} | ||
columns={itemSetColumns} | ||
/> | ||
)} | ||
</Collection> | ||
</Box> | ||
); | ||
|
||
export default ItemSetList; |
24 changes: 24 additions & 0 deletions
24
packages/spelunker-web/src/components/entities/ItemSet/Reference/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import gql from 'graphql-tag'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import styles from '../../Item/Reference/index.styl'; | ||
|
||
const ItemSetReference = ({ itemSet }) => ( | ||
<Link | ||
to={`/item-sets/${itemSet.id}`} | ||
className={styles[itemSet.quality.toLowerCase()]} | ||
> | ||
{itemSet.name} | ||
</Link> | ||
); | ||
|
||
ItemSetReference.fragment = gql` | ||
fragment ItemSetReference on ItemSet { | ||
id | ||
name | ||
quality | ||
} | ||
`; | ||
|
||
export default ItemSetReference; |
14 changes: 14 additions & 0 deletions
14
packages/spelunker-web/src/components/entities/ItemSet/columns/ReferenceColumn.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
|
||
import ItemSetReference from '../Reference'; | ||
|
||
const ItemSetReferenceColumn = ({ value: itemSet }) => ( | ||
<ItemSetReference itemSet={itemSet} /> | ||
); | ||
|
||
ItemSetReferenceColumn.defaultProps = { | ||
id: 'item-set', | ||
label: 'Item Set', | ||
}; | ||
|
||
export default ItemSetReferenceColumn; |
25 changes: 25 additions & 0 deletions
25
packages/spelunker-web/src/components/entities/ItemSet/columns/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import gql from 'graphql-tag'; | ||
|
||
import ItemSetReference from '../Reference'; | ||
import { IDColumn } from '../../../core'; | ||
|
||
import ItemSetReferenceColumn from './ReferenceColumn'; | ||
|
||
const columns = [ | ||
<IDColumn />, | ||
<ItemSetReferenceColumn />, | ||
]; | ||
|
||
columns.fragment = gql` | ||
fragment itemSetColumns on ItemSet { | ||
...ItemSetReference | ||
} | ||
${ItemSetReference.fragment} | ||
`; | ||
|
||
export { | ||
ItemSetReferenceColumn, | ||
columns as default, | ||
}; |
Oops, something went wrong.