Merge branch 'master' into production

This commit is contained in:
Nick Winter 2014-08-28 10:52:15 -07:00
commit 8bb6af2c77
13 changed files with 47 additions and 59 deletions

View file

@ -212,6 +212,11 @@ class CocoModel extends Backbone.Model
return false return false
getOwner: ->
return null unless permissions = @get 'permissions'
ownerPermission = _.find permissions, access: 'owner'
ownerPermission?.target
getDelta: -> getDelta: ->
differ = deltasLib.makeJSONDiffer() differ = deltasLib.makeJSONDiffer()
differ.diff @_revertAttributes, @attributes differ.diff @_revertAttributes, @attributes

View file

@ -16,6 +16,9 @@
overflow: hidden overflow: hidden
text-overflow: ellipsis text-overflow: ellipsis
tr.mine
background-color: #f8ecaa
.loading .loading
text-align: center text-align: center

View file

@ -233,6 +233,7 @@
position: relative position: relative
height: 100% height: 100%
width: 100% width: 100%
z-index: 1
.bubble .bubble
position: absolute position: absolute

View file

@ -1,21 +1 @@
table.table extends /templates/kinds/table
tr
th(colspan=3)
span(data-i18n="general.results")
| Results
span
|: #{documents.length}
tr
th(data-i18n="general.name") Name
th(data-i18n="general.description") Description
th(data-i18n="general.version") Version
for data in documents
- data = data.attributes;
tr
td
a(href="/editor/article/#{data.slug || data._id}")
| #{data.name}
td.body-row #{data.description}
td #{data.version.major}.#{data.version.minor}

View file

@ -1,21 +1 @@
table.table extends /templates/kinds/table
tr
th(colspan=3)
span(data-i18n="general.results")
| Results
span
|: #{documents.length}
tr
th(data-i18n="general.name") Name
th(data-i18n="general.description") Description
th(data-i18n="general.version") Version
for data in documents
- data = data.attributes;
tr
td
a(href="/editor/level/#{data.slug || data._id}")
| #{data.name}
td.body-row #{data.description}
td #{data.version.major}.#{data.version.minor}

View file

@ -1,17 +1,21 @@
table.table extends /templates/kinds/table
block tableResultsHeader
tr tr
th(colspan=3) th(colspan=4)
span(data-i18n="general.results") span(data-i18n="general.results")
| Results | Results
span span
|: #{documents.length} |: #{documents.length}
block tableHeader
tr tr
th#portrait-col th#portrait-col
th(data-i18n="general.name") Name th(data-i18n="general.name") Name
th(data-i18n="general.description") Description th(data-i18n="general.description") Description
th(data-i18n="general.version") Version th(data-i18n="general.version") Version
block tableBody
for thang in documents for thang in documents
tr tr
td td

View file

@ -1,10 +1,11 @@
table.table table.table
tr block tableResultsHeader
th(colspan=3) tr
span(data-i18n="general.results") th(colspan=3)
| Results span(data-i18n="general.results")
span | Results
|: #{documents.length} span
|: #{documents.length}
block tableHeader block tableHeader
tr tr
@ -13,9 +14,9 @@ table.table
th(data-i18n="general.version") Version th(data-i18n="general.version") Version
block tableBody block tableBody
for data in documents for document in documents
- data = data.attributes; - var data = document.attributes;
tr tr(class=document.getOwner() == me.id ? 'mine' : '')
td td
a(href="/editor/#{page}/#{data.slug || data._id}") a(href="/editor/#{page}/#{data.slug || data._id}")
| #{data.name} | #{data.name}

View file

@ -6,6 +6,7 @@ module.exports = class ArticleSearchView extends SearchView
model: require 'models/Article' model: require 'models/Article'
modelURL: '/db/article' modelURL: '/db/article'
tableTemplate: require 'templates/editor/article/table' tableTemplate: require 'templates/editor/article/table'
page: 'article'
getRenderData: -> getRenderData: ->
context = super() context = super()

View file

@ -6,6 +6,7 @@ module.exports = class LevelSearchView extends SearchView
model: require 'models/Level' model: require 'models/Level'
modelURL: '/db/level' modelURL: '/db/level'
tableTemplate: require 'templates/editor/level/table' tableTemplate: require 'templates/editor/level/table'
page: 'editor'
getRenderData: -> getRenderData: ->
context = super() context = super()

View file

@ -7,6 +7,7 @@ module.exports = class ThangTypeSearchView extends SearchView
modelURL: '/db/thang.type' modelURL: '/db/thang.type'
tableTemplate: require 'templates/editor/thang/table' tableTemplate: require 'templates/editor/thang/table'
projection: ['original', 'name', 'version', 'description', 'slug', 'kind', 'rasterIcon'] projection: ['original', 'name', 'version', 'description', 'slug', 'kind', 'rasterIcon']
page: 'thang'
getRenderData: -> getRenderData: ->
context = super() context = super()

View file

@ -7,11 +7,19 @@ class SearchCollection extends Backbone.Collection
initialize: (modelURL, @model, @term, @projection) -> initialize: (modelURL, @model, @term, @projection) ->
@url = "#{modelURL}?project=" @url = "#{modelURL}?project="
if @projection? and not (@projection == []) if @projection? and not (@projection == [])
@url += projection[0] @url += 'created,permissions'
@url += ',' + projected for projected in projection[1..] @url += ',' + projected for projected in projection
else @url += 'true' else @url += 'true'
@url += "&term=#{term}" if @term @url += "&term=#{term}" if @term
comparator: (a, b) ->
score = 0
score -= 9001900190019001 if a.getOwner() is me.id
score += 9001900190019001 if b.getOwner() is me.id
score -= new Date(a.get 'created')
score -= -(new Date(b.get 'created'))
if score < 0 then -1 else (if score > 0 then 1 else 0)
module.exports = class SearchView extends RootView module.exports = class SearchView extends RootView
template: template template: template
className: 'search-view' className: 'search-view'
@ -67,8 +75,9 @@ module.exports = class SearchView extends RootView
onSearchChange: -> onSearchChange: ->
@hideLoading() @hideLoading()
@collection.sort()
documents = @collection.models documents = @collection.models
table = $(@tableTemplate(documents:documents)) table = $(@tableTemplate(documents: documents, me: me, page: @page))
@$el.find('table').replaceWith(table) @$el.find('table').replaceWith(table)
@$el.find('table').i18n() @$el.find('table').i18n()

View file

@ -207,7 +207,8 @@ module.exports = class LevelHUDView extends CocoView
if @lastResponses if @lastResponses
buttons = $('.enter button') buttons = $('.enter button')
for response, i in @lastResponses for response, i in @lastResponses
f = (r) => => setTimeout((-> Backbone.Mediator.publish(r.channel, r.event or {})), 10) channel = response.channel.replace 'level-set-playing', 'level:set-playing' # Easier than migrating all those victory buttons.
f = (r) => => setTimeout((-> Backbone.Mediator.publish(channel, r.event or {})), 10)
$(buttons[i]).click(f(response)) $(buttons[i]).click(f(response))
else else
$('.enter', @bubble).click(-> Backbone.Mediator.publish('script:end-current-script', {})) $('.enter', @bubble).click(-> Backbone.Mediator.publish('script:end-current-script', {}))
@ -221,7 +222,8 @@ module.exports = class LevelHUDView extends CocoView
# If we decide that always having the last one fire is bad, we should make it smarter. # If we decide that always having the last one fire is bad, we should make it smarter.
return unless @lastResponses?.length return unless @lastResponses?.length
r = @lastResponses[@lastResponses.length - 1] r = @lastResponses[@lastResponses.length - 1]
_.delay (-> Backbone.Mediator.publish(r.channel, r.event or {})), 10 channel = r.channel.replace 'level-set-playing', 'level:set-playing'
_.delay (-> Backbone.Mediator.publish(channel, r.event or {})), 10
onEscapePressed: (e) -> onEscapePressed: (e) ->
@escapePressed = true @escapePressed = true

View file

@ -7,7 +7,7 @@ Patch = require '../patches/Patch'
User = require '../users/User' User = require '../users/User'
sendwithus = require '../sendwithus' sendwithus = require '../sendwithus'
PROJECT = {original: 1, name: 1, version: 1, description: 1, slug: 1, kind: 1} PROJECT = {original: 1, name: 1, version: 1, description: 1, slug: 1, kind: 1, created: 1, permissions: 1}
FETCH_LIMIT = 300 FETCH_LIMIT = 300
module.exports = class Handler module.exports = class Handler