diff --git a/Gemfile b/Gemfile index 2b3a5d1a5..724cf68ba 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ gem 'rails', '5.2.0' gem 'webpacker', '~> 4.0.2' #gem 'wcmc-components', path: "../web-components/gems/wcmc_components" -gem 'wcmc-components', '~>0.0.3' +gem 'wcmc-components', '~>0.0.4' gem 'bourbon' diff --git a/Gemfile.lock b/Gemfile.lock index 28698c94e..1010793be 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1365,7 +1365,7 @@ DEPENDENCIES turnout (~> 2.5.0) uglifier (~> 4.1.17) vuejs-rails (~> 2.3.2) - wcmc-components (~> 0.0.3) + wcmc-components (~> 0.0.4) webmock (~> 1.22.0) webpacker (~> 4.0.2) whenever diff --git a/app/controllers/pame_controller.rb b/app/controllers/pame_controller.rb index edadd5347..4dbe261a0 100644 --- a/app/controllers/pame_controller.rb +++ b/app/controllers/pame_controller.rb @@ -1,4 +1,32 @@ class PameController < ApplicationController + DEFAULT_PARAMS = + { + requested_page: 1, + filters: [] + }.to_json + + # Format for this date is: Month and Year (4 digits) + UPDATED_AT = "July 2019".freeze + def index + @table_attributes = PameEvaluation::TABLE_ATTRIBUTES.to_json + @filters = PameEvaluation.filters_to_json + @sources = PameEvaluation.sources_to_json + @json = PameEvaluation.paginate_evaluations(DEFAULT_PARAMS).to_json + @updated_at = UPDATED_AT end -end \ No newline at end of file + + def list + @evaluations = PameEvaluation.paginate_evaluations(params.to_json) + + render json: @evaluations + end + + def download + send_data PameEvaluation.to_csv(params.to_json), { + type: "text/csv; charset=utf-8; header=present", + disposition: "attachment", + filename: "protectedplanet-pame.csv" } + end +end + diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 40642f7b8..162bb6f9e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,3 +1,4 @@ +# coding: utf-8 module ApplicationHelper include BemHelper diff --git a/app/javascript/components/FilteredTable.vue b/app/javascript/components/FilteredTable.vue new file mode 100644 index 000000000..3dadb321e --- /dev/null +++ b/app/javascript/components/FilteredTable.vue @@ -0,0 +1,90 @@ + + + diff --git a/app/javascript/components/forms/DownloadCsv.vue b/app/javascript/components/forms/DownloadCsv.vue new file mode 100644 index 000000000..deb2a6061 --- /dev/null +++ b/app/javascript/components/forms/DownloadCsv.vue @@ -0,0 +1,99 @@ + + + diff --git a/app/javascript/components/pagination/PamePagination.vue b/app/javascript/components/pagination/PamePagination.vue new file mode 100644 index 000000000..bd7a0bd80 --- /dev/null +++ b/app/javascript/components/pagination/PamePagination.vue @@ -0,0 +1,106 @@ + + + diff --git a/app/javascript/components/pame-filters/DataFilter.vue b/app/javascript/components/pame-filters/DataFilter.vue new file mode 100644 index 000000000..96acb2013 --- /dev/null +++ b/app/javascript/components/pame-filters/DataFilter.vue @@ -0,0 +1,139 @@ + + + diff --git a/app/javascript/components/pame-filters/DataFilterOption.vue b/app/javascript/components/pame-filters/DataFilterOption.vue new file mode 100644 index 000000000..c8faf7c99 --- /dev/null +++ b/app/javascript/components/pame-filters/DataFilterOption.vue @@ -0,0 +1,38 @@ + + + diff --git a/app/javascript/components/pame-filters/Filters.vue b/app/javascript/components/pame-filters/Filters.vue new file mode 100644 index 000000000..062451359 --- /dev/null +++ b/app/javascript/components/pame-filters/Filters.vue @@ -0,0 +1,76 @@ + + + diff --git a/app/javascript/components/pame-filters/SelectedFilter.vue b/app/javascript/components/pame-filters/SelectedFilter.vue new file mode 100644 index 000000000..6fb94481e --- /dev/null +++ b/app/javascript/components/pame-filters/SelectedFilter.vue @@ -0,0 +1,36 @@ + + + diff --git a/app/javascript/components/table/PameTableHead.vue b/app/javascript/components/table/PameTableHead.vue new file mode 100644 index 000000000..bb6b92ff2 --- /dev/null +++ b/app/javascript/components/table/PameTableHead.vue @@ -0,0 +1,54 @@ + + + diff --git a/app/javascript/components/table/Row.vue b/app/javascript/components/table/Row.vue new file mode 100644 index 000000000..9eb0c3dfb --- /dev/null +++ b/app/javascript/components/table/Row.vue @@ -0,0 +1,79 @@ + + + diff --git a/app/javascript/components/table/TableHeader.vue b/app/javascript/components/table/TableHeader.vue new file mode 100644 index 000000000..bc48df2d5 --- /dev/null +++ b/app/javascript/components/table/TableHeader.vue @@ -0,0 +1,48 @@ + + + diff --git a/app/javascript/store/store.js b/app/javascript/store/store.js index de34a5b5e..54db8293c 100644 --- a/app/javascript/store/store.js +++ b/app/javascript/store/store.js @@ -14,5 +14,10 @@ import { storeTable } from './_store-table.js' export default new Vuex.Store({ modules: { table: storeTable - } + }, + mutations: { + setFilterOptions (state, options) { + this.state.selectedFilterOptions = options + }, + } }) diff --git a/app/javascript/vue.js b/app/javascript/vue.js index 0264f2e74..87bc78ece 100644 --- a/app/javascript/vue.js +++ b/app/javascript/vue.js @@ -31,6 +31,7 @@ import ChartRowPa from './components/charts/chart-row-pa/ChartRowPa' import ChartRowTarget from './components/charts/chart-row-target/ChartRowTarget' import ChartSunburst from './components/charts/chart-sunburst/ChartSunburst' import Download from './components/download/Download' +import FilteredTable from './components/FilteredTable' import MapInteractive from './components/map/MapInteractive' import NavBurger from './components/nav/NavBurger' import SearchAreas from './components/search/SearchAreas' @@ -48,6 +49,8 @@ import Tooltip from './components/tooltip/Tooltip' import VSelectSearchable from './components/select/VSelectSearchable' import VTable from './components/table/VTable' +export const eventHub = new Vue() + document.addEventListener('DOMContentLoaded', () => { if(document.getElementById('v-app')) { @@ -80,6 +83,7 @@ document.addEventListener('DOMContentLoaded', () => { ChartRowTarget, ChartSunburst, Download, + FilteredTable, MapInteractive, NavBurger, SearchAreas, diff --git a/app/models/pame_evaluation.rb b/app/models/pame_evaluation.rb index ce206a3c7..55ed2d1a0 100644 --- a/app/models/pame_evaluation.rb +++ b/app/models/pame_evaluation.rb @@ -8,9 +8,14 @@ class PameEvaluation < ApplicationRecord belongs_to :pame_source has_and_belongs_to_many :countries + validates :methodology, :year, :metadata_id, presence: true + + # config for loadable mixin ignore_column :designation + import_by protected_area: :wdpa_id - validates :methodology, :year, :metadata_id, presence: true + import_by country: :iso_3 + TABLE_ATTRIBUTES = [ { diff --git a/app/views/pame/index.html.erb b/app/views/pame/index.html.erb index 33178dc16..71f50e26b 100644 --- a/app/views/pame/index.html.erb +++ b/app/views/pame/index.html.erb @@ -1,3 +1,10 @@ -<%= render partial: "./layouts/partials/hero-basic", locals: { title: @cms_page.label, classes: "#{@cms_page.slug} bg-image-overlay--white" } %> -<%= render "partials/ctas/live-report" %> \ No newline at end of file + + +
+ + + + +
+ diff --git a/config/routes.rb b/config/routes.rb index bddfdc8fe..42c014166 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -41,7 +41,7 @@ get '/search/by_point', to: 'search#by_point' end end - + # resources :projects, only: [:create, :index, :update, :destroy] get '/marine/download_designations', to: 'marine#download_designations' @@ -69,6 +69,11 @@ # routes worked on so far as part of the refresh + + get '/pame', to: 'pame#index' + post '/pame/download', to: 'pame#download' + post '/pame/list', to: 'pame#list' + get '/resources', to: 'resources#index' get '/search', to: 'search#index' diff --git a/lib/data/seeds/pame_data-2019-08-30.csv b/lib/data/seeds/pame_data-2019-08-30.csv index 33bc33ebb..49088071d 100644 --- a/lib/data/seeds/pame_data-2019-08-30.csv +++ b/lib/data/seeds/pame_data-2019-08-30.csv @@ -1,4 +1,4 @@ -evaluation_id,wdpa_id,ISO3,methodology,year,url,metadata_id,name,designation,source_data_title,source_resp_party,source_year,source_language,restricted,assessment_is_public +id,wdpa_id,countries,methodology,year,url,metadata_id,name,designation,pame_source_data_title,pame_source_resp_party,pame_source_year,pame_source_language,restricted,assessment_is_public 1,555622076,ARE,METT,2016,Not Reported,1,Al Aqqa,Protected Area,UAE Management Effectiveness Evaluation,Ministry of Climate Change and Environment,2018,Arabic,FALSE,FALSE 2,555622075,ARE,METT,2016,Not Reported,1,Al Bidiya,Protected Area,UAE Management Effectiveness Evaluation,Ministry of Climate Change and Environment,2018,Arabic,FALSE,FALSE 3,555622070,ARE,METT,2016,Not Reported,1,Al Ghaf of Nazwa,Protected Area,UAE Management Effectiveness Evaluation,Ministry of Climate Change and Environment,2018,Arabic,FALSE,FALSE