Skip to content

Commit

Permalink
Merge branch 'development' into fix-pagniable-links
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminfaure authored Jan 27, 2023
2 parents 5246ce3 + 1b816d9 commit 223a7f9
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- Added popover for org profile page and added explanation for public plan
### Fixed

- Updated sans-serif font used in PDF downloads to Roboto since Google API no longer offers Helvetica
- Fixed discrepencies with default/max per_page values for API and UI pagination
- Updated JS that used to call the TinyMCE `setMode()` function so that it now calls `mode.set()` because the former is now deprecated.
- Fixed an issue with the Rails 6 keyword arguments change that was causing the `paginable_sort_link` to fail

Expand Down
6 changes: 5 additions & 1 deletion app/controllers/api/v0/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ def index
plan_ids = extract_param_list(params, 'plan')
@plans = @plans.where(id: plan_ids) if plan_ids.present?
# apply pagination after filtering
@args = { per_page: params[:per_page], page: params[:page] }
max_per_page = Rails.configuration.x.application.api_max_page_size
page = params.fetch('page', 1).to_i
per_page = params.fetch('per_page', max_per_page).to_i
per_page = max_per_page if @per_page > max_per_page
@args = { per_page: per_page, page: page }
@plans = refine_query(@plans)
respond_with @plans
end
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/api/v1/base_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ def base_response_content
# Retrieve the requested pagination params or use defaults
# only allow 100 per page as the max
def pagination_params
max_per_page = Rails.configuration.x.application.api_max_page_size
@page = params.fetch('page', 1).to_i
@per_page = params.fetch('per_page', 20).to_i
@per_page = 100 if @per_page > 100
@per_page = params.fetch('per_page', max_per_page).to_i
@per_page = max_per_page if @per_page > max_per_page
end

# Parse the body of the incoming request
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/paginable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def refine_query(scope)
if @args[:page] != 'ALL'
# Can raise error if page is not a number
scope = scope.page(@args[:page])
.per(@args.fetch(:per_page, Rails.configuration.x.application.api_max_page_size))
.per(@args.fetch(:per_page, Rails.configuration.x.results_per_page))
end
scope
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/exports_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module ExportsHelper
}.freeze

def font_face
@formatting[:font_face].presence || 'Arial, Helvetica, Sans-Serif'
@formatting[:font_face].presence || 'Roboto, Arial, Sans-Serif'
end

def font_size
Expand Down
2 changes: 1 addition & 1 deletion app/models/settings/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Settings
class Template < RailsSettings::SettingObject
VALID_FONT_FACES = [
'"Times New Roman", Times, Serif',
'Arial, Helvetica, Sans-Serif'
'Roboto, Arial, Sans-Serif'
].freeze

VALID_FONT_SIZE_RANGE = (8..14).freeze
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/export/_plan_styling.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<style>
@import 'https://fonts.googleapis.com/css?family=<%= font_face.downcase.include?('times') ? 'Times' : 'Helvetica' %>';
@import 'https://fonts.googleapis.com/css?family=<%= font_face.downcase.include?('times') ? 'Times' : 'Roboto' %>';

body {
font-family: <%= font_face %>;
Expand Down Expand Up @@ -58,5 +58,5 @@
}
.bold {
font-weight: bold;
}
}
</style>

0 comments on commit 223a7f9

Please sign in to comment.