mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-22 18:20:12 +01:00
Have a Star option on task entry screens #928
This commit is contained in:
parent
f4a07110ff
commit
c45b11dc70
8 changed files with 29 additions and 17 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
else
|
||||
_remove_tags STARRED_TAG_NAME
|
||||
end
|
||||
starred?
|
||||
starred
|
||||
end
|
||||
|
||||
def from_recurring_todo?
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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 -%>
|
||||
|
|
|
|||
|
|
@ -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() != "")
|
||||
|
|
|
|||
|
|
@ -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;}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue