Skip to content

Instantly share code, notes, and snippets.

@brian428
Created August 19, 2012 18:57
Show Gist options
  • Save brian428/3397044 to your computer and use it in GitHub Desktop.
Save brian428/3397044 to your computer and use it in GitHub Desktop.
TodoController.coffee
Ext.define( "ExtCoffeeTodo.controller.TodoController",
extend: "Deft.mvc.ViewController"
requires: [ "ExtCoffeeTodo.store.TodoStore" ]
inject: [ "todoStore" ]
# Handle view events
control:
showCompletedCheckbox:
change: "toggleShowCompleted"
completeColumn:
checkchange: "syncTodoStore"
view:
edit: "syncTodoStore"
addButton:
click: "addNewTodo"
config:
todoStore: null
init: ->
@callParent( arguments )
addNewTodo: ->
newTodo = Ext.create( "ExtCoffeeTodo.model.Todo",
complete: false
)
@getTodoStore().insert( 0, newTodo )
@getView().cellEditing.startEditByPosition(
row: 0
column: 0
)
toggleShowCompleted: ( field, value ) ->
@getTodoStore().showCompleted( value )
syncTodoStore: ->
@getTodoStore().sync()
@getView().getSelectionModel().deselectAll()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment