Skip to content

Commit

Permalink
* fixed sidebars for loglist, booking list and report
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Kranz committed Nov 30, 2015
1 parent 349d80b commit 176288d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 34 deletions.
7 changes: 4 additions & 3 deletions app/concerns/tt_query_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ module TtQueryConcern

included do
class_eval do
scope :visible, lambda { |*args|
scope :visible, lambda {|*args|
user = args.shift || User.current
base = Project.allowed_to_condition(user, @visibile_permission, *args)
scope = joins(:project).where("#{table_name}.project_id IS NULL OR (#{base})")
base = Project.allowed_to_condition(user, @visible_permission, *args)
scope = joins("LEFT OUTER JOIN #{Project.table_name} ON #{table_name}.project_id = #{Project.table_name}.id").
where("#{table_name}.project_id IS NULL OR (#{base})")

if user.admin?
scope.where("#{table_name}.visibility <> ? OR #{table_name}.user_id = ?", Query::VISIBILITY_PRIVATE, user.id)
Expand Down
15 changes: 5 additions & 10 deletions app/helpers/report_sidebar_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
module ReportSidebarHelper
def sidebar_queries
unless @sidebar_queries
@sidebar_queries = ReportQuery.visible.all(
:order => "#{Query.table_name}.name ASC",
# Project specific queries and global queries
:conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
)
end
@sidebar_queries
return @sidebar_queries if @sidebar_queries
@sidebar_queries = ReportQuery.visible
@project.nil? ? @sidebar_queries.where(project_id: nil) : @sidebar_queries.where(project_id: [nil, @project.id])
@sidebar_queries.order(name: :asc)
end

end
end
15 changes: 5 additions & 10 deletions app/helpers/time_bookings_sidebar_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
module TimeBookingsSidebarHelper
def sidebar_queries
unless @sidebar_queries
@sidebar_queries = TimeBookingQuery.visible.all(
:order => "#{Query.table_name}.name ASC",
# Project specific queries and global queries
:conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
)
end
@sidebar_queries
return @sidebar_queries if @sidebar_queries
@sidebar_queries = TimeBookingQuery.visible
@project.nil? ? @sidebar_queries.where(project_id: nil) : @sidebar_queries.where(project_id: [nil, @project.id])
@sidebar_queries.order(name: :asc)
end

end
end
14 changes: 5 additions & 9 deletions app/helpers/time_logs_sidebar_helper.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
module TimeLogsSidebarHelper
def sidebar_queries
unless @sidebar_queries
@sidebar_queries = TimeLogQuery.visible.all(
:order => "#{Query.table_name}.name ASC",
# Project specific queries and global queries
:conditions => (@project.nil? ? ["project_id IS NULL"] : ["project_id IS NULL OR project_id = ?", @project.id])
)
end
@sidebar_queries
return @sidebar_queries if @sidebar_queries
@sidebar_queries = TimeLogQuery.visible
@project.nil? ? @sidebar_queries.where(project_id: nil) : @sidebar_queries.where(project_id: [nil, @project.id])
@sidebar_queries.order(name: :asc)
end
end
end
2 changes: 1 addition & 1 deletion app/helpers/time_trackers_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def time_string2hour(str)

def query_from_id
unless params[:query_id].blank?
query = Query.find(params[:query_id], :conditions => "project_id IS NULL")
query = Query.find(params[:query_id])
raise ::Unauthorized unless query.visible?
sess_info = {:filters => query.filters, :group_by => query.group_by, :column_names => query.column_names}
case query.class.name
Expand Down
4 changes: 4 additions & 0 deletions app/views/tt_bookings_list/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,8 @@
<% end %>
<% end %>

<% content_for :sidebar do %>
<%= render_sidebar_queries %>
<% end %>

<%= context_menu tt_bookings_list_context_menu_path %>
4 changes: 4 additions & 0 deletions app/views/tt_logs_list/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,8 @@
<% end %>
<% end %>

<% content_for :sidebar do %>
<%= render_sidebar_queries %>
<% end %>

<%= context_menu tt_logs_list_context_menu_path %>
2 changes: 1 addition & 1 deletion app/views/tt_reporting/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<% end %>

<% content_for :sidebar do %>

<%= render_sidebar_queries %>
<div id="tt_reporting-sidebar">
<h3><%=l(:time_tracker_label_menu_tab_reports)%></h3>
<!--TODO insert statistics here-->
Expand Down

0 comments on commit 176288d

Please sign in to comment.