Skip to content

Commit 2764c25

Browse files
committed
CP changes: change date picker
1 parent b9dcdbb commit 2764c25

1 file changed

Lines changed: 28 additions & 28 deletions

File tree

app/views/tpi/companies/show.html.erb

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -251,47 +251,24 @@
251251

252252
<% if @company_presenter.cp_assessments.any? %>
253253
<section id="carbon-performance" class="carbon-performance container">
254+
<% subsector_assessments = @company.company_subsectors.any? ? @company_presenter.cp_assessments.group_by(&:subsector_name) : {} %>
255+
<% active_subsector = @company.company_subsectors.any? ? (params[:subsector_type] || @cp_assessment&.subsector_name || @company.company_subsectors.first.subsector) : nil %>
256+
254257
<div class="management-quality__header">
255258
<h4>
256259
Carbon Performance <%= @company.name %>
257260
</h4>
258261
<p class="is-hidden-desktop"><%= "Carbon Performance alignment of companies in the #{@company.name} sector with the Paris agreement benchmarks." %></p>
259262

260-
<% if @company.company_subsectors.any? %>
261-
<% subsector_assessments = @company_presenter.cp_assessments.group_by(&:subsector_name) %>
262-
<% active_subsector = params[:subsector_type] || @cp_assessment&.subsector_name || @company.company_subsectors.first.subsector %>
263-
<div class="buttons has-addons" style="margin-bottom: 0.5rem;">
264-
<% @company.company_subsectors.each do |cs| %>
265-
<% has_data = subsector_assessments[cs.subsector].present? %>
266-
<% if has_data %>
267-
<% first_assessment_id = subsector_assessments[cs.subsector].first.id %>
268-
<%= link_to cs.subsector, cp_assessment_tpi_company_path(@company, cp_assessment_id: first_assessment_id),
269-
remote: true,
270-
class: "button #{active_subsector == cs.subsector ? 'is-primary' : 'is-secondary'}" %>
271-
<% else %>
272-
<span class="button is-secondary" style="opacity: 0.5; cursor: not-allowed;" title="No data available">
273-
<%= cs.subsector %>
274-
</span>
275-
<% end %>
276-
<% end %>
277-
</div>
278-
<% if @cp_assessment&.subsector_name.present? %>
279-
<p style="font-size: 0.9rem; margin-bottom: 1rem;">
280-
The graph shows the company's pathway and the relevant benchmarks for <%= @cp_assessment.subsector_name.downcase %>.
281-
</p>
282-
<% end %>
283-
<% end %>
284-
285263
<div>
286264
<div class="show-by-dropdown assessment-date__container">
287265
<div class="caption">
288266
Assessment Date:
289267
</div>
290268

291-
<% active_subsector_type = active_subsector if @company.company_subsectors.any? %>
292269
<% cp_dropdown_assessments = @company_presenter.cp_assessments.select do |v|
293-
if active_subsector_type.present?
294-
v.subsector_name == active_subsector_type
270+
if active_subsector.present?
271+
v.subsector_name == active_subsector
295272
else
296273
true
297274
end
@@ -316,6 +293,29 @@
316293
</div>
317294
</div>
318295

296+
<% if @company.company_subsectors.any? %>
297+
<div class="buttons has-addons" style="margin-top: 1rem; margin-bottom: 0.5rem;">
298+
<% @company.company_subsectors.each do |cs| %>
299+
<% has_data = subsector_assessments[cs.subsector].present? %>
300+
<% if has_data %>
301+
<% first_assessment_id = subsector_assessments[cs.subsector].first.id %>
302+
<%= link_to cs.subsector, cp_assessment_tpi_company_path(@company, cp_assessment_id: first_assessment_id),
303+
remote: true,
304+
class: "button #{active_subsector == cs.subsector ? 'is-primary' : 'is-secondary'}" %>
305+
<% else %>
306+
<span class="button is-secondary" style="opacity: 0.5; cursor: not-allowed;" title="No data available">
307+
<%= cs.subsector %>
308+
</span>
309+
<% end %>
310+
<% end %>
311+
</div>
312+
<% if @cp_assessment&.subsector_name.present? %>
313+
<p style="font-size: 0.9rem; margin-bottom: 1rem;">
314+
The graph shows the company's pathway and the relevant benchmarks for <%= @cp_assessment.subsector_name.downcase %>.
315+
</p>
316+
<% end %>
317+
<% end %>
318+
319319
<div id="cp-assessment">
320320
<%= render partial: 'cp_assessment', locals: { assessment: @cp_assessment } %>
321321
</div>

0 commit comments

Comments
 (0)