Adding default IDs to new goals.

This commit is contained in:
Nick Winter 2014-09-02 17:28:40 -07:00
parent 3fd9cb89ef
commit 23516175d4
2 changed files with 9 additions and 3 deletions

View file

@ -15,9 +15,6 @@ module.exports = class AchievementEditView extends RootView
'click #recalculate-button': 'confirmRecalculation'
'click #delete-button': 'confirmDeletion'
subscriptions:
'save-new': 'saveAchievement'
constructor: (options, @achievementID) ->
super options
@achievement = new Achievement(_id: @achievementID)

View file

@ -61,6 +61,15 @@ module.exports = class SettingsTabView extends CocoView
if (terrain = @settingsTreema.data.terrain) isnt @lastTerrain
@lastTerrain = terrain
Backbone.Mediator.publish 'editor:terrain-changed', terrain: terrain
for goal, index in @settingsTreema.data.goals ? []
continue if goal.id
goalIndex = index
goalID = "goal-#{goalIndex}"
goalID = "goal-#{++goalIndex}" while _.find @settingsTreema.get("goals"), id: goalID
@settingsTreema.disableTracking()
@settingsTreema.set "/goals/#{index}/id", goalID
@settingsTreema.set "/goals/#{index}/name", _.string.humanize goalID
@settingsTreema.enableTracking()
onThangsEdited: (e) ->
# Update in-place so existing Treema nodes refer to the same array.