mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 22:13:32 -04:00
Some weird bugs I noticed with {me}.
This commit is contained in:
parent
d62f04cf88
commit
0c30ec0c12
5 changed files with 18 additions and 18 deletions
app
lib
models
views/editor/level
|
@ -16,7 +16,7 @@ init = ->
|
|||
module.exports.createUser = (userObject, failure=backboneFailure, nextURL=null) ->
|
||||
user = new User(userObject)
|
||||
user.save({}, {
|
||||
error: (model,jqxhr,options) ->
|
||||
error: (model,jqxhr,options) ->
|
||||
error = parseServerError(jqxhr.responseText)
|
||||
property = error.property if error.property
|
||||
if jqxhr.status is 409 and property is 'name'
|
||||
|
@ -26,12 +26,12 @@ module.exports.createUser = (userObject, failure=backboneFailure, nextURL=null)
|
|||
genericFailure(jqxhr)
|
||||
success: -> if nextURL then window.location.href = nextURL else window.location.reload()
|
||||
})
|
||||
|
||||
|
||||
module.exports.createUserWithoutReload = (userObject, failure=backboneFailure) ->
|
||||
user = new User(userObject)
|
||||
user.save({}, {
|
||||
error: failure
|
||||
success: ->
|
||||
success: ->
|
||||
Backbone.Mediator.publish("created-user-without-reload")
|
||||
})
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ module.exports.CollisionCategory = class CollisionCategory
|
|||
# "ground_and_air_<team>" units don't hit ground or air units on their team (so missiles don't hit same team)
|
||||
sameTeam = @superteamIndex and cat.superteamIndex is @superteamIndex
|
||||
return false if sameTeam and @ground and @air
|
||||
|
||||
|
||||
# actually, "ground_and_air<team>" units don't hit any ground_and_air units (temp missile collision fix)
|
||||
return false if @ground and @air and cat.ground and cat.air
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class CocoModel extends Backbone.Model
|
|||
clone = super()
|
||||
clone.set($.extend(true, {}, if withChanges then @attributes else @_revertAttributes))
|
||||
clone
|
||||
|
||||
|
||||
onError: ->
|
||||
@loading = false
|
||||
|
||||
|
@ -178,7 +178,7 @@ class CocoModel extends Backbone.Model
|
|||
|
||||
watching: ->
|
||||
return me.id in (@get('watchers') or [])
|
||||
|
||||
|
||||
populateI18N: (data, schema, path='') ->
|
||||
# TODO: Better schema/json walking
|
||||
sum = 0
|
||||
|
@ -187,7 +187,7 @@ class CocoModel extends Backbone.Model
|
|||
if schema.properties?.i18n and _.isPlainObject(data) and not data.i18n?
|
||||
data.i18n = {}
|
||||
sum += 1
|
||||
|
||||
|
||||
if _.isPlainObject data
|
||||
for key, value of data
|
||||
numChanged = 0
|
||||
|
@ -195,10 +195,10 @@ class CocoModel extends Backbone.Model
|
|||
if numChanged and not path # should only do this for the root object
|
||||
@set key, value
|
||||
sum += numChanged
|
||||
|
||||
|
||||
if schema.items and _.isArray data
|
||||
sum += @populateI18N(value, schema.items, path+'/'+index) for value, index in data
|
||||
|
||||
|
||||
sum
|
||||
|
||||
@getReferencedModel: (data, schema) ->
|
||||
|
@ -229,13 +229,13 @@ class CocoModel extends Backbone.Model
|
|||
model = new Model()
|
||||
model.url = makeUrlFunc(link)
|
||||
return model
|
||||
|
||||
|
||||
setURL: (url) ->
|
||||
makeURLFunc = (u) -> -> u
|
||||
@url = makeURLFunc(url)
|
||||
@
|
||||
|
||||
|
||||
getURL: ->
|
||||
return if _.isString @url then @url else @url()
|
||||
|
||||
|
||||
module.exports = CocoModel
|
||||
|
|
|
@ -46,12 +46,12 @@ module.exports = class LevelComponentEditView extends View
|
|||
schema = _.cloneDeep LevelComponent.schema
|
||||
schema.properties = _.pick schema.properties, (value, key) => key in @editableSettings
|
||||
schema.required = _.intersection schema.required, @editableSettings
|
||||
|
||||
|
||||
treemaOptions =
|
||||
supermodel: @supermodel
|
||||
schema: schema
|
||||
data: data
|
||||
readonly: @me.get('anonymous')
|
||||
readonly: me.get('anonymous')
|
||||
callbacks: {change: @onComponentSettingsEdited}
|
||||
@componentSettingsTreema = @$el.find('#edit-component-treema').treema treemaOptions
|
||||
@componentSettingsTreema.build()
|
||||
|
@ -69,7 +69,7 @@ module.exports = class LevelComponentEditView extends View
|
|||
supermodel: @supermodel
|
||||
schema: LevelComponent.schema.properties.configSchema
|
||||
data: @levelComponent.get 'configSchema'
|
||||
readonly: @me.get('anonymous')
|
||||
readonly: me.get('anonymous')
|
||||
callbacks: {change: @onConfigSchemaEdited}
|
||||
@configSchemaTreema = @$el.find('#config-schema-treema').treema treemaOptions
|
||||
@configSchemaTreema.build()
|
||||
|
@ -93,7 +93,7 @@ module.exports = class LevelComponentEditView extends View
|
|||
session.setNewLineMode = 'unix'
|
||||
session.setUseSoftTabs true
|
||||
@editor.on('change', @onEditorChange)
|
||||
|
||||
|
||||
onEditorChange: =>
|
||||
@levelComponent.set 'code', @editor.getValue()
|
||||
Backbone.Mediator.publish 'level-component-edited', levelComponent: @levelComponent
|
||||
|
@ -107,7 +107,7 @@ module.exports = class LevelComponentEditView extends View
|
|||
versionHistoryView = new VersionHistoryView {}, @levelComponent.id
|
||||
@openModalView versionHistoryView
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
|
||||
|
||||
startPatchingComponent: (e) ->
|
||||
@openModalView new SaveVersionModal({model:@levelComponent})
|
||||
Backbone.Mediator.publish 'level:view-switched', e
|
||||
|
@ -120,4 +120,3 @@ module.exports = class LevelComponentEditView extends View
|
|||
destroy: ->
|
||||
@editor?.destroy()
|
||||
super()
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ template = require 'templates/editor/level/settings_tab'
|
|||
Level = require 'models/Level'
|
||||
Surface = require 'lib/surface/Surface'
|
||||
nodes = require './treema_nodes'
|
||||
{me} = require 'lib/auth'
|
||||
|
||||
module.exports = class SettingsTabView extends View
|
||||
id: 'editor-level-settings-tab-view'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue