mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-05 16:58:50 +01:00
add submenu to todos
This commit is contained in:
parent
c5884a3f3c
commit
c7aa8ca597
8 changed files with 84 additions and 30 deletions
|
|
@ -6,20 +6,30 @@
|
|||
# go_projects: this.goto_page "/projects"
|
||||
|
||||
TracksApp =
|
||||
currentPosition: 0
|
||||
|
||||
updateCurrentPosition: ->
|
||||
this.currentPosition = 0
|
||||
$("div.todo-item").each ->
|
||||
if $(this).hasClass("selected-item")
|
||||
return false
|
||||
else
|
||||
this.currentPosition++
|
||||
createSubmenu: (todo, itemToAddBefore) ->
|
||||
template_clone = $("div.todo-sub-menu-template").clone()
|
||||
itemToAddBefore.before(template_clone)
|
||||
todo_menu = todo.find("div.todo-sub-menu-template")
|
||||
todo_menu.removeClass("todo-sub-menu-template")
|
||||
todo_menu.addClass("todo-sub-menu")
|
||||
todo_menu.removeClass("hide")
|
||||
|
||||
appendTodoSubMenu: (todo) ->
|
||||
if todo.find("div.todo-sub-menu").length is 0
|
||||
notes_row = todo.find(".todo-notes").parent()
|
||||
submenu = TracksApp.createSubmenu(todo, notes_row)
|
||||
else
|
||||
todo.find("div.todo-sub-menu").removeClass("hide")
|
||||
|
||||
selectTodo: (new_todo) ->
|
||||
$("div.todo-item.selected-item").removeClass("selected-item")
|
||||
selected_item = $("div.todo-item.selected-item")
|
||||
selected_item.find("div.todo-sub-menu").addClass("hide")
|
||||
selected_item.find("span.todo-item-detail").addClass("hide")
|
||||
selected_item.removeClass("selected-item")
|
||||
TracksApp.appendTodoSubMenu(new_todo)
|
||||
new_todo.find("span.todo-item-detail").removeClass("hide")
|
||||
new_todo.addClass("selected-item")
|
||||
TracksApp.updateCurrentPosition()
|
||||
|
||||
selectPrevNext: (go_next) ->
|
||||
current = prev = next = null
|
||||
|
|
@ -66,5 +76,5 @@ $ ->
|
|||
todo_item = $(this).parent().parent().parent().parent()
|
||||
TracksApp.selectTodo(todo_item)
|
||||
|
||||
$("div.todo-item-description-container").click ->
|
||||
$("span.todo-item-description-container").click ->
|
||||
TracksApp.selectTodo( $(this).parent().parent().parent() )
|
||||
|
|
@ -80,12 +80,12 @@ div.todo-item {
|
|||
span.todo-description {
|
||||
margin-right: 10px;
|
||||
}
|
||||
div.todo-item-icons {
|
||||
span.todo-item-icons {
|
||||
display: block;
|
||||
margin-right: 10px;
|
||||
float:left;
|
||||
}
|
||||
div.todo-item-description-container {
|
||||
span.todo-item-description-container {
|
||||
display: inline-block;
|
||||
float:left;
|
||||
}
|
||||
|
|
@ -95,11 +95,24 @@ div.todo-item {
|
|||
padding: 10px;
|
||||
margin: 0px -3px 0px -3px;
|
||||
}
|
||||
div.todo-sub-menu {
|
||||
margin-top: 5px;
|
||||
padding-top: 5px;
|
||||
margin-bottom: 10px;
|
||||
border: 1px solid #EEE;
|
||||
border-width: 1px 0 0 0;
|
||||
}
|
||||
span.todo-item-detail {
|
||||
text-decoration: none;
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
div.selected-item {
|
||||
border: 3px solid #AAA;
|
||||
border-radius: 3px;
|
||||
border: 1.5px solid #AAA;
|
||||
border-radius: 4px;
|
||||
.row {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,6 +125,10 @@ module TodosHelper
|
|||
|
||||
# === helpers for rendering a todo
|
||||
|
||||
def todo_notes(todo)
|
||||
todo.rendered_notes.html_safe
|
||||
end
|
||||
|
||||
def remote_star_icon(todo=@todo)
|
||||
link_to( image_tag_for_star(todo),
|
||||
toggle_star_todo_path(todo),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
</head>
|
||||
<body class="<%= controller.controller_name %>">
|
||||
|
||||
<% cache do -%>
|
||||
<% cache [:navbar] do -%>
|
||||
<%= render partial: "shared/navbar" %>
|
||||
<% end -%>
|
||||
|
||||
|
|
@ -42,11 +42,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<% cache do -%>
|
||||
<% cache [:footer] do -%>
|
||||
<%= render partial: "shared/footer" %>
|
||||
<% # dialogs -%>
|
||||
<%= render partial: "shared/keyboard_shortcuts" %>
|
||||
<%= render partial: "shared/add_new_action" %>
|
||||
<%= render partial: "todos/todo_sub_menu" %>
|
||||
<% end -%>
|
||||
<%
|
||||
# Javascripts
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
<div id="<%=div_id%>" class="todo_items toggle_target">
|
||||
|
||||
<% cache container_name, show_empty_message do %>
|
||||
<%= render partial: "todos/container_empty_message", locals: {
|
||||
container_id: settings[:container_id],
|
||||
container_name: settings[:container_name],
|
||||
show_empty_message: settings[:show_empty_message]} -%>
|
||||
<% cache [settings[:container_name], settings[:show_empty_message]] do %>
|
||||
<%= render partial: "todos/container_empty_message", locals: {
|
||||
container_id: settings[:container_id],
|
||||
container_name: settings[:container_name],
|
||||
show_empty_message: settings[:show_empty_message]} -%>
|
||||
<% end -%>
|
||||
|
||||
<%= render(:partial => "todos/todo", :collection => collection, :locals => settings) %>
|
||||
<%= render(:partial => "todos/todo", :collection => collection, :locals => settings) %>
|
||||
</div>
|
||||
|
|
@ -6,17 +6,23 @@
|
|||
<div id="<%= dom_id(todo) %>" class="todo-item">
|
||||
<div class="row">
|
||||
<div class="span8">
|
||||
<div class="todo-item-icons">
|
||||
<span class="todo-item-icons">
|
||||
<i class="<%= todo.completed? ? "icon-check-sign" : "icon-check-empty"%>"></i>
|
||||
<i class="<%= todo.starred? ? "icon-star" : "icon-star-empty"%>"></i>
|
||||
</div>
|
||||
<div class="todo-item-description-container">
|
||||
</span>
|
||||
<span class="todo-item-description-container">
|
||||
<span class="todo-description"><%= todo.description %></span>
|
||||
<%= content_tag(:i, {class: "icon-refresh"}){} if todo.from_recurring_todo? -%>
|
||||
<%= deferred_due_date(todo) -%>
|
||||
<%= content_tag(:i, {class: "icon-sitemap"}){} if todo.has_pending_successors -%>
|
||||
<%= content_tag(:i, {class: "icon-book", "data-note-id" => dom_id(todo, 'notes')}){} unless todo.notes.blank? %>
|
||||
</div>
|
||||
</span>
|
||||
<span class="todo-item-detail hide"><br/>
|
||||
<p class="small todo-project-and-context"><small>
|
||||
project: <span class="todo-project-name"><%= todo.project.name.blank? ? "none" : todo.project.name %></span>
|
||||
context: <span class="todo-context-name"><%= todo.context.name.blank? ? "none" : todo.context.name %></span>
|
||||
</small></p>
|
||||
</span>
|
||||
</div>
|
||||
<div class="span4 pull-right">
|
||||
<%= date_span(todo) -%>
|
||||
|
|
@ -25,7 +31,7 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div id="<%=dom_id(todo, 'notes')%>" class="todo-notes hide">
|
||||
<%=todo.rendered_notes.html_safe%>
|
||||
<%= todo_notes(todo) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
18
app/views/todos/_todo_sub_menu.html.erb
Normal file
18
app/views/todos/_todo_sub_menu.html.erb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<div class="row todo-sub-menu-template hide">
|
||||
<a class="btn btn-primary btn-mini"><i class="icon-pencil"></i> Edit</a>
|
||||
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-primary btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
<i class="icon-calendar"></i> Defer <span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a>1 day</a></li>
|
||||
<li><a>2 days</a></li>
|
||||
<li><a>3 days</a></li>
|
||||
<li><a>7 days</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<a class="btn btn-primary btn-mini"><i class="icon-magic"></i> Make Project</a>
|
||||
<a class="btn btn-danger btn-mini"><i class="icon-trash"></i> Delete</a>
|
||||
</div>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
<%# Template Dependency: todos/collection -%>
|
||||
<%# Template Dependency: contexts/context -%>
|
||||
<%# Template Dependency: projects/project -%>
|
||||
<% cache("not_done", @not_done_todos.empty?) do -%>
|
||||
<% cache ["not_done", @not_done_todos.empty?] do -%>
|
||||
<%= render partial: "empty_message_container", locals: {:show => @not_done_todos.empty?, :container_name => "not_done"} %>
|
||||
<% end -%>
|
||||
|
||||
|
|
@ -11,4 +11,6 @@
|
|||
<%= show_todos_without_project(@todos_without_project) -%>
|
||||
<% end -%>
|
||||
|
||||
<%= show_done_todos(@done, {:parent_container_type => @group_view_by, :collapsible => true}) unless @done.nil? %>
|
||||
<% cache [@done.first, "home_completed"] do %>
|
||||
<%= show_done_todos(@done, {:parent_container_type => @group_view_by, :collapsible => true}) unless @done.nil? %>
|
||||
<% end %>
|
||||
Loading…
Add table
Add a link
Reference in a new issue