Have a Star option on task entry screens #928

This commit is contained in:
Demian Gemperli 2011-07-30 18:52:11 +02:00
parent f4a07110ff
commit c45b11dc70
8 changed files with 29 additions and 17 deletions

View file

@ -83,6 +83,8 @@ class TodosController < ApplicationController
@todo.context_id = context.id
end
@todo.starred= params[:new_todo_starred].include? "true"
@todo.add_predecessor_list(predecessor_list)
# Fix for #977 because AASM overrides @state on creation

View file

@ -427,8 +427,7 @@ module TodosHelper
private
def image_tag_for_star(todo)
class_str = todo.starred? ? "starred_todo" : "unstarred_todo"
image_tag("blank.png", :title =>t('todos.star_action'), :class => class_str, :id => "star_img_"+todo.id.to_s)
image_tag("blank.png", :title =>t('todos.star_action'), :class => "todo_star"+(todo.starred? ? " starred":""), :id => "star_img_"+todo.id.to_s)
end
end

View file

@ -248,14 +248,16 @@ class Todo < ActiveRecord::Base
end
def toggle_star!
if starred?
_remove_tags STARRED_TAG_NAME
tags.reload
else
starred=!starred?
end
def starred=(starred)
if starred
_add_tags(STARRED_TAG_NAME)
tags.reload
end
starred?
else
_remove_tags STARRED_TAG_NAME
end
starred
end
def from_recurring_todo?

View file

@ -4,10 +4,12 @@
<% form_for(todo, :html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'inline-form new_todo_form' }) do |t|%>
<input id="default_project_name_id" name="default_project_name" type="hidden" value="<%= h(@initial_project_name)-%>" />
<input id="default_context_name_id" name="default_context_name" type="hidden" value="<%= h(@initial_context_name)-%>" />
<input type="hidden" id="new_todo_starred" name="new_todo_starred" value="false" />
<div id="error_status"><%= error_messages_for("item", :object_name => 'action') %></div>
<label for="todo_description"><%= Todo.human_attribute_name('description') %></label>
<label for="todo_description" style="float:left"><%= Todo.human_attribute_name('description') %></label>
<a href="#" id="new_todo_starred_link" class="undecorated_link" ><%= image_tag("blank.png", :title =>t('todos.star_action'), :class => "todo_star", :style=> "float: right")%></a>
<%= t.text_field("description", "size" => 30, "tabindex" => next_tab_index, "maxlength" => 100, "autocomplete" => "off", :autofocus => 1) %>
<label for="todo_notes"><%= Todo.human_attribute_name('notes') %></label>
@ -57,4 +59,4 @@
</div>
<% end # form_for -%>
</div>
</div>

View file

@ -22,6 +22,8 @@ function clear_form() {
TracksForm.set_project_name('<%=escape_javascript @initial_project_name%>');
TracksForm.set_tag_list('<%=escape_javascript @default_tags%>');
$('#todo-form-new-action input:text:first').focus();
$('#new_todo_starred_link .todo_star').removeClass('starred');
$('#new_todo_starred').val('false');
}
function insert_new_context_with_new_todo() {
@ -64,4 +66,4 @@ function html_for_new_context() {
function html_for_new_todo() {
return "<%= @saved ? escape_javascript(render(:partial => @todo, :locals => { :parent_container_type => parent_container_type, :source_view => @source_view })) : "" %>";
}
}

View file

@ -1,5 +1,5 @@
<%- if @saved -%>
$('div#line_todo_<%= @todo.id %> a.star_item img').toggleClass('starred_todo').toggleClass('unstarred_todo');
$('div#line_todo_<%= @todo.id %> a.star_item img').toggleClass('starred');
<%- else -%>
TracksPages.page_notify('error', '<%= t('todos.error_starring', :description => @todo.description) %>', 8);
<%- end -%>