mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-22 10:10: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
|
@todo.context_id = context.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@todo.starred= params[:new_todo_starred].include? "true"
|
||||||
|
|
||||||
@todo.add_predecessor_list(predecessor_list)
|
@todo.add_predecessor_list(predecessor_list)
|
||||||
|
|
||||||
# Fix for #977 because AASM overrides @state on creation
|
# Fix for #977 because AASM overrides @state on creation
|
||||||
|
|
|
||||||
|
|
@ -427,8 +427,7 @@ module TodosHelper
|
||||||
private
|
private
|
||||||
|
|
||||||
def image_tag_for_star(todo)
|
def image_tag_for_star(todo)
|
||||||
class_str = todo.starred? ? "starred_todo" : "unstarred_todo"
|
image_tag("blank.png", :title =>t('todos.star_action'), :class => "todo_star"+(todo.starred? ? " starred":""), :id => "star_img_"+todo.id.to_s)
|
||||||
image_tag("blank.png", :title =>t('todos.star_action'), :class => class_str, :id => "star_img_"+todo.id.to_s)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -248,14 +248,16 @@ class Todo < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def toggle_star!
|
def toggle_star!
|
||||||
if starred?
|
starred=!starred?
|
||||||
_remove_tags STARRED_TAG_NAME
|
end
|
||||||
tags.reload
|
|
||||||
else
|
def starred=(starred)
|
||||||
|
if starred
|
||||||
_add_tags(STARRED_TAG_NAME)
|
_add_tags(STARRED_TAG_NAME)
|
||||||
tags.reload
|
else
|
||||||
end
|
_remove_tags STARRED_TAG_NAME
|
||||||
starred?
|
end
|
||||||
|
starred
|
||||||
end
|
end
|
||||||
|
|
||||||
def from_recurring_todo?
|
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|%>
|
<% 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_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 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>
|
<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) %>
|
<%= 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>
|
<label for="todo_notes"><%= Todo.human_attribute_name('notes') %></label>
|
||||||
|
|
@ -57,4 +59,4 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% end # form_for -%>
|
<% end # form_for -%>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ function clear_form() {
|
||||||
TracksForm.set_project_name('<%=escape_javascript @initial_project_name%>');
|
TracksForm.set_project_name('<%=escape_javascript @initial_project_name%>');
|
||||||
TracksForm.set_tag_list('<%=escape_javascript @default_tags%>');
|
TracksForm.set_tag_list('<%=escape_javascript @default_tags%>');
|
||||||
$('#todo-form-new-action input:text:first').focus();
|
$('#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() {
|
function insert_new_context_with_new_todo() {
|
||||||
|
|
@ -64,4 +66,4 @@ function html_for_new_context() {
|
||||||
|
|
||||||
function html_for_new_todo() {
|
function html_for_new_todo() {
|
||||||
return "<%= @saved ? escape_javascript(render(:partial => @todo, :locals => { :parent_container_type => parent_container_type, :source_view => @source_view })) : "" %>";
|
return "<%= @saved ? escape_javascript(render(:partial => @todo, :locals => { :parent_container_type => parent_container_type, :source_view => @source_view })) : "" %>";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<%- if @saved -%>
|
<%- 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 -%>
|
<%- else -%>
|
||||||
TracksPages.page_notify('error', '<%= t('todos.error_starring', :description => @todo.description) %>', 8);
|
TracksPages.page_notify('error', '<%= t('todos.error_starring', :description => @todo.description) %>', 8);
|
||||||
<%- end -%>
|
<%- end -%>
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,10 @@ var TracksForm = {
|
||||||
$(this).prev().val('');
|
$(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 */
|
/* submit todo form after entering new todo */
|
||||||
$("button#todo_new_action_submit").live('click', function (ev) {
|
$("button#todo_new_action_submit").live('click', function (ev) {
|
||||||
if ($('input#predecessor_input').val() != "")
|
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;}
|
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;}
|
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.undecorated_link {background-color:transparent;color:transparent;}
|
||||||
a:hover img.starred_todo {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: -16px 0px;}
|
img.todo_star {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: -32px 0px;}
|
||||||
img.unstarred_todo {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.unstarred_todo {background-image: url(../images/staricons.png); background-repeat: no-repeat; border:none; background-position: -48px 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 {background: transparent url(../images/top_off.png) no-repeat;}
|
||||||
a.to_top:hover {background: transparent url(../images/top_on.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