diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 01b17f02..6494137c 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -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 diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 8688b924..98947bfe 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -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 diff --git a/app/models/todo.rb b/app/models/todo.rb index 382d8588..4904b791 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -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? diff --git a/app/views/todos/_new_todo_form.rhtml b/app/views/todos/_new_todo_form.rhtml index eedca1d8..16beb13a 100644 --- a/app/views/todos/_new_todo_form.rhtml +++ b/app/views/todos/_new_todo_form.rhtml @@ -4,10 +4,12 @@ <% form_for(todo, :html=> { :id=>'todo-form-new-action', :name=>'todo', :class => 'inline-form new_todo_form' }) do |t|%> +
<%= error_messages_for("item", :object_name => 'action') %>
- + + <%= image_tag("blank.png", :title =>t('todos.star_action'), :class => "todo_star", :style=> "float: right")%> <%= t.text_field("description", "size" => 30, "tabindex" => next_tab_index, "maxlength" => 100, "autocomplete" => "off", :autofocus => 1) %> @@ -57,4 +59,4 @@ <% end # form_for -%> - \ No newline at end of file + diff --git a/app/views/todos/create.js.erb b/app/views/todos/create.js.erb index 17373b4f..c7e77133 100644 --- a/app/views/todos/create.js.erb +++ b/app/views/todos/create.js.erb @@ -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 })) : "" %>"; -} \ No newline at end of file +} diff --git a/app/views/todos/toggle_star.js.erb b/app/views/todos/toggle_star.js.erb index 9ec02520..eaf4a2af 100644 --- a/app/views/todos/toggle_star.js.erb +++ b/app/views/todos/toggle_star.js.erb @@ -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 -%> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 45c13712..48b0076a 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -74,6 +74,10 @@ var TracksForm = { $(this).prev().val(''); }); + $("#new_todo_starred_link").click(function() { + $("#new_todo_starred").val($(this).children(".todo_star").toggleClass("starred").hasClass("starred")); + }); + /* submit todo form after entering new todo */ $("button#todo_new_action_submit").live('click', function (ev) { if ($('input#predecessor_input').val() != "") diff --git a/public/stylesheets/standard.css b/public/stylesheets/standard.css index c029ed91..25eaafe0 100644 --- a/public/stylesheets/standard.css +++ b/public/stylesheets/standard.css @@ -79,10 +79,11 @@ a:hover img.edit_item {background-image: url(../images/edit_on.png); background- img.delete_item {background-image: url(../images/delete_off.png); background-repeat: no-repeat; border: none;} a:hover img.delete_item {background-image: url(../images/delete_on.png);background-color: transparent;background-repeat: no-repeat; border: none;} -img.starred_todo {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: 0px 0px;} -a:hover img.starred_todo {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: -16px 0px;} -img.unstarred_todo {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: -32px 0px;} -a:hover img.unstarred_todo {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: -48px 0px;} +a.undecorated_link {background-color:transparent;color:transparent;} +img.todo_star {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: -32px 0px;} +img.todo_star.starred{ background-position: 0px 0px; } +a:hover img.todo_star { background-position: -48px 0px;} +a:hover img.todo_star.starred { background-position: -16px 0px; } a.to_top {background: transparent url(../images/top_off.png) no-repeat;} a.to_top:hover {background: transparent url(../images/top_on.png) no-repeat;}