Skip to content

Commit

Permalink
fix[Op#58142]: Standardize projects table rendering
Browse files Browse the repository at this point in the history
Leverage correct pagination rendering via `url_for_action:` overrides.
  • Loading branch information
akabiru committed Sep 27, 2024
1 parent 0b9c117 commit 46312dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,6 @@ def find_custom_field_project_to_destroy
respond_with_project_not_found_turbo_streams
end

def update_project_list_via_turbo_stream(url_for_action: action_name)
update_via_turbo_stream(
component: Admin::CustomFields::CustomFieldProjects::TableComponent.new(
query: available_custom_fields_projects_query,
params: { custom_field: @custom_field, url_for_action: }
)
)
end

def available_custom_fields_projects_query
@available_custom_fields_projects_query = ProjectQuery.new(
name: "custom-fields-projects-#{@custom_field.id}"
Expand All @@ -165,7 +156,7 @@ def initialize_custom_field_project

def respond_with_project_not_found_turbo_streams
render_error_flash_message_via_turbo_stream message: t(:notice_project_not_found)
update_project_list_via_turbo_stream
render_project_list(url_for_action: :index)

respond_with_turbo_streams
end
Expand Down
17 changes: 4 additions & 13 deletions app/controllers/admin/settings/project_custom_fields_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,8 @@ def find_unlink_project_custom_field_mapping
project_id: permitted_params.project_custom_field_project_mapping[:project_id]
)
rescue ActiveRecord::RecordNotFound
render_error_flash_message_via_turbo_stream(
message: t(:notice_file_not_found)
)
replace_via_turbo_stream(
component: Settings::ProjectCustomFields::ProjectCustomFieldMapping::TableComponent.new(
query: project_custom_field_mappings_query,
params: { custom_field: @custom_field }
)
)
render_error_flash_message_via_turbo_stream(message: t(:notice_file_not_found))
render_project_list(url_for_action: :project_mappings)

respond_with_turbo_streams
end
Expand All @@ -211,10 +204,8 @@ def find_custom_field_projects_to_link
false
end
rescue ActiveRecord::RecordNotFound
render_error_flash_message_via_turbo_stream(
message: t(:notice_project_not_found)
)
render_project_list
render_error_flash_message_via_turbo_stream(message: t(:notice_project_not_found))
render_project_list(url_for_action: :project_mappings)

respond_with_turbo_streams
end
Expand Down

0 comments on commit 46312dd

Please sign in to comment.