Skip to content

Commit

Permalink
Merge pull request #20 from akpaevj/develop
Browse files Browse the repository at this point in the history
Fixed displaying of child projects
  • Loading branch information
akpaevj authored Jun 2, 2021
2 parents ba59361 + ccffb16 commit ca09608
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
18 changes: 8 additions & 10 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def get_projects
data
end

def add_children_ids(id_array, project)
project.children.each do |child_project|
id_array.push(child_project.id)
add_children_ids(id_array, child_project)
end
end

def get_issues(project_id, with_sub_tasks)
id_array = []

Expand All @@ -69,16 +76,7 @@ def get_issues(project_id, with_sub_tasks)
# fill array of children ids
if project_id != -1 && with_sub_tasks
project = Project.find(project_id)
children = nil
loop do
if project.children.any?
children = project.children.first
id_array.push(children.id)
project = children
else
break
end
end
add_children_ids(id_array, project)
end

items = id_array.empty? ? Issue.visible : Issue.visible.where(:projects => {:id => id_array})
Expand Down
4 changes: 2 additions & 2 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
name 'Dashboard'
author "Akpaev E.A."
description "Plugin adds an issues dashboard to the application"
version '1.0.10'
version '1.0.11'
url 'https://github.com/akpaevj/Dashboard'
author_url 'https://github.com/akpaevj'
menu :top_menu, :dashboard, { controller: 'dashboard', action: 'index' }, caption: :top_menu_item_title, first: true
settings :default => {:empty => true}, :partial => 'settings/dashboard_settings'
end
end

0 comments on commit ca09608

Please sign in to comment.