This commit is contained in:
Nick Winter 2014-03-28 11:02:23 -07:00
parent 62867534a7
commit ff7e2d5d47
3 changed files with 17 additions and 4 deletions

View file

@ -1,5 +1,5 @@
h3(data-i18n="editor.level_tab_thangs_add") Add Thangs
input(type="text", id="thang-search")
input(type="search", id="thang-search")
#thangs-list
for group in groups
h4= group.name

View file

@ -21,7 +21,7 @@ componentOriginals =
"physics.Physical" : "524b75ad7fc0f6d519000001"
class ThangTypeSearchCollection extends CocoCollection
url: '/db/thang.type/search?project=true'
url: '/db/thang.type/search?project=original,name,version,slug,kind,components'
model: ThangType
module.exports = class ThangsTabView extends View

View file

@ -2,6 +2,8 @@ async = require 'async'
mongoose = require('mongoose')
Grid = require 'gridfs-stream'
errors = require './errors'
log = require 'winston'
PROJECT = {original:1, name:1, version:1, description: 1, slug:1, kind: 1}
FETCH_LIMIT = 150
@ -99,6 +101,17 @@ module.exports = class Handler
filters = [{filter: {index: true}}]
if @modelClass.schema.uses_coco_permissions and req.user
filters.push {filter: {index: req.user.get('id')}}
projection = null
if req.query.project is 'true'
projection = PROJECT
else if req.query.project
if @modelClass.className is 'User'
projection = PROJECTION
log.warn "Whoa, we haven't yet thought about public properties for User projection yet."
else
projection = {}
for field in req.query.project.split(',')
projection[field] = 1
for filter in filters
callback = (err, results) =>
return @sendDatabaseError(res, err) if err
@ -111,11 +124,11 @@ module.exports = class Handler
res.send matchedObjects
res.end()
if term
filter.project = PROJECT if req.query.project
filter.project = projection
@modelClass.textSearch term, filter, callback
else
args = [filter.filter]
args.push PROJECT if req.query.project
args.push projection if projection
@modelClass.find(args...).limit(FETCH_LIMIT).exec callback
versions: (req, res, id) ->