Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions app/builders/better_together/navigation_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -219,56 +219,56 @@ def build_host # rubocop:todo Metrics/MethodLength
slug_en: 'host-dashboard',
position: 0,
item_type: 'link',
route_name: 'host_dashboard_url'
route_name: 'host_root_url'
},
{
title_en: 'Communities',
slug_en: 'communities',
position: 1,
item_type: 'link',
route_name: 'communities_url'
route_name: 'host_communities_url'
},
{
title_en: 'Navigation Areas',
slug_en: 'navigation-areas',
position: 2,
item_type: 'link',
route_name: 'navigation_areas_url'
route_name: 'host_navigation_areas_url'
},
{
title_en: 'Pages',
slug_en: 'pages',
position: 3,
item_type: 'link',
route_name: 'pages_url'
route_name: 'host_pages_url'
},
{
title_en: 'People',
slug_en: 'people',
position: 4,
item_type: 'link',
route_name: 'people_url'
route_name: 'host_people_url'
},
{
title_en: 'Platforms',
slug_en: 'platforms',
position: 5,
item_type: 'link',
route_name: 'platforms_url'
route_name: 'host_platforms_url'
},
{
title_en: 'Roles',
slug_en: 'roles',
position: 6,
item_type: 'link',
route_name: 'roles_url'
route_name: 'host_roles_url'
},
{
title_en: 'Resource Permissions',
slug_en: 'resource_permissions',
position: 7,
item_type: 'link',
route_name: 'resource_permissions_url'
route_name: 'host_resource_permissions_url'
}
]

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/better_together/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def store_user_location!
def after_sign_in_path_for(resource)
stored_location_for(resource) ||
if resource.permitted_to?('manage_platform')
host_dashboard_path
host_root_path
else
BetterTogether.base_path_with_locale
end
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/better_together/navigation_areas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def create
@navigation_area = resource_class.new(navigation_area_params)
authorize @navigation_area

if @navigation_area.save
redirect_to @navigation_area, only_path: true, notice: 'Navigation area was successfully created.'
if @navigation_area.save
redirect_to [:host, @navigation_area], only_path: true, notice: 'Navigation area was successfully created.'
else
render :new
end
Expand All @@ -59,8 +59,8 @@ def create
def update
authorize @navigation_area

if @navigation_area.update(navigation_area_params)
redirect_to @navigation_area, only_path: true, notice: 'Navigation area was successfully updated.'
if @navigation_area.update(navigation_area_params)
redirect_to [:host, @navigation_area], only_path: true, notice: 'Navigation area was successfully updated.'
else
render :edit
end
Expand All @@ -69,7 +69,7 @@ def update
def destroy
authorize @navigation_area
@navigation_area.destroy
redirect_to navigation_areas_url, notice: 'Navigation area was successfully destroyed.'
redirect_to host_navigation_areas_url, notice: 'Navigation area was successfully destroyed.'
end

private
Expand Down
20 changes: 10 additions & 10 deletions app/controllers/better_together/navigation_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def create
@navigation_item.assign_attributes(navigation_item_params)
authorize @navigation_item

if @navigation_item.save
redirect_to @navigation_area, only_path: true, notice: 'Navigation item was successfully created.'
if @navigation_item.save
redirect_to [:host, @navigation_area], only_path: true, notice: 'Navigation item was successfully created.'
else
render :new
end
Expand All @@ -49,11 +49,11 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength

respond_to do |format|
if @navigation_item.update(navigation_item_params)
flash[:notice] = t('navigation_item.updated')
format.html { redirect_to @navigation_area, notice: t('navigation_item.updated') }
format.turbo_stream do
redirect_to @navigation_area, only_path: true
end
flash[:notice] = t('navigation_item.updated')
format.html { redirect_to [:host, @navigation_area], notice: t('navigation_item.updated') }
format.turbo_stream do
redirect_to [:host, @navigation_area], only_path: true
end
else
flash.now[:alert] = t('navigation_item.update_failed')
format.html { render :edit, status: :unprocessable_entity }
Expand All @@ -73,9 +73,9 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength

def destroy
authorize @navigation_item
@navigation_item.destroy
redirect_to navigation_area_navigation_items_url(@navigation_area),
notice: 'Navigation item was successfully destroyed.'
@navigation_item.destroy
redirect_to host_navigation_area_navigation_items_url(@navigation_area),
notice: 'Navigation item was successfully destroyed.'
end

private
Expand Down
16 changes: 8 additions & 8 deletions app/controllers/better_together/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def create
@page = resource_class.new(page_params)
authorize @page

if @page.save
redirect_to edit_page_path(@page), notice: 'Page was successfully created.'
if @page.save
redirect_to edit_host_page_path(@page), notice: 'Page was successfully created.'
else
render :new
end
Expand All @@ -52,10 +52,10 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength

respond_to do |format|
if @page.update(page_params)
format.html do
flash[:notice] = 'Page was successfully updated.'
redirect_to edit_page_path(@page), notice: 'Page was successfully updated.'
end
format.html do
flash[:notice] = 'Page was successfully updated.'
redirect_to edit_host_page_path(@page), notice: 'Page was successfully updated.'
end
format.turbo_stream do
flash.now[:notice] = 'Page was successfully updated.'
render turbo_stream: [
Expand All @@ -76,8 +76,8 @@ def update # rubocop:todo Metrics/AbcSize, Metrics/MethodLength

def destroy
authorize @page
@page.destroy
redirect_to pages_url, notice: 'Page was successfully destroyed.'
@page.destroy
redirect_to host_pages_url, notice: 'Page was successfully destroyed.'
end

protected
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/better_together/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create
authorize_person

if @person.save
redirect_to @person, only_path: true, notice: 'Person was successfully created.', status: :see_other
redirect_to [:host, @person], only_path: true, notice: 'Person was successfully created.', status: :see_other
else
render :new, status: :unprocessable_entity
end
Expand All @@ -37,7 +37,7 @@ def edit; end
def update
ActiveRecord::Base.transaction do
if @person.update(person_params)
redirect_to @person, only_path: true, notice: 'Profile was successfully updated.', status: :see_other
redirect_to (me? ? @person : [:host, @person]), only_path: true, notice: 'Profile was successfully updated.', status: :see_other
else
flash.now[:alert] = 'Please address the errors below.'
render :edit, status: :unprocessable_entity
Expand All @@ -48,7 +48,7 @@ def update
# DELETE /people/1
def destroy
@person.destroy
redirect_to people_url, notice: 'Person was successfully deleted.', status: :see_other
redirect_to host_people_url, notice: 'Person was successfully deleted.', status: :see_other
end

protected
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/better_together/platforms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def create
authorize_platform

if @platform.save
redirect_to @platform, notice: 'Platform was successfully created.'
redirect_to [:host, @platform], notice: 'Platform was successfully created.'
else
render :new, status: :unprocessable_entity
end
Expand All @@ -51,7 +51,7 @@ def create
def update
authorize @platform
if @platform.update(platform_params)
redirect_to @platform, notice: 'Platform was successfully updated.', status: :see_other
redirect_to [:host, @platform], notice: 'Platform was successfully updated.', status: :see_other
else
render :edit, status: :unprocessable_entity
end
Expand All @@ -61,7 +61,7 @@ def update
def destroy
authorize @platform
@platform.destroy
redirect_to platforms_url, notice: 'Platform was successfully destroyed.', status: :see_other
redirect_to host_platforms_url, notice: 'Platform was successfully destroyed.', status: :see_other
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def create
@resource_permission = resource_class.new(resource_permission_params)
authorize @resource_permission

if @resource_permission.save
redirect_to @resource_permission, only_path: true, notice: 'Resource permission was successfully created.'
if @resource_permission.save
redirect_to [:host, @resource_permission], only_path: true, notice: 'Resource permission was successfully created.'
else
render :new, status: :unprocessable_entity
end
Expand All @@ -43,9 +43,9 @@ def create
def update
authorize @resource_permission

if @resource_permission.update(resource_permission_params)
redirect_to @resource_permission, only_path: true, notice: 'Resource permission was successfully updated.',
status: :see_other
if @resource_permission.update(resource_permission_params)
redirect_to [:host, @resource_permission], only_path: true, notice: 'Resource permission was successfully updated.',
status: :see_other
else
render :edit, status: :unprocessable_entity
end
Expand All @@ -54,9 +54,9 @@ def update
# DELETE /resource_permissions/1
def destroy
authorize @resource_permission
@resource_permission.destroy
redirect_to resource_permissions_url, notice: 'Resource permission was successfully destroyed.',
status: :see_other
@resource_permission.destroy
redirect_to host_resource_permissions_url, notice: 'Resource permission was successfully destroyed.',
status: :see_other
end

private
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/better_together/roles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def create
@role = resource_class.new(role_params)
authorize @role # Add authorization check

if @role.save
redirect_to @role, only_path: true, notice: 'Role was successfully created.'
if @role.save
redirect_to [:host, @role], only_path: true, notice: 'Role was successfully created.'
else
render :new, status: :unprocessable_entity
end
Expand All @@ -44,8 +44,8 @@ def create
def update
authorize @role # Add authorization check

if @role.update(role_params)
redirect_to @role, only_path: true, notice: 'Role was successfully updated.', status: :see_other
if @role.update(role_params)
redirect_to [:host, @role], only_path: true, notice: 'Role was successfully updated.', status: :see_other
else
render :edit, status: :unprocessable_entity
end
Expand All @@ -54,8 +54,8 @@ def update
# DELETE /roles/1
def destroy
authorize @role # Add authorization check
@role.destroy
redirect_to roles_url, notice: 'Role was successfully destroyed.', status: :see_other
@role.destroy
redirect_to host_roles_url, notice: 'Role was successfully destroyed.', status: :see_other
end

private
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/better_together/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def create
@user = resource_class.new(user_params)
authorize_user

if @user.save
redirect_to @user, only_path: true, notice: 'User was successfully created.', status: :see_other
if @user.save
redirect_to [:host, @user], only_path: true, notice: 'User was successfully created.', status: :see_other
else
render :new, status: :unprocessable_entity
end
Expand All @@ -39,8 +39,8 @@ def edit; end
# PATCH/PUT /users/1
def update
ActiveRecord::Base.transaction do
if @user.update(user_params)
redirect_to @user, only_path: true, notice: 'Profile was successfully updated.', status: :see_other
if @user.update(user_params)
redirect_to [:host, @user], only_path: true, notice: 'Profile was successfully updated.', status: :see_other
else
flash.now[:alert] = 'Please address the errors below.'
render :edit, status: :unprocessable_entity
Expand All @@ -50,8 +50,8 @@ def update

# DELETE /users/1
def destroy
@user.destroy
redirect_to users_url, notice: 'User was successfully deleted.', status: :see_other
@user.destroy
redirect_to host_users_url, notice: 'User was successfully deleted.', status: :see_other
end

private
Expand Down
44 changes: 22 additions & 22 deletions app/models/better_together/navigation_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ class NavigationItem < ApplicationRecord # rubocop:todo Metrics/ClassLength
include Protected

class_attribute :route_names, default: {
calls_for_interest: 'calls_for_interest_url',
calendars: 'calendars_url',
content_blocks: 'content_blocks_url',
communities: 'communities_url',
events: 'events_url',
geography_continents: 'geography_continents_url',
geography_countries: 'geography_countries_url',
geography_maps: 'geography_maps_url',
geography_states: 'geography_states_url',
geography_regions: 'geography_regions_url',
geography_settlements: 'geography_settlements_url',
host_dashboard: 'host_dashboard_url',
hub: 'hub_url',
metrics_reports: 'metrics_reports_url',
navigation_areas: 'navigation_areas_url',
pages: 'pages_url',
people: 'people_url',
platforms: 'platforms_url',
resource_permissions: 'resource_permissions_url',
roles: 'roles_url',
users: 'users_url'
}
calls_for_interest: 'calls_for_interest_url',
calendars: 'calendars_url',
content_blocks: 'host_content_blocks_url',
communities: 'host_communities_url',
events: 'events_url',
geography_continents: 'host_geography_continents_url',
geography_countries: 'host_geography_countries_url',
geography_maps: 'geography_maps_url',
geography_states: 'host_geography_states_url',
geography_regions: 'host_geography_regions_url',
geography_settlements: 'host_geography_settlements_url',
host_dashboard: 'host_root_url',
hub: 'hub_url',
metrics_reports: 'host_metrics_reports_url',
navigation_areas: 'host_navigation_areas_url',
pages: 'host_pages_url',
people: 'host_people_url',
platforms: 'host_platforms_url',
resource_permissions: 'host_resource_permissions_url',
roles: 'host_roles_url',
users: 'host_users_url'
}

belongs_to :navigation_area, touch: true
belongs_to :linkable, polymorphic: true, optional: true, autosave: true
Expand Down
Loading
Loading