Newly inserted scripts are automatically assigned id

This commit is contained in:
Jayant Jain 2014-07-29 20:33:40 +05:30
parent 632d9a666e
commit f0940308ea

View file

@ -39,6 +39,13 @@ module.exports = class ScriptsTabView extends CocoView
onScriptsChanged: (e) =>
@level.set 'scripts', @scriptsTreema.data
lastAction = @scriptsTreema.trackedActions[@scriptsTreema.trackedActions.length - 1]
if lastAction.action is 'insert' and lastAction.parentPath is '/'
newScript = @scriptsTreema.get lastAction.path
if newScript.id is undefined
@scriptsTreema.set lastAction.path+'/id', 'Script-' + @scriptsTreema.data.length
@scriptTreema.refreshDisplay()
onScriptSelected: (e, selected) =>
selected = if selected.length > 1 then selected[0].getLastSelectedTreema() else selected[0]