Skip to content

Commit 7d42afb

Browse files
committed
improve FMUs show page, two columns, show geojson in modal dialog for copy-paste actions
1 parent e0194e6 commit 7d42afb

File tree

4 files changed

+46
-22
lines changed

4 files changed

+46
-22
lines changed

app/admin/fmu.rb

+38-22
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def download_shapefiles(fmus)
6969
}
7070
end
7171

72-
sidebar "Shapefiles" do
72+
sidebar "Shapefiles", only: :index do
7373
div do
7474
link_to "Download Filtered Shapefiles", download_filtered_shapefiles_admin_fmus_path(
7575
q: params[:q]&.to_unsafe_h
@@ -101,29 +101,45 @@ def download_shapefiles(fmus)
101101
end
102102

103103
show do
104-
attributes_table do
105-
row :id
106-
row :name
107-
row :forest_type
108-
row :country
109-
row :operator
110-
row :certification_fsc
111-
row :certification_pefc
112-
row :certification_olb
113-
row :certification_pafc
114-
row :certification_fsc_cw
115-
row :certification_tlv
116-
row :certification_ls
117-
if resource.geojson && resource.centroid.present?
118-
row :map do |r|
119-
render partial: "map", locals: {center: [r.centroid.x, r.centroid.y], center_marker: false, geojson: r.geojson, bbox: r.bbox}
104+
columns class: "d-flex" do
105+
column class: "flex-1" do
106+
attributes_table do
107+
row :id
108+
row :name
109+
row :forest_type
110+
row :country
111+
row :operator
112+
113+
if resource.geojson && resource.centroid.present?
114+
row :map do |r|
115+
render partial: "map", locals: {center: [r.centroid.x, r.centroid.y], center_marker: false, geojson: r.geojson, bbox: r.bbox}
116+
end
117+
end
118+
if resource.geojson
119+
row(:geojson) do
120+
div id: "geojson_modal", style: "display: none;" do
121+
resource.geojson
122+
end
123+
link_to "Show", "javascript:void(0)", onclick: "$('#geojson_modal').dialog({ modal: true, dialogClass: 'custom_dialog' })"
124+
end
125+
end
126+
row :created_at
127+
row :updated_at
128+
row :deleted_at
129+
end
130+
end
131+
132+
column max_width: "250px" do
133+
attributes_table title: t("active_admin.fmus_page.certification") do
134+
row :certification_fsc
135+
row :certification_pefc
136+
row :certification_olb
137+
row :certification_pafc
138+
row :certification_fsc_cw
139+
row :certification_tlv
140+
row :certification_ls
120141
end
121142
end
122-
row(:geojson) { |fmu| fmu.geojson.to_json }
123-
row(:properties) { |fmu| fmu.geojson&.dig("properties")&.to_json }
124-
row :created_at
125-
row :updated_at
126-
row :deleted_at
127143
end
128144
end
129145

app/assets/stylesheets/active_admin.scss

+6
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,9 @@ body.active_admin {
214214
display: none;
215215
}
216216

217+
.custom_dialog {
218+
width: unset !important;
219+
max-height: 80vh;
220+
max-width: 70vw;
221+
overflow-y: auto;
222+
}

config/locales/en.yml

+1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ en:
330330
indicator_apv: 'Indicator APV'
331331
law_details: 'Law details'
332332
fmus_page:
333+
certification: Certification
333334
download_shapefile: 'Download shapefile'
334335
confirm_delete: 'Are you sure you want to delete this FMU?'
335336
operator_page:

config/locales/fr.yml

+1
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ fr:
362362
indicator_apv: 'Indicateur APV'
363363
law_details: 'Détails de la loi'
364364
fmus_page:
365+
certification: Certification
365366
download_shapefile: 'Télécharger shapefile'
366367
confirm_delete: 'Êtes-vous sûr de vouloir supprimer cette FMU?'
367368
required_operator_document_page:

0 commit comments

Comments
 (0)