Merge pull request #5786 from consuldemocracy/stats_turbolinks_reload

Include stat graphs JavaScript in all admin stats actions
This commit is contained in:
Javi Martín
2024-11-11 15:46:15 +01:00
committed by GitHub
12 changed files with 23 additions and 9 deletions

View File

@@ -1,3 +1,5 @@
<% include_stat_graphs_javascript %>
<%= back_link_to budgets_admin_stats_path %> <%= back_link_to budgets_admin_stats_path %>
<h2><%= budget.name %> - <%= t("admin.stats.budget_balloting.title") %></h2> <h2><%= budget.name %> - <%= t("admin.stats.budget_balloting.title") %></h2>

View File

@@ -1,5 +1,6 @@
class Admin::Stats::BudgetBallotingComponent < ApplicationComponent class Admin::Stats::BudgetBallotingComponent < ApplicationComponent
attr_reader :budget attr_reader :budget
use_helpers :include_stat_graphs_javascript
def initialize(budget) def initialize(budget)
@budget = budget @budget = budget

View File

@@ -1,6 +1,4 @@
<% content_for :head do %> <% include_stat_graphs_javascript %>
<%= javascript_include_tag "stat_graphs", "data-turbolinks-track" => "reload" %>
<% end %>
<%= back_link_to budgets_admin_stats_path %> <%= back_link_to budgets_admin_stats_path %>

View File

@@ -1,5 +1,6 @@
class Admin::Stats::BudgetSupportingComponent < ApplicationComponent class Admin::Stats::BudgetSupportingComponent < ApplicationComponent
attr_reader :budget attr_reader :budget
use_helpers :include_stat_graphs_javascript
def initialize(budget) def initialize(budget)
@budget = budget @budget = budget

View File

@@ -18,6 +18,12 @@ module ApplicationHelper
WYSIWYGSanitizer.new.sanitize(text) WYSIWYGSanitizer.new.sanitize(text)
end end
def include_stat_graphs_javascript
content_for :head do
javascript_include_tag "stat_graphs", "data-turbolinks-track" => "reload"
end
end
def author_of?(authorable, user) def author_of?(authorable, user)
return false if authorable.blank? || user.blank? return false if authorable.blank? || user.blank?

View File

@@ -1,3 +1,5 @@
<% include_stat_graphs_javascript %>
<%= back_link_to admin_stats_path %> <%= back_link_to admin_stats_path %>
<h2><%= t("admin.stats.budgets.title") %></h2> <h2><%= t("admin.stats.budgets.title") %></h2>

View File

@@ -1,3 +1,5 @@
<% include_stat_graphs_javascript %>
<%= back_link_to admin_stats_path %> <%= back_link_to admin_stats_path %>
<h2><%= t("admin.stats.direct_messages.title") %></h2> <h2><%= t("admin.stats.direct_messages.title") %></h2>

View File

@@ -1,6 +1,4 @@
<% content_for :head do %> <% include_stat_graphs_javascript %>
<%= javascript_include_tag "stat_graphs", "data-turbolinks-track" => "reload" %>
<% end %>
<%= back_link_to admin_stats_path %> <%= back_link_to admin_stats_path %>

View File

@@ -1,3 +1,5 @@
<% include_stat_graphs_javascript %>
<%= back_link_to admin_stats_path %> <%= back_link_to admin_stats_path %>
<h2 id="top"><%= t("admin.stats.polls.title") %></h2> <h2 id="top"><%= t("admin.stats.polls.title") %></h2>

View File

@@ -1,3 +1,5 @@
<% include_stat_graphs_javascript %>
<%= back_link_to admin_stats_path %> <%= back_link_to admin_stats_path %>
<h2><%= t("admin.stats.proposal_notifications.title") %></h2> <h2><%= t("admin.stats.proposal_notifications.title") %></h2>

View File

@@ -1 +1,3 @@
<% include_stat_graphs_javascript %>
<%= render Admin::Stats::SDGComponent.new(@goals) %> <%= render Admin::Stats::SDGComponent.new(@goals) %>

View File

@@ -1,6 +1,4 @@
<% content_for :head do %> <% include_stat_graphs_javascript %>
<%= javascript_include_tag "stat_graphs", "data-turbolinks-track" => "reload" %>
<% end %>
<div id="stats" class="stats"> <div id="stats" class="stats">
<div class="row"> <div class="row">