mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Fix populate i18n to also populate thang component configs
This commit is contained in:
parent
803fc39998
commit
e9c7edb6be
2 changed files with 21 additions and 1 deletions
|
@ -309,6 +309,8 @@ class CocoModel extends Backbone.Model
|
|||
sum = 0
|
||||
data ?= $.extend true, {}, @attributes
|
||||
schema ?= @schema() or {}
|
||||
if schema.oneOf # get populating the Programmable component config to work
|
||||
schema = _.find(schema.oneOf, {type: 'object'})
|
||||
addedI18N = false
|
||||
if schema.properties?.i18n and _.isPlainObject(data) and not data.i18n?
|
||||
data.i18n = {'-':{'-':'-'}} # mongoose doesn't work with empty objects
|
||||
|
@ -318,7 +320,11 @@ class CocoModel extends Backbone.Model
|
|||
if _.isPlainObject data
|
||||
for key, value of data
|
||||
numChanged = 0
|
||||
numChanged = @populateI18N(value, childSchema, path+'/'+key) if childSchema = schema.properties?[key]
|
||||
childSchema = schema.properties?[key]
|
||||
if not childSchema and _.isObject(schema.additionalProperties)
|
||||
childSchema = schema.additionalProperties
|
||||
if childSchema
|
||||
numChanged = @populateI18N(value, childSchema, path+'/'+key)
|
||||
if numChanged and not path # should only do this for the root object
|
||||
@set key, value
|
||||
sum += numChanged
|
||||
|
|
|
@ -2,6 +2,7 @@ RootView = require 'views/core/RootView'
|
|||
template = require 'templates/editor/level/edit'
|
||||
Level = require 'models/Level'
|
||||
LevelSystem = require 'models/LevelSystem'
|
||||
LevelComponent = require 'models/LevelComponent'
|
||||
World = require 'lib/world/world'
|
||||
DocumentFiles = require 'collections/DocumentFiles'
|
||||
LevelLoader = require 'lib/LevelLoader'
|
||||
|
@ -217,6 +218,19 @@ module.exports = class LevelEditView extends RootView
|
|||
|
||||
onPopulateI18N: ->
|
||||
@level.populateI18N()
|
||||
|
||||
levelComponentMap = _(currentView.supermodel.getModels(LevelComponent))
|
||||
.map((c) -> [c.get('original'), c])
|
||||
.object()
|
||||
.value()
|
||||
|
||||
for thang, thangIndex in @level.get('thangs')
|
||||
for thangComponent, thangComponentIndex in thang.components
|
||||
component = levelComponentMap[thangComponent.original]
|
||||
configSchema = component.get('configSchema')
|
||||
path = "/thangs/#{thangIndex}/components/#{thangComponentIndex}/config"
|
||||
@level.populateI18N(thangComponent.config, configSchema, path)
|
||||
|
||||
f = -> document.location.reload()
|
||||
setTimeout(f, 2000)
|
||||
|
||||
|
|
Loading…
Reference in a new issue