Undo redo descriptions for settings tab view

This commit is contained in:
Jayant Jain 2014-08-13 02:55:05 +05:30
parent d713c35db7
commit 67ed28e034

View file

@ -39,6 +39,7 @@ module.exports = class SettingsTabView extends CocoView
callbacks: {change: @onSettingsChanged}
thangIDs: thangIDs
nodeClasses:
object: SettingsNode
thang: nodes.ThangNode
@settingsTreema = @$el.find('#settings-treema').treema treemaOptions
@ -59,3 +60,39 @@ module.exports = class SettingsTabView extends CocoView
redo: ->
@settingsTreema.redo()
showUndoDescription: ->
titleText = $('#undo-button').attr('title', 'Undo ' + @settingsTreema.getUndoDescription() + ' (Ctrl+Z)')
showRedoDescription: ->
titleText = $('#redo-button').attr('title', 'Redo ' + @settingsTreema.getRedoDescription() + ' (Ctrl+Shift+Z)')
class SettingsNode extends TreemaObjectNode
getUndoDescription: ->
return '' unless @canUndo()
trackedActions = @getTrackedActions()
currentStateIndex = @getCurrentStateIndex()
return @getTrackedActionDescription( trackedActions[currentStateIndex - 1] )
getRedoDescription: ->
return '' unless @canRedo()
trackedActions = @getTrackedActions()
currentStateIndex = @getCurrentStateIndex()
return @getTrackedActionDescription trackedActions[currentStateIndex]
getTrackedActionDescription: (trackedAction) ->
switch trackedAction.action
when 'insert'
trackedActionDescription = 'Add New Setting'
when 'delete'
trackedActionDescription = 'Delete Setting'
when 'edit'
path = trackedAction.path.split '/'
trackedActionDescription = 'Edit Setting'
else
trackedActionDescription = ''
trackedActionDescription