Skip to content

Commit

Permalink
Change County to Shift Territory
Browse files Browse the repository at this point in the history
This change is a bit more wide ranging than the other renames, because
counties sometimes mean actual physical counties, and other times mean
a shift territory that can be a city, zip, county, or collection of
counties.

For that reason, many of the times, county was changed to
shift_territory, but there are many cases where a county_name became a
county since there was no more confusion.

Issue #185: Change entity names
  • Loading branch information
Frank Duncan committed Jun 16, 2020
1 parent 4a22f7b commit 6825d00
Show file tree
Hide file tree
Showing 163 changed files with 703 additions and 658 deletions.
6 changes: 3 additions & 3 deletions SmokeTest.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Scheduling
* see your flex schedule
* can edit it
* go into schedule for a month, play with different options
* see shifts, county shifts
* see shifts, shift territory shifts
* sign up for a schedule
* then de*sign up for it

Expand Down Expand Up @@ -93,6 +93,6 @@ Creating shifts in the admin console
* position
* time (shift group)
* see All shifts
* you can only sign up for shifts if you have a position and county that match
* there are regular expressions in the admin, rosters, counties (and positions)
* you can only sign up for shifts if you have a position and shift territory that match
* there are regular expressions in the admin, rosters, shift territories (and positions)
* those need to match up to somethign
4 changes: 2 additions & 2 deletions app/admin/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def initialize(person)

if is_config # is site manager
can [:read, :update], Roster::Region
can :manage, Roster::County
can :manage, Roster::ShiftTerritory
can :manage, Roster::Position
can :manage, Roster::CellCarrier
can :manage, Roster::Person
Expand Down Expand Up @@ -49,7 +49,7 @@ def initialize(person)
is_admin = person.has_role 'region_admin'
if is_admin
region = person.region_id
can :read, [Roster::Person, Roster::County, Roster::Position], region_id: region
can :read, [Roster::Person, Roster::ShiftTerritory, Roster::Position], region_id: region
can :impersonate, Roster::Person, region_id: region
can :manage, Logistics::Vehicle, region_id: region
can :manage, HomepageLink, region_id: region
Expand Down
4 changes: 2 additions & 2 deletions app/admin/incidents/dispatch_logs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

filter :region
filter :incident_number
filter :county_name
filter :county
filter :created_at

index do
column("CID") { |msg| msg.region_id }
column :message_number
column :incident_number
column :county_name
column :county
column :num_dials
actions
end
Expand Down
8 changes: 4 additions & 4 deletions app/admin/incidents/notifications/roles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
column(:members) { |r|
safe_join(r.positions.map(&:name) + r.shifts.map(&:name), tag(:br))
}
column(:counties) { |r|
safe_join(r.role_scopes.includes{response_territory}.map{|rs| rs.response_territory ? "Response Territory: #{rs.response_territory.name}" : "County: #{rs.value}" }, tag(:br))
column(:shift_territories) { |r|
safe_join(r.role_scopes.includes{response_territory}.map{|rs| rs.response_territory ? "Response Territory: #{rs.response_territory.name}" : "Shift Territory: #{rs.value}" }, tag(:br))
}
actions
end
Expand Down Expand Up @@ -56,7 +56,7 @@
end
table_for role.shifts do
column("Shift") { |s| s.name }
column("County") { |s| s.county.name }
column("Shift Territory") { |s| s.shift_territory.name }
column("Shift Time") { |shift| safe_join(shift.shift_times.map(&:name), tag(:br)) }
end
end
Expand Down Expand Up @@ -99,7 +99,7 @@
controller do

def collection
@col ||= super.includes{[positions,shifts.shift_times, shifts.county]}
@col ||= super.includes{[positions,shifts.shift_times, shifts.shift_territory]}
end

def resource_params
Expand Down
6 changes: 3 additions & 3 deletions app/admin/incidents/report_subscriptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def collection
end

def resource_params
request.get? ? [] : [params.require(:notification).permit(:person_id, :county_id, :report_type, :frequency)]
request.get? ? [] : [params.require(:notification).permit(:person_id, :shift_territory_id, :report_type, :frequency)]
end
end

Expand Down Expand Up @@ -55,7 +55,7 @@ def resource_params
column :person
column :report_type
column :frequency
column :county
column :shift_territory
column :persistent
column :last_sent
actions
Expand All @@ -64,7 +64,7 @@ def resource_params
form do |f|
f.inputs do
f.input :person
f.input :county
f.input :shift_territory
f.input :report_type, as: :assignable_select
f.input :frequency, as: :assignable_select
f.input :persistent
Expand Down
14 changes: 7 additions & 7 deletions app/admin/incidents/response_territories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

filter :region

permit_params :region_id, :name, :enabled, :is_default, :dispatch_number, :non_disaster_number, :special_instructions, :dispatch_config_id, :calendar_county_ids => [], :counties => [], cities: [], zip_codes: []
permit_params :region_id, :name, :enabled, :is_default, :dispatch_number, :non_disaster_number, :special_instructions, :dispatch_config_id, :shift_territory_ids => [], :counties => [], cities: [], zip_codes: []

index do
id_column
Expand All @@ -32,8 +32,8 @@
f.input :zip_codes, as: :string_array
f.input :special_instructions
end
f.inputs 'Counties' do
f.input :calendar_counties, as: :check_boxes, collection: available_counties
f.inputs 'Shift Territories' do
f.input :shift_territories, as: :check_boxes, collection: available_shift_territories
end
f.actions
end
Expand All @@ -43,13 +43,13 @@ def collection
@coll ||= super.includes{region}
end

def available_counties
def available_shift_territories
if resource.region
resource.region.counties
resource.region.shift_territories
else
Roster::County.all
Roster::ShiftTerritory.all
end
end
helper_method :available_counties
helper_method :available_shift_territories
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ActiveAdmin.register Roster::County, as: 'County' do
ActiveAdmin.register Roster::ShiftTerritory, as: 'Shift Territory' do

menu parent: 'Roster'

Expand Down Expand Up @@ -27,7 +27,7 @@

controller do
def resource_params
[params.fetch(resource_request_name, {}).permit(:name, :abbrev, :enabled, :county_code, :fips_code, :gis_name, :vc_regex_raw, :region_id)]
[params.fetch(resource_request_name, {}).permit(:name, :abbrev, :enabled, :shift_territory_code, :fips_code, :gis_name, :vc_regex_raw, :region_id)]
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/admin/scheduler/dispatch_configs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
f.inputs do
f.input :region, input_html: {disabled: !allow_edit_names?}
f.input :name, input_html: {disabled: !allow_edit_names?}
f.input :county, collection: f.object.region.try(:counties), input_html: {disabled: !allow_edit_names?}
f.input :shift_territory, collection: f.object.region.try(:shift_territories), input_html: {disabled: !allow_edit_names?}
f.input :is_active, input_html: {disabled: !allow_edit_names?}
if f.object.region
shifts = Scheduler::Shift.for_region(f.object.region).joins{county}.order{[county.name, name]}.includes{[shift_times, county]}
shifts = Scheduler::Shift.for_region(f.object.region).joins{shift_territory}.order{[shift_territory.name, name]}.includes{[shift_times, shift_territory]}
f.input :shift_first, collection: shifts
f.input :shift_second, collection: shifts
f.input :shift_third, collection: shifts
Expand Down Expand Up @@ -56,7 +56,7 @@ def collection

def resource_params
permitted_keys = [:backup_first_id, :backup_second_id, :backup_third_id, :backup_fourth_id, :shift_first_id, :shift_second_id, :shift_third_id, :shift_fourth_id]
permitted_keys += [:name, :region_id, :county_id, :is_active] if allow_edit_names?
permitted_keys += [:name, :region_id, :shift_territory_id, :is_active] if allow_edit_names?
[params.fetch(resource_request_name, {}).permit(*permitted_keys)]
end
end
Expand Down
22 changes: 11 additions & 11 deletions app/admin/scheduler/people.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
end
f.actions
f.inputs do
f.has_many :county_memberships do |county_form|
county_form.input :county, collection: (f.object.region && f.object.region.counties)
county_form.input :persistent
county_form.input :_destroy, as: :boolean, label: "Remove"
f.has_many :shift_territory_memberships do |shift_territory_form|
shift_territory_form.input :shift_territory, collection: (f.object.region && f.object.region.shift_territories)
shift_territory_form.input :persistent
shift_territory_form.input :_destroy, as: :boolean, label: "Remove"
end
end
f.actions
Expand All @@ -44,7 +44,7 @@

show do |person|
attributes_table do
attrs = %i(id region primary_county full_name email last_login vc_imported_at vc_is_active gap_primary gap_secondary gap_tertiary vc_last_login vc_last_profile_update address1 address2 city state zip lat lng rco_id)
attrs = %i(id region primary_shift_territory full_name email last_login vc_imported_at vc_is_active gap_primary gap_secondary gap_tertiary vc_last_login vc_last_profile_update address1 address2 city state zip lat lng rco_id)
attrs.each do |a|
row a
end
Expand All @@ -61,9 +61,9 @@
end
end
column do
panel "Counties" do
table_for person.county_memberships do
column( :name) { |rec| rec.county && rec.county.name }
panel "Shift Territories" do
table_for person.shift_territory_memberships do
column( :name) { |rec| rec.shift_territory && rec.shift_territory.name }
column(:persistent) { |rec| rec.persistent ? 'Yes' : ''}
end
end
Expand Down Expand Up @@ -101,7 +101,7 @@

filter :first_name
filter :last_name
filter :counties_id, :as => :check_boxes, :collection => proc {current_region.counties}
filter :shift_territories_id, :as => :check_boxes, :collection => proc {current_region.shift_territories}
filter :positions_id, as: :check_boxes, collection: proc {current_region.positions.sort_by{|i| [i.hidden ? 1 : 0, i.name]}}
filter :last_login, as: :date_range

Expand All @@ -119,7 +119,7 @@ def date_ranges
controller do

before_filter only: :index do
#params['q'] ||= {counties_id_in: current_user.county_ids}
#params['q'] ||= {shift_territories_id_in: current_user.shift_territory_ids}
end

def resource
Expand All @@ -129,7 +129,7 @@ def resource

def resource_params
[params.fetch(resource_request_name, {}).permit(:first_name, :last_name, :rco_id,
county_memberships_attributes: [:id, :_destroy, :persistent, :county_id],
shift_territory_memberships_attributes: [:id, :_destroy, :persistent, :shift_territory_id],
position_memberships_attributes: [:id, :_destroy, :persistent, :position_id])]
end
end
Expand Down
16 changes: 8 additions & 8 deletions app/admin/scheduler/shifts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
actions :all, except: [:destroy]

filter :shift_time
filter :county
filter :shift_territory
filter :region
filter :name
filter :abbrev
filter :dispatch_role
filter :shift_ends

scope :all do |shifts|
shifts.includes([:shift_times, {:county => :region}, :positions]).order(:county_id, :ordinal)
shifts.includes([:shift_times, {:shift_territory => :region}, :positions]).order(:shift_territory_id, :ordinal)
end
scope :active, default: true do |shifts|
shifts.where{(shift_ends == nil) | (shift_ends >= Date.current)}.includes([:shift_times, {:county => :region}, :positions]).order(:county_id, :ordinal)
shifts.where{(shift_ends == nil) | (shift_ends >= Date.current)}.includes([:shift_times, {:shift_territory => :region}, :positions]).order(:shift_territory_id, :ordinal)
end

index do
#column :shift_time, sortable: "scheduler_shift_times.start_offset"
selectable_column
column :county
column :shift_territory
column :name
column :abbrev
column 'Spreadsheet', :spreadsheet_ordinal
Expand All @@ -35,10 +35,10 @@
form do |f|
f.inputs 'Details'
f.inputs 'Shift Times' do
f.input :shift_times, as: :check_boxes, collection: Scheduler::ShiftTime.for_region(f.object.county.try(:region))
f.input :shift_times, as: :check_boxes, collection: Scheduler::ShiftTime.for_region(f.object.shift_territory.try(:region))
end
f.inputs 'Position and County' do
f.input :positions, as: :check_boxes, collection: f.object.county.try(:region).try(:positions)
f.inputs 'Position and Shift Territory' do
f.input :positions, as: :check_boxes, collection: f.object.shift_territory.try(:region).try(:positions)
f.actions
end
end
Expand Down Expand Up @@ -94,7 +94,7 @@

controller do
def resource_params
[params.fetch(resource_request_name, {}).permit(:name, :abbrev, :shift_category_id, :max_signups, :county_id, :ordinal, :spreadsheet_ordinal, :dispatch_role, :shift_begins, :shift_ends, :signups_frozen_before, :min_desired_signups, :max_advance_signup, :min_advance_signup, :ignore_county, :vc_hours_type, :show_in_dispatch_console, :exclusive, :position_ids => [], :shift_time_ids => [])]
[params.fetch(resource_request_name, {}).permit(:name, :abbrev, :shift_category_id, :max_signups, :shift_territory_id, :ordinal, :spreadsheet_ordinal, :dispatch_role, :shift_begins, :shift_ends, :signups_frozen_before, :min_desired_signups, :max_advance_signup, :min_advance_signup, :ignore_shift_territory, :vc_hours_type, :show_in_dispatch_console, :exclusive, :position_ids => [], :shift_time_ids => [])]
end
end
end
6 changes: 3 additions & 3 deletions app/assets/javascripts/scheduler/calendar.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ class window.CalendarController
chosen = $(evt.target).data('shifts')
@params['show_shifts'] = chosen
$('#select-shift-time > button[data-shifts='+chosen+']').addClass('active')
$('#choose-counties').toggle(chosen == 'county')
$('#choose-shift_territories').toggle(chosen == 'shift_territory')
this.reload()

$('#choose-county').change (evt) =>
$('#choose-shift_territory').change (evt) =>
val = $(evt.target).val()
@params['counties'] = if this.isArray(val) then val else [val]
@params['shift_territories'] = if this.isArray(val) then val else [val]
this.reload()

$(document).on 'change', '.choose-category', (evt) =>
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/scheduler/shift_assignments.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# You can use CoffeeScript in this file: http://coffeescript.org/

class window.SwapController
constructor: (county_id, position_ids) ->
constructor: (shift_territory_id, position_ids) ->

filter =
in_county: county_id
in_shift_territory: shift_territory_id
with_position: position_ids

new PersonTypeaheadController $('#select-person'), ((id, record) => $("#swap-to-id").val(id)), 'shift-swap', filter
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Place all the styles related to the Roster::Counties controller here.
// Place all the styles related to the Roster::ShiftTerritories controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
17 changes: 0 additions & 17 deletions app/controllers/admin/counties_controller.rb

This file was deleted.

17 changes: 17 additions & 0 deletions app/controllers/admin/shift_territories_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Admin::ShiftTerritoriesController < GridController
belongs_to :region, parent_class: Roster::Region, finder: :find_by_url_slug!
defaults resource_class: Roster::ShiftTerritory
load_and_authorize_resource class: Roster::ShiftTerritory

column :name
column :abbrev
column :vc_regex_raw

def build_resource_params
[params.fetch(:roster_shift_territory, {}).permit(:name, :vc_regex_raw, :abbrev)]
end

def current_ability
AdminAbility.new(logged_in_user)
end
end
Loading

0 comments on commit 6825d00

Please sign in to comment.