diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index d8425c217..ea2a327f7 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -105,4 +105,18 @@ module BudgetsHelper ends_at: balloting_phase.ends_at }), method: :post end + + def budget_subnav_items_for(budget) + { + results: t("budgets.results.link"), + stats: t("stats.budgets.link"), + executions: t("budgets.executions.link") + }.select { |section, _| can?(:"read_#{section}", budget) }.map do |section, text| + { + text: text, + url: send("budget_#{section}_path", budget), + active: controller_name == section.to_s + } + end + end end diff --git a/app/views/budgets/_finished.html.erb b/app/views/budgets/_finished.html.erb new file mode 100644 index 000000000..60b715917 --- /dev/null +++ b/app/views/budgets/_finished.html.erb @@ -0,0 +1,35 @@ +
+
+

<%= t("budgets.index.finished_budgets") %>

+ +
+ <% budgets.each do |budget| %> +
+
+
+
+
+

<%= budget.name %>

+
+
+ +
+
+ <% if can?(:read_results, budget) %> + <%= link_to t("budgets.index.see_results"), + budget_results_path(budget), + class: "button" %> + <% end %> + + <%= link_to t("budgets.index.milestones"), + budget_executions_path(budget), + class: "button" %> +
+
+
+
+
+ <% end %> +
+
+
diff --git a/app/views/budgets/_subnav.html.erb b/app/views/budgets/_subnav.html.erb new file mode 100644 index 000000000..f5f960377 --- /dev/null +++ b/app/views/budgets/_subnav.html.erb @@ -0,0 +1,17 @@ +
+
+ +
+
diff --git a/app/views/budgets/executions/show.html.erb b/app/views/budgets/executions/show.html.erb index a0e3324bc..acab50de4 100644 --- a/app/views/budgets/executions/show.html.erb +++ b/app/views/budgets/executions/show.html.erb @@ -25,21 +25,7 @@ -
-
- -
-
+<%= render "budgets/subnav", budget: @budget %>
diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index 9e198156f..5a7dde0ba 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -53,7 +53,7 @@ <% end %> <% end %> - <% if current_budget.finished? %> + <% if can?(:read_results, current_budget) %> <%= link_to t("budgets.show.see_results"), budget_results_path(current_budget, heading_id: current_budget.headings.first), class: "button margin-top expanded" %> @@ -126,38 +126,7 @@
<% if @finished_budgets.present? %> -
-
-

<%= t("budgets.index.finished_budgets") %>

- -
- <% @finished_budgets.each do |budget| %> -
-
-
-
-
-

<%= budget.name %>

-
-
- -
-
- <%= link_to t("budgets.index.see_results"), - budget_results_path(budget.id), - class: "button" %> - <%= link_to t("budgets.index.milestones"), - budget_executions_path(budget.id), - class: "button" %> -
-
-
-
-
- <% end %> -
-
-
+ <%= render "finished", budgets: @finished_budgets %> <% end %>
<% else %> diff --git a/app/views/budgets/results/show.html.erb b/app/views/budgets/results/show.html.erb index d77f50b77..6a8829437 100644 --- a/app/views/budgets/results/show.html.erb +++ b/app/views/budgets/results/show.html.erb @@ -24,22 +24,7 @@ -
-
- -
-
+<%= render "budgets/subnav", budget: @budget %>
diff --git a/app/views/budgets/show.html.erb b/app/views/budgets/show.html.erb index 89e4e146c..26af33856 100644 --- a/app/views/budgets/show.html.erb +++ b/app/views/budgets/show.html.erb @@ -36,7 +36,7 @@ <% end %> <% end %> - <% if @budget.finished? %> + <% if can?(:read_results, @budget) %> <%= link_to t("budgets.show.see_results"), budget_results_path(@budget), class: "button margin-top expanded" %> diff --git a/app/views/budgets/stats/show.html.erb b/app/views/budgets/stats/show.html.erb index bbbfda4bb..60697135d 100644 --- a/app/views/budgets/stats/show.html.erb +++ b/app/views/budgets/stats/show.html.erb @@ -21,22 +21,7 @@
-
-
- -
-
+ <%= render "budgets/subnav", budget: @budget %>