diff --git a/app/admin/ascor/assessments.rb b/app/admin/ascor/assessments.rb index 6a58f9170..0a6ed560f 100644 --- a/app/admin/ascor/assessments.rb +++ b/app/admin/ascor/assessments.rb @@ -35,7 +35,7 @@ end panel 'Assessment Results' do - table_for resource.results.includes(:indicator).order(:id) do + table_for resource.results.includes(:indicator).order(:indicator_id) do column(:indicator) column(:answer) column(:source) diff --git a/app/assets/stylesheets/tpi/pages/ascor.scss b/app/assets/stylesheets/tpi/pages/ascor.scss index 18f69dbd1..fb904bc17 100644 --- a/app/assets/stylesheets/tpi/pages/ascor.scss +++ b/app/assets/stylesheets/tpi/pages/ascor.scss @@ -321,17 +321,34 @@ $see-more-width-tablet: 130px; &__indicator { margin-bottom: 1px; + outline: solid 1px $grey-lighter-medium; + margin-left: 40px; + padding: 15px 45px 15px 20px; + display: flex; &__title { - outline: solid 1px $grey-lighter-medium; font-family: $family-sans-serif; font-weight: 700; font-size: 16px; - margin-left: 40px; - padding: 15px 20px; display: flex; align-items: center; gap: 25px; + flex-grow: 2; + } + + &__source { + font-family: $family-sans-serif; + font-size: 14px !important; + line-height: 40px; + + a { + color: $grey-dark; + text-decoration: underline; + } + + a:hover { + color: $dark; + } } } diff --git a/app/controllers/tpi/ascor_controller.rb b/app/controllers/tpi/ascor_controller.rb index 004b710ac..992f2b864 100644 --- a/app/controllers/tpi/ascor_controller.rb +++ b/app/controllers/tpi/ascor_controller.rb @@ -19,6 +19,7 @@ def index def show @assessment = ASCOR::Assessment.find_by country: @country, assessment_date: @assessment_date + @recent_emissions = Api::ASCOR::RecentEmissions.new(@assessment_date, @country).call fixed_navbar("ASCOR Country #{@country.name}", admin_ascor_country_path(@country.id)) end diff --git a/app/javascript/components/tpi/AscorRecentEmissions.js b/app/javascript/components/tpi/AscorRecentEmissions.js new file mode 100644 index 000000000..61cca5c8a --- /dev/null +++ b/app/javascript/components/tpi/AscorRecentEmissions.js @@ -0,0 +1,35 @@ +import PropTypes from 'prop-types'; + +// eslint-disable-next-line no-empty-pattern +const AscorRecentEmissions = ({ }) => { + +}; + +AscorRecentEmissions.propTypes = { + emissions_metric_filter: PropTypes.arrayOf(PropTypes.string).isRequired, + default_emissions_metric_filter: PropTypes.string.isRequired, + emissions_boundary_filter: PropTypes.arrayOf(PropTypes.string).isRequired, + default_emissions_boundary_filter: PropTypes.string.isRequired, + trend_filters: PropTypes.arrayOf(PropTypes.string).isRequired, + default_trend_filter: PropTypes.string.isRequired, + data: PropTypes.arrayOf( + PropTypes.shape({ + value: PropTypes.number, + source: PropTypes.string, + year: PropTypes.number, + unit: PropTypes.string.isRequired, + trends: PropTypes.shape({ + source: PropTypes.string, + year: PropTypes.number, + values: PropTypes.arrayOf( + PropTypes.shape({ + filter: PropTypes.string.isRequired, + value: PropTypes.string.isRequired + }) + ).isRequired + }).isRequired + }) + ).isRequired +}; + +export default AscorRecentEmissions; diff --git a/app/services/api/ascor/recent_emissions.rb b/app/services/api/ascor/recent_emissions.rb new file mode 100644 index 000000000..fc6a60ba0 --- /dev/null +++ b/app/services/api/ascor/recent_emissions.rb @@ -0,0 +1,40 @@ +module Api + module ASCOR + class RecentEmissions + attr_accessor :assessment_date, :country + + def initialize(assessment_date, country) + @assessment_date = assessment_date + @country = country + end + + def call + pathways.map do |pathway| + { + value: pathway.recent_emission_level, + source: pathway.recent_emission_source, + year: pathway.recent_emission_year, + emissions_metric: pathway.emissions_metric, + emissions_boundary: pathway.emissions_boundary, + unit: pathway.units, + trend: { + source: pathway.trend_source, + year: pathway.trend_year, + values: [ + {filter: '1 year trend', value: pathway.trend_1_year}, + {filter: '3 years trend', value: pathway.trend_3_year}, + {filter: '5 years trend', value: pathway.trend_5_year} + ] + } + } + end + end + + private + + def pathways + @pathways ||= ::ASCOR::Pathway.where(assessment_date: assessment_date, country: country) + end + end + end +end diff --git a/app/views/tpi/ascor/_assessment.html.erb b/app/views/tpi/ascor/_assessment.html.erb index fa65af0c3..8e3402dff 100644 --- a/app/views/tpi/ascor/_assessment.html.erb +++ b/app/views/tpi/ascor/_assessment.html.erb @@ -22,31 +22,38 @@