Add limited sort support
parent
1c08e51b0d
commit
6fab2976cf
|
@ -4,7 +4,7 @@ const path = require('path')
|
||||||
|
|
||||||
module.exports = (plugin, app) => {
|
module.exports = (plugin, app) => {
|
||||||
router.get(['/db/:collection', '/db/:collection/:type', '/db/:collection/:type/:name'], async function(req, res) {
|
router.get(['/db/:collection', '/db/:collection/:type', '/db/:collection/:type/:name'], async function(req, res) {
|
||||||
let collection = app.live.db.getCollection(req.params.collection)
|
let collection = app.live.db.getCollection(req.params.collection).chain()
|
||||||
let results = []
|
let results = []
|
||||||
let error = ''
|
let error = ''
|
||||||
let errorCode = 0
|
let errorCode = 0
|
||||||
|
@ -31,7 +31,10 @@ module.exports = (plugin, app) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//console.log(results, error, errorCode)
|
if (req.query['sort-by']) {
|
||||||
|
results.simplesort(req.query['sort-by'])
|
||||||
|
}
|
||||||
|
results = results.data()
|
||||||
|
|
||||||
let content
|
let content
|
||||||
if (errorCode > 0) {
|
if (errorCode > 0) {
|
||||||
|
|
|
@ -22,17 +22,17 @@
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th><a href="?sort-by=name">Name</a></th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Attack</th>
|
<th><a href="?sort-by=attack">Attack</a></th>
|
||||||
<th>Damage</th>
|
<th><a href="?sort-by=damage">Damage</a></th>
|
||||||
<th>Type</th>
|
<th><a href="?sort-by=weapontype">Type</a></th>
|
||||||
<th>Range</th>
|
<th><a href="?sort-by=range">Range</a></th>
|
||||||
<th>Radius</th>
|
<th>Radius</th>
|
||||||
<th>Capacity</th>
|
<th>Capacity</th>
|
||||||
<th>Duration</th>
|
<th>Duration</th>
|
||||||
<th>Properties</th>
|
<th>Properties</th>
|
||||||
<th>Worth</th>
|
<th><a href="?sort-by=worth">Worth</a></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -62,11 +62,11 @@
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th><a href="?sort-by=name">Name</a></th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Defense</th>
|
<th>Defense</th>
|
||||||
<th>Properties</th>
|
<th>Properties</th>
|
||||||
<th>Worth</th>
|
<th><a href="?sort-by=worth">Worth</a></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -89,10 +89,10 @@
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th><a href="?sort-by=name">Name</a></th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Properties</th>
|
<th>Properties</th>
|
||||||
<th>Worth</th>
|
<th><a href="?sort-by=worth">Worth</a></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -136,6 +136,7 @@
|
||||||
#}}
|
#}}
|
||||||
|
|
||||||
{{##def.consumables_table:it:
|
{{##def.consumables_table:it:
|
||||||
|
Sort: <a href="?sort-by=name">Name</a> <a href="?sort-by=worth">Worth</a>
|
||||||
{{~it :item:index}}
|
{{~it :item:index}}
|
||||||
{{#def.consumables_table_entry:item || ''}}
|
{{#def.consumables_table_entry:item || ''}}
|
||||||
{{~}}
|
{{~}}
|
||||||
|
|
Loading…
Reference in New Issue