mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-29 10:35:51 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
8bb6af2c77
13 changed files with 47 additions and 59 deletions
|
@ -212,6 +212,11 @@ class CocoModel extends Backbone.Model
|
|||
|
||||
return false
|
||||
|
||||
getOwner: ->
|
||||
return null unless permissions = @get 'permissions'
|
||||
ownerPermission = _.find permissions, access: 'owner'
|
||||
ownerPermission?.target
|
||||
|
||||
getDelta: ->
|
||||
differ = deltasLib.makeJSONDiffer()
|
||||
differ.diff @_revertAttributes, @attributes
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
overflow: hidden
|
||||
text-overflow: ellipsis
|
||||
|
||||
tr.mine
|
||||
background-color: #f8ecaa
|
||||
|
||||
.loading
|
||||
text-align: center
|
||||
|
||||
|
|
|
@ -233,6 +233,7 @@
|
|||
position: relative
|
||||
height: 100%
|
||||
width: 100%
|
||||
z-index: 1
|
||||
|
||||
.bubble
|
||||
position: absolute
|
||||
|
|
|
@ -1,21 +1 @@
|
|||
table.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}
|
||||
extends /templates/kinds/table
|
||||
|
|
|
@ -1,21 +1 @@
|
|||
table.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}
|
||||
extends /templates/kinds/table
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
table.table
|
||||
extends /templates/kinds/table
|
||||
|
||||
block tableResultsHeader
|
||||
tr
|
||||
th(colspan=3)
|
||||
th(colspan=4)
|
||||
span(data-i18n="general.results")
|
||||
| Results
|
||||
span
|
||||
|: #{documents.length}
|
||||
|
||||
block tableHeader
|
||||
tr
|
||||
th#portrait-col
|
||||
th(data-i18n="general.name") Name
|
||||
th(data-i18n="general.description") Description
|
||||
th(data-i18n="general.version") Version
|
||||
|
||||
block tableBody
|
||||
for thang in documents
|
||||
tr
|
||||
td
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
table.table
|
||||
block tableResultsHeader
|
||||
tr
|
||||
th(colspan=3)
|
||||
span(data-i18n="general.results")
|
||||
|
@ -13,9 +14,9 @@ table.table
|
|||
th(data-i18n="general.version") Version
|
||||
|
||||
block tableBody
|
||||
for data in documents
|
||||
- data = data.attributes;
|
||||
tr
|
||||
for document in documents
|
||||
- var data = document.attributes;
|
||||
tr(class=document.getOwner() == me.id ? 'mine' : '')
|
||||
td
|
||||
a(href="/editor/#{page}/#{data.slug || data._id}")
|
||||
| #{data.name}
|
||||
|
|
|
@ -6,6 +6,7 @@ module.exports = class ArticleSearchView extends SearchView
|
|||
model: require 'models/Article'
|
||||
modelURL: '/db/article'
|
||||
tableTemplate: require 'templates/editor/article/table'
|
||||
page: 'article'
|
||||
|
||||
getRenderData: ->
|
||||
context = super()
|
||||
|
|
|
@ -6,6 +6,7 @@ module.exports = class LevelSearchView extends SearchView
|
|||
model: require 'models/Level'
|
||||
modelURL: '/db/level'
|
||||
tableTemplate: require 'templates/editor/level/table'
|
||||
page: 'editor'
|
||||
|
||||
getRenderData: ->
|
||||
context = super()
|
||||
|
|
|
@ -7,6 +7,7 @@ module.exports = class ThangTypeSearchView extends SearchView
|
|||
modelURL: '/db/thang.type'
|
||||
tableTemplate: require 'templates/editor/thang/table'
|
||||
projection: ['original', 'name', 'version', 'description', 'slug', 'kind', 'rasterIcon']
|
||||
page: 'thang'
|
||||
|
||||
getRenderData: ->
|
||||
context = super()
|
||||
|
|
|
@ -7,11 +7,19 @@ class SearchCollection extends Backbone.Collection
|
|||
initialize: (modelURL, @model, @term, @projection) ->
|
||||
@url = "#{modelURL}?project="
|
||||
if @projection? and not (@projection == [])
|
||||
@url += projection[0]
|
||||
@url += ',' + projected for projected in projection[1..]
|
||||
@url += 'created,permissions'
|
||||
@url += ',' + projected for projected in projection
|
||||
else @url += 'true'
|
||||
@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
|
||||
template: template
|
||||
className: 'search-view'
|
||||
|
@ -67,8 +75,9 @@ module.exports = class SearchView extends RootView
|
|||
|
||||
onSearchChange: ->
|
||||
@hideLoading()
|
||||
@collection.sort()
|
||||
documents = @collection.models
|
||||
table = $(@tableTemplate(documents:documents))
|
||||
table = $(@tableTemplate(documents: documents, me: me, page: @page))
|
||||
@$el.find('table').replaceWith(table)
|
||||
@$el.find('table').i18n()
|
||||
|
||||
|
|
|
@ -207,7 +207,8 @@ module.exports = class LevelHUDView extends CocoView
|
|||
if @lastResponses
|
||||
buttons = $('.enter button')
|
||||
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))
|
||||
else
|
||||
$('.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.
|
||||
return unless @lastResponses?.length
|
||||
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) ->
|
||||
@escapePressed = true
|
||||
|
|
|
@ -7,7 +7,7 @@ Patch = require '../patches/Patch'
|
|||
User = require '../users/User'
|
||||
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
|
||||
|
||||
module.exports = class Handler
|
||||
|
|
Loading…
Reference in a new issue