implement switching grouping

This commit is contained in:
Reinier Balt 2013-07-29 12:23:52 +02:00
parent dbe8060bec
commit d139693632
11 changed files with 107 additions and 56 deletions

View file

@ -23,9 +23,10 @@
// require jquery-ui-1.10.0.custom.min
// require jquery.ui.touch-punch.min
// require jquery.blockUI
// require jquery.cookie
// require jquery.form
// require jquery.jeditable.mini
// require jquery.simulate.drag-sortable
// require jquery.truncator
//= require jquery.cookie
//= require swf_fu

View file

@ -57,8 +57,8 @@ $ ->
Mousetrap.bind 'g s', -> TracksApp.go_starred()
# VIEW
Mousetrap.bind 'v p', -> alert("group by project")
Mousetrap.bind 'v c', -> alert("group by context")
Mousetrap.bind 'v p', -> TracksApp.group_view_by_project()
Mousetrap.bind 'v c', -> TracksApp.group_view_by_context()
# Item Selection
Mousetrap.bind 'j', -> TracksApp.selectNext()

View file

@ -7,6 +7,7 @@ TracksApp =
go_projects: -> TracksApp.goto_page "/projects"
go_starred: -> TracksApp.goto_page "/tag/starred"
# TODO: refactor to work for contexts and projects and tags
go_project: ->
$("input#tracks-goto-project").val("")
$('div#tracks-go-project-dialog').on 'shown', -> $("input#tracks-goto-project").focus()
@ -68,29 +69,42 @@ TracksApp =
unless TracksApp.selectPrevNext(false)?
TracksApp.selectTodo($("div.todo-item").first())
show_note: (node) ->
notes_id = node.attr("data-note-id")
notes_div = $("div#" + notes_id )
notes_div.toggleClass("hide")
todo_item = $(this).parent().parent().parent().parent().parent()
TracksApp.selectTodo(todo_item)
refresh_page: ->
location.reload(true)
group_view_by: (state) ->
$.cookie('group_view_by', state)
group_view_by_context: ->
TracksApp.group_view_by('context')
TracksApp.refresh_page()
group_view_by_project: ->
TracksApp.group_view_by('project')
TracksApp.refresh_page()
# Make TracksApp globally accessible. From http://stackoverflow.com/questions/4214731/coffeescript-global-variables
root = exports ? this
root.TracksApp = TracksApp
$ ->
$("a#menu-keyboard-shotcuts").click -> $('div#tracks-shortcuts-dialog').modal()
$("a.button-add-todo").click -> TracksApp.add_todo()
$("a.button-home").click -> TracksApp.go_home()
$("a.button-goto").click -> TracksApp.go_menu()
$("i.icon-book").click ->
notes_id = $( this ).attr("data-note-id")
notes_div = $("div#" + notes_id )
notes_div.toggleClass("hide")
todo_item = $(this).parent().parent().parent().parent()
TracksApp.selectTodo(todo_item)
$("span.todo-item-description-container").click ->
TracksApp.selectTodo( $(this).parent().parent().parent() )
$("a#menu-keyboard-shotcuts").click -> $('div#tracks-shortcuts-dialog').modal()
$("a.button-add-todo").click -> TracksApp.add_todo()
$("a.button-home").click -> TracksApp.go_home()
$("a.button-goto").click -> TracksApp.go_menu()
$("i.icon-book").click -> TracksApp.show_note( $(this) )
$("span.todo-item-description-container").click -> TracksApp.selectTodo( $(this).parent().parent().parent() )
$('.ajax-typeahead').typeahead
minLength: 3,
minLength: 2,
source: (query, process) ->
typeaheadURL = $(this)[0].$element[0].dataset.link
return $.ajax
@ -101,4 +115,4 @@ $ ->
success: (json) ->
$("input#tracks-json-result").val(json)
map = $.map json, (data, item) -> data.value
return process(map)
return process(map)