Skip to content

Commit

Permalink
fix: add JURISDICTIONS depends on country or region
Browse files Browse the repository at this point in the history
  • Loading branch information
yuelongh committed Jan 19, 2024
1 parent cd98a9e commit 9f9019e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions app/presenters/designations_presenter.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
class DesignationsPresenter
include Rails.application.routes.url_helpers

def initialize(geo_entity)
JURISDICTIONSCOUNTRY=['National', 'Regional', 'International','Not Applicable'].freeze
JURISDICTIONSREGION=['National', 'Regional', 'International'].freeze

def initialize(geo_entity, is_regional= false)
@geo_entity = geo_entity
@is_regional = is_regional
@JURISDICTIONS = @is_regional ? JURISDICTIONSREGION : JURISDICTIONSCOUNTRY
end
# All avaliable JURISDICTIONS
JURISDICTIONS = ['National', 'Regional', 'International', 'Not Applicable'].freeze

JURISDICTIONS_TITLE = {
'National' => 'National',
'Regional' => 'Regional',
Expand All @@ -14,7 +19,7 @@ def initialize(geo_entity)
}.freeze

def designations(exclude_oecms: false)
JURISDICTIONS.map do |j|
@JURISDICTIONS.map do |j|
juristiction_count_data = jurisdiction_counts(j, exclude_oecms: exclude_oecms)
{
title: designation_title(j),
Expand Down Expand Up @@ -86,8 +91,12 @@ def get_jurisdictions(jurisdiction)
# https://unep-wcmc.codebasehq.com/projects/protected-planet-support-and-maintenance/tickets/241
# jurisdictions = jurisdiction == 'National' ? ['National', 'Not Applicable'] : jurisdiction

# As 20 DEC 2023 Not Applicable is now showing as a category
# As 20 DEC 2023 Not Applicable is now showing as a category for country page
# https://unep-wcmc.codebasehq.com/projects/protected-planet-support-and-maintenance/tickets/337#update-73110217
Jurisdiction.where(name: jurisdiction)
if @is_regional == true
Jurisdiction.where(name: jurisdiction == 'National' ? ['National', 'Not Applicable'] : jurisdiction)
else
Jurisdiction.where(name: jurisdiction)
end
end
end
2 changes: 1 addition & 1 deletion app/presenters/region_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(region)
@region = region
@countries = @region.countries
@statistics = @countries.map(&:statistic).compact
@designations_presenter = DesignationsPresenter.new(region)
@designations_presenter = DesignationsPresenter.new(region, true)
end

def iucn_categories_chart(chart_input)
Expand Down

0 comments on commit 9f9019e

Please sign in to comment.