Skip to content
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GIT

GIT
remote: https://github.com/tsubik/active_admin_paranoia.git
revision: 3f3fd26962ae4d8aee139a3b8f7256e2d1d340dc
revision: cf5de101901e49eebf3ab76aae9e290d5e44f546
specs:
active_admin_paranoia (1.0.11)
paranoia (>= 1.0)
Expand Down
2 changes: 1 addition & 1 deletion app/admin/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def scoped_collection

filter :iso, as: :select
filter :translations_name_cont, as: :select,
label: -> { I18n.t("activerecord.attributes.country.name") },
label: -> { Country.human_attribute_name(:name) },
collection: -> { Country.order(:name).pluck(:name) }
filter :region_iso, as: :select
filter :region_name
Expand Down
1 change: 1 addition & 0 deletions app/admin/custom_admin_header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def build(namespace, menu) # rubocop:disable Metrics/AbcSize
ul do
li { link_to t("active_admin.menu.language.english"), admin_dashboard_change_language_path(locale: :en), method: :post }
li { link_to t("active_admin.menu.language.french"), admin_dashboard_change_language_path(locale: :fr), method: :post }
li { link_to t("active_admin.menu.language.spanish"), admin_dashboard_change_language_path(locale: :es), method: :post }
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/admin/fmu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def download_shapefiles(fmus)

filter :id, as: :select
filter :country, as: :select, label: proc { I18n.t("activerecord.models.country.one") }, collection: -> { Country.joins(:fmus).by_name_asc }
filter :operator_in_all, as: :select, label: proc { I18n.t("activerecord.attributes.fmu.operator") }, collection: -> { Operator.order(:name) }
filter :operator_in_all, as: :select, label: proc { Fmu.human_attribute_name(:operator) }, collection: -> { Operator.order(:name) }
filter :name_cont,
as: :select, label: proc { I18n.t("activerecord.attributes.fmu.name") },
as: :select, label: proc { Fmu.human_attribute_name(:name) },
collection: -> { Fmu.by_name_asc.pluck(:name) }

dependent_filters do
Expand Down Expand Up @@ -191,7 +191,7 @@ def download_shapefiles(fmus)
end

f.inputs I18n.t("activerecord.models.operator"), for: [:fmu_operator, f.object.fmu_operator || FmuOperator.new] do |fo|
fo.input :operator_id, label: I18n.t("activerecord.attributes.operator.name"), as: :select,
fo.input :operator_id, label: Operator.human_attribute_name(:name), as: :select,
collection: Operator.active.map { |o| [o.name, o.id] },
input_html: {disabled: object.persisted?}, required: false
fo.input :start_date, input_html: {disabled: object.persisted?}, required: false
Expand Down
2 changes: 1 addition & 1 deletion app/admin/gov_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def scoped_collection
collection: -> { Country.with_translations(I18n.locale).joins(:required_gov_documents).distinct.order("country_translations.name") }
filter :status, as: :select, collection: -> { GovDocument.statuses }
filter :required_gov_document_document_type,
label: proc { I18n.t("activerecord.attributes.required_gov_document.document_type") },
label: proc { RequiredGovDocument.human_attribute_name(:document_type) },
as: :select, collection: -> { RequiredGovDocument.document_types }
filter :updated_at

Expand Down
2 changes: 1 addition & 1 deletion app/admin/government.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def scoped_collection

filter :country, as: :select, collection: -> { Country.joins(:governments).by_name_asc }
filter :translations_government_entity_cont,
as: :select, label: -> { I18n.t("activerecord.attributes.government/translation.government_entity") },
as: :select, label: -> { Government.human_attribute_name(:government_entity) },
collection: -> { Government.by_entity_asc.distinct.pluck(:government_entity) }

dependent_filters do
Expand Down
48 changes: 21 additions & 27 deletions app/admin/law.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def scoped_collection
filter :subcategory,
as: :select,
collection: -> { Subcategory.joins(:laws).with_translations(I18n.locale).order("subcategory_translations.name") }
filter :written_infraction_cont, label: proc { I18n.t("active_admin.laws_page.written_infraction") }
filter :infraction_cont, label: proc { I18n.t("active_admin.laws_page.infraction") }
filter :sanctions_cont, label: proc { I18n.t("active_admin.laws_page.sanctions") }
filter :max_fine, label: proc { I18n.t("active_admin.laws_page.max_fine") }
filter :min_fine, label: proc { I18n.t("active_admin.laws_page.min_fine") }
filter :written_infraction_cont, label: proc { Law.human_attribute_name(:written_infraction) }
filter :infraction_cont, label: proc { Law.human_attribute_name(:infraction) }
filter :sanctions_cont, label: proc { Law.human_attribute_name(:sanctions) }
filter :max_fine, label: proc { Law.human_attribute_name(:max_fine) }
filter :min_fine, label: proc { Law.human_attribute_name(:min_fine) }

dependent_filters do
{
Expand All @@ -46,15 +46,9 @@ def scoped_collection
column :subcategory do |l|
l.subcategory&.name
end
column I18n.t("active_admin.laws_page.written_infraction") do |l|
l.written_infraction
end
column I18n.t("active_admin.laws_page.infraction") do |l|
l.infraction
end
column I18n.t("active_admin.laws_page.sanctions") do |l|
l.sanctions
end
column :written_infraction
column :infraction
column :sanctions
column :min_fine
column :max_fine
column :currency
Expand All @@ -68,15 +62,15 @@ def scoped_collection
index do
column :country, sortable: "country_translations.name"
column :subcategory, sortable: "subcategory_translations.name"
column I18n.t("active_admin.laws_page.written_infraction"), :written_infraction, sortable: true
column I18n.t("active_admin.laws_page.infraction"), :infraction, sortable: true
column I18n.t("active_admin.laws_page.sanctions"), :sanctions, sortable: true
column I18n.t("active_admin.laws_page.min_fine"), :min_fine, sortable: true
column I18n.t("active_admin.laws_page.max_fine"), :max_fine, sortable: true
column :written_infraction, sortable: true
column :infraction, sortable: true
column :sanctions, sortable: true
column :min_fine, sortable: true
column :max_fine, sortable: true
column :currency
column :penal_servitude, sortable: true
column :other_penalties, sortable: true
column I18n.t("active_admin.laws_page.indicator_apv"), :apv, sortable: true
column :apv, sortable: true
column :created_at, sortable: true
column :updated_at, sortable: true

Expand All @@ -85,7 +79,7 @@ def scoped_collection

form do |f|
f.semantic_errors(*f.object.errors.attribute_names)
f.inputs I18n.t("active_admin.laws_page.law_details") do
f.inputs I18n.t("active_admin.shared.law_details") do
if f.object.new_record?
f.input :country
f.input :subcategory, as: :select,
Expand All @@ -95,15 +89,15 @@ def scoped_collection
f.input :subcategory, input_html: {disabled: true}
end

f.input :written_infraction, label: I18n.t("active_admin.laws_page.written_infraction")
f.input :infraction, label: I18n.t("active_admin.laws_page.infraction")
f.input :sanctions, label: I18n.t("active_admin.laws_page.sanctions")
f.input :min_fine, label: I18n.t("active_admin.laws_page.min_fine")
f.input :max_fine, label: I18n.t("active_admin.laws_page.max_fine")
f.input :written_infraction
f.input :infraction
f.input :sanctions
f.input :min_fine
f.input :max_fine
f.input :currency
f.input :penal_servitude
f.input :other_penalties
f.input :apv, label: I18n.t("active_admin.laws_page.indicator_apv")
f.input :apv

f.actions
end
Expand Down
Loading