mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 07:40:12 +01:00
fix #1157 and fix #1158 by changing the way empty projects are included in the sorting and by fixing the dutch translation for sorting titles
This commit is contained in:
parent
2675be8f4c
commit
0ccf42d08c
3 changed files with 23 additions and 19 deletions
|
|
@ -60,19 +60,23 @@ class User < ActiveRecord::Base
|
|||
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,
|
||||
|
|
|
|||
|
|
@ -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') %> </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"> | </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>
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue