Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Subproject News Option #164

Open
defsdoor opened this issue Mar 28, 2023 · 1 comment
Open

Include Subproject News Option #164

defsdoor opened this issue Mar 28, 2023 · 1 comment

Comments

@defsdoor
Copy link

Hi

I'd find it really useful to have the option to include news articles on a dashboard for the current project and all sub-projects.

I might have a go at doing this myself - would this be a useful feature worth including ?

Cheers

@defsdoor
Copy link
Author

Not sure if this is nice or optimal as I don't know the Redmine code very well and obviously this should be configurable -

diff --git a/app/helpers/dashboards_helper.rb b/app/helpers/dashboards_helper.rb
index d2cf89a6..63e17b36 100644
--- a/app/helpers/dashboards_helper.rb
+++ b/app/helpers/dashboards_helper.rb
@@ -344,8 +344,10 @@ module DashboardsHelper
     news = if dashboard.content_project.nil?
              News.latest User.current, max_entries
            else
-             dashboard.content_project
-                      .news
+             project_ids = [dashboard.content_project.id] +
+                           dashboard.content_project.descendants.where.not(status: Project::STATUS_ARCHIVED).ids
+             @subproject_ids = project_ids & User.current.memberships.collect(&:project_id)
+             News.where(project_id: @subproject_ids)
                       .limit(max_entries)
                       .includes(:author, :project)
                       .reorder(created_on: :desc)
diff --git a/app/views/dashboards/blocks/_news.html.slim b/app/views/dashboards/blocks/_news.html.slim
index 93d87f85..8f942876 100644
--- a/app/views/dashboards/blocks/_news.html.slim
+++ b/app/views/dashboards/blocks/_news.html.slim
@@ -15,7 +15,10 @@ h3.icon.icon-news = l :label_news_latest
         = link_to_function l(:button_cancel), "$('##{block}-settings').toggle()"
 
 - if news.any?
+  - saved_project = @project
+  - @project = nil if @subproject_ids && @subproject_ids.size > 1
   = render partial: 'news/news', collection: news
+  - @project = saved_project
   p
     - if @project
       = link_to l(:label_news_view_all), project_news_index_path(@project)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants