mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-04 09:53:55 -04:00
Merge pull request #1398 from jayant1992/master
Updates for script tab in level editor
This commit is contained in:
commit
2ebc7f5aa6
1 changed files with 24 additions and 1 deletions
|
@ -39,7 +39,23 @@ module.exports = class ScriptsTabView extends CocoView
|
||||||
|
|
||||||
onScriptsChanged: (e) =>
|
onScriptsChanged: (e) =>
|
||||||
@level.set 'scripts', @scriptsTreema.data
|
@level.set 'scripts', @scriptsTreema.data
|
||||||
|
lastAction = @scriptsTreema.trackedActions[@scriptsTreema.trackedActions.length - 1]
|
||||||
|
return unless lastAction
|
||||||
|
|
||||||
|
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()
|
||||||
|
|
||||||
|
if lastAction.action is 'delete' and lastAction.parentPath[0] is '/'
|
||||||
|
for key, treema of @scriptsTreema.childrenTreemas
|
||||||
|
key = parseInt(key)
|
||||||
|
if /Script-[0-9]*/.test treema.data.id
|
||||||
|
existingKey = parseInt(treema.data.id.substr(7))
|
||||||
|
if existingKey isnt key+1
|
||||||
|
treema.set 'id', 'Script-' + (key+1)
|
||||||
|
|
||||||
onScriptSelected: (e, selected) =>
|
onScriptSelected: (e, selected) =>
|
||||||
selected = if selected.length > 1 then selected[0].getLastSelectedTreema() else selected[0]
|
selected = if selected.length > 1 then selected[0].getLastSelectedTreema() else selected[0]
|
||||||
unless selected
|
unless selected
|
||||||
|
@ -124,7 +140,14 @@ class EventPropsNode extends TreemaNode.nodeMap.string
|
||||||
joined = '(unset)' if not joined.length
|
joined = '(unset)' if not joined.length
|
||||||
@buildValueForDisplaySimply valEl, joined
|
@buildValueForDisplaySimply valEl, joined
|
||||||
|
|
||||||
buildValueForEditing: (valEl) -> @buildValueForEditingSimply(valEl, @arrayToString())
|
buildValueForEditing: (valEl) ->
|
||||||
|
super(valEl)
|
||||||
|
channel = @getRoot().data.channel
|
||||||
|
channelSchema = Backbone.Mediator.channelSchemas[channel]
|
||||||
|
autocompleteValues = []
|
||||||
|
autocompleteValues.push key for key, val of channelSchema?.properties
|
||||||
|
valEl.find('input').autocomplete(source: autocompleteValues, minLength: 0, delay: 0, autoFocus: true).autocomplete('search')
|
||||||
|
valEl
|
||||||
|
|
||||||
saveChanges: (valEl) ->
|
saveChanges: (valEl) ->
|
||||||
@data = (s for s in $('input', valEl).val().split('.') when s.length)
|
@data = (s for s in $('input', valEl).val().split('.') when s.length)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue