Skip to content

Commit

Permalink
fix TracksApp#1157 and fix TracksApp#1158 by changing the way empty p…
Browse files Browse the repository at this point in the history
…rojects are included in the sorting and by fixing the dutch translation for sorting titles
  • Loading branch information
lrbalt committed Apr 29, 2011
1 parent 2675be8 commit 0ccf42d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
28 changes: 16 additions & 12 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,23 @@ def alphabetize(scope_conditions = {})
return projects
end
def actionize(user_id, scope_conditions = {})
@state = scope_conditions[:state]
query_state = ""
query_state = "AND project.state = '" + @state +"' "if @state
projects = Project.find_by_sql([
"SELECT project.id, count(todo.id) as p_count " +
"FROM projects as project " +
"LEFT OUTER JOIN todos as todo ON todo.project_id = project.id "+
"WHERE project.user_id = ? AND NOT (todo.state='completed') " +
query_state = scope_conditions[:state] ? "AND projects.state = '#{scope_conditions[:state]}' " : ""
projects_with_active_todos = Project.find_by_sql([
"SELECT projects.id, count(todos.id) as p_count " +
"FROM projects " +
"LEFT OUTER JOIN todos ON todos.project_id = projects.id "+
"WHERE projects.user_id = ? AND " +
"NOT (todos.state='completed' OR todos.state='deferred' OR todos.state='pending') " +
query_state +
" GROUP BY project.id ORDER by p_count DESC",user_id])
self.update_positions(projects.map{ |p| p.id })
projects = find(:all, :conditions => scope_conditions)
return projects
" GROUP BY projects.id ORDER by p_count DESC",user_id])
all_project_ids = Project.find_by_sql([
"SELECT id FROM projects WHERE projects.user_id = ? " + query_state, user_id
])
ids_in_new_positions = projects_with_active_todos.map{|p| p.id}
ids_of_unselected_projects = all_project_ids.map{|p| p.id} - ids_in_new_positions
self.update_positions(ids_in_new_positions + ids_of_unselected_projects)

return find(:all, :conditions => scope_conditions)
end
end
has_many :active_projects,
Expand Down
4 changes: 2 additions & 2 deletions app/views/projects/_project_state_group.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<h2><span id="<%= state %>-projects-count" class="badge"><%= project_state_group.length %></span><%= t('states.'+state+'_plural' )%> <%= t('common.projects') %></h2>
<div class="menu_sort"><span class="sort_separator"><%= t('common.sort.sort') %>&nbsp;</span>
<div class="alpha_sort">
<%= link_to("Alphabetically", alphabetize_projects_path(:state => state),
<%= link_to(t("common.sort.alphabetically"), alphabetize_projects_path(:state => state),
:id => "#{state}_alphabetize_link", :class => "alphabetize_link", :title => t('common.sort.alphabetically_title'), :x_confirm_message => t('common.sort.alphabetically_confirm')) %>
</div><span class="sort_separator">&nbsp;|&nbsp;</span><div class="tasks_sort">
<%= link_to("By number of tasks", actionize_projects_path(:state => state),
<%= link_to(t("common.sort.by_task_count"), actionize_projects_path(:state => state),
:id => "#{state}_actionize_link", :class => "actionize_link", :title => t('common.sort.by_task_count_title'), :x_confirm_message => t('common.sort.by_task_count_title_confirm')) %>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ nl:
drag_handle: SLEEP
sort:
by_task_count_title: Sorteer op aantal acties
by_task_count_title_confirm: Weet u zeker dat u deze projecten alphabetisch wilt sorteren? Dat zal de huidige sorteervolgorde aanpassen.
alphabetically: Alphabetisch
by_task_count_title_confirm: Weet u zeker dat u deze op aantal acties wilt sorteren? Dat zal de huidige sorteervolgorde aanpassen.
alphabetically: Alfabetisch
sort: Sorteer
alphabetically_title: Sorteer projecten alphabetisch
alphabetically_confirm: Weet u zeker dat u deze projecten alphabetisch wilt sorteren? Dat zal de huidige sorteervolgorde aanpassen.
by_task_count: Bij aantal acties
alphabetically_title: Sorteer projecten alfabetisch
alphabetically_confirm: Weet u zeker dat u deze projecten alfabetisch wilt sorteren? Dat zal de huidige sorteervolgorde aanpassen.
by_task_count: Op aantal acties
create: Maken
contexts: Contexten
fourth: Vierde
Expand Down

0 comments on commit 0ccf42d

Please sign in to comment.