New models with default tasks are preintialized with these tasks.

This commit is contained in:
Josh Callebaut 2016-01-20 10:48:53 -08:00
parent ad28be1c64
commit 80c2a9e539
2 changed files with 4 additions and 0 deletions
app
schemas/models
views/editor/modal

View file

@ -254,6 +254,7 @@ LevelSchema = c.object {
'default':
name: 'Ineffable Wizardry'
description: 'This level is indescribably flarmy.'
tasks: (name: t, complete: false for t in defaultTasks)
documentation: {}
scripts: []
thangs: []

View file

@ -12,6 +12,7 @@ module.exports = class NewModelModal extends ModalView
'submit form': 'onModelSubmitted'
constructor: (options) ->
console.log options.model.schema
super options
@modelClass = options.model
@modelLabel = options.modelLabel
@ -22,6 +23,8 @@ module.exports = class NewModelModal extends ModalView
model = new @modelClass
name = @$el.find('#name').val()
model.set('name', name)
if @modelClass.schema.default?
model.set('tasks', @modelClass.schema.default.tasks)
if model.schema().properties.permissions
model.set 'permissions', [{access: 'owner', target: me.id}]
model.set(key, prop) for key, prop of @properties if @properties?