From 92450631a09e1b27a85d2c6f1c69bf91018d186a Mon Sep 17 00:00:00 2001 From: Ben <95949082+kasugaijin@users.noreply.github.com> Date: Wed, 18 Dec 2024 15:37:04 -0800 Subject: [PATCH] Refactor countries states (#1278) * Refactor countries states to use full name module because the CS module name was breaking in the Org settings context (might interfere with an existing name) * lint fixes * update test --- ..._states_controller.rb => countries_states_controller.rb} | 4 ++-- .../organizations/staff/organizations_controller.rb | 1 + .../index.turbo_stream.erb | 0 app/views/organizations/staff/organizations/_form.html.erb | 5 ++--- app/views/shared/_location_fields.html.erb | 6 +++--- config/initializers/countries_states.rb | 4 ++-- config/routes.rb | 2 +- test/controllers/country_states_controller_test.rb | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) rename app/controllers/{country_states_controller.rb => countries_states_controller.rb} (71%) rename app/views/{country_states => countries_states}/index.turbo_stream.erb (100%) diff --git a/app/controllers/country_states_controller.rb b/app/controllers/countries_states_controller.rb similarity index 71% rename from app/controllers/country_states_controller.rb rename to app/controllers/countries_states_controller.rb index 9a9484ec6..096a7c4fb 100644 --- a/app/controllers/country_states_controller.rb +++ b/app/controllers/countries_states_controller.rb @@ -1,4 +1,4 @@ -class CountryStatesController < ApplicationController +class CountriesStatesController < ApplicationController skip_before_action :authenticate_user! skip_verify_authorized only: %i[index] @@ -8,7 +8,7 @@ def index @name = params[:name] @selected_state = params[:province_state] - @states = CS[country.to_sym][:states].invert + @states = COUNTRIES_STATES[country.to_sym][:states].invert respond_to do |format| format.turbo_stream diff --git a/app/controllers/organizations/staff/organizations_controller.rb b/app/controllers/organizations/staff/organizations_controller.rb index ac8a497d2..0f92ef0b3 100644 --- a/app/controllers/organizations/staff/organizations_controller.rb +++ b/app/controllers/organizations/staff/organizations_controller.rb @@ -6,6 +6,7 @@ class OrganizationsController < Organizations::BaseController before_action :set_organization, only: %i[edit update] def edit + @location = @organization.locations.last || @organization.locations.build # polymorphic end def update diff --git a/app/views/country_states/index.turbo_stream.erb b/app/views/countries_states/index.turbo_stream.erb similarity index 100% rename from app/views/country_states/index.turbo_stream.erb rename to app/views/countries_states/index.turbo_stream.erb diff --git a/app/views/organizations/staff/organizations/_form.html.erb b/app/views/organizations/staff/organizations/_form.html.erb index 6ce2493b1..0e808198e 100644 --- a/app/views/organizations/staff/organizations/_form.html.erb +++ b/app/views/organizations/staff/organizations/_form.html.erb @@ -39,9 +39,8 @@