Skip to content

Commit

Permalink
Merge branch 'development' into domo-arigato
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminfaure authored Jan 27, 2023
2 parents 16c2f27 + 00459b6 commit cfc9b39
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,rb,erb}]
[*.{js,scss,rb,erb}]
charset = utf-8
indent_style = space
indent_size = 2
indent_size = 2
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
### Added

- Added CHANGELOG.md and Danger Github Action [#3257](https://github.com/DMPRoadmap/roadmap/issues/3257)

- Added validation with custom error message in research_output.rb to ensure a user does not enter a very large value as 'Anticipated file size'. [#3161](https://github.com/DMPRoadmap/roadmap/issues/3161)
- 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.

### Changed

- Added scss files to EditorConfig
- Change csv file name for statistics from 'Completed' to 'Created'
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
4 changes: 2 additions & 2 deletions app/controllers/usage_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def yearly_plans
plan_data(args: default_query_args)
sep = sep_param
send_data(CSV.generate(col_sep: sep) do |csv|
csv << [_('Month'), _('No. Completed Plans')]
csv << [_('Month'), _('No. Created Plans')]
total = 0
@plans_per_month.each do |data|
csv << [data.date.strftime('%b-%y'), data.count]
total += data.count
end
csv << [_('Total'), total]
end, filename: 'completed_plans.csv')
end, filename: 'created_plans.csv')
end
# rubocop:enable Metrics/AbcSize

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/answers/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ $(() => {
} else {
// Sets the editor mode for each editor to readonly
Tinymce.findEditorsByClassName(editorClass).forEach((editor) => {
editor.setMode('readonly');
editor.mode.set('readonly');
});
}

Expand Down
4 changes: 2 additions & 2 deletions app/javascript/src/orgs/adminEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ $(() => {
const editor = Tinymce.findEditorById('org_feedback_msg');
if (isObject(editor)) {
if ($('#org_feedback_enabled_true').is(':checked')) {
editor.setMode('code');
editor.mode.set('design');
} else {
editor.setMode('readonly');
editor.mode.set('readonly');
}
}
};
Expand Down
2 changes: 2 additions & 0 deletions app/models/research_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class ResearchOutput < ApplicationRecord
allow_nil: true, allow_blank: true,
message: UNIQUENESS_MESSAGE }

validates_numericality_of :byte_size, greater_than: 0, less_than_or_equal_to: 2**63,
message: '(Anticipated file size) is too large. Please enter a smaller value.'
# Ensure presence of the :output_type_description if the user selected 'other'
validates_presence_of :output_type_description, if: -> { other? }, message: PRESENCE_MESSAGE

Expand Down
19 changes: 17 additions & 2 deletions app/views/orgs/_profile_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<%
shared_links_tooltip = _('Links will be displayed next to your organisation\'s logo')
org_config_info_tooltip = _('This information can only be changed by a system administrator. Contact the Help Desk if you have questions or to request changes.')
org_types_tooltip = _(
'This information can only be changed by a system administrator. Contact %{support_email} if you have questions or to request changes.' % { support_email: Rails.configuration.x.organisation.email}
)
%>
<%= form_for(org, url: url, html: { multipart: true, method: method,
Expand Down Expand Up @@ -136,7 +139,13 @@
<div class="row">
<% if current_user.can_super_admin? %>
<fieldset class="col-xs-8">
<legend><%= _('Organisation Types') %></legend>
<legend>
<%= _('Organisation Types') %>
&nbsp; <a href="#" aria-label="<%= _('Text') %>" data-toggle="tooltip" data-placement="right" title="<%= org_types_tooltip %>">
<i class="fas fa-question-circle fa-reverse" ></i>
<em class="sr-only"></em>
</a>
</legend>
<div class="checkbox">
<%= f.label :funder do %>
<%= f.check_box :funder, { class: 'org_types', value: org.funder? }, "true", "false" %>
Expand All @@ -159,7 +168,13 @@
<% else %>
<div class="col-xs-8">
<dl>
<dt><%= _('Organisation type(s)') %></dt>
<dt>
<%= _('Organisation type(s)') %>
&nbsp; <a href="#" aria-label="<%= _('Text') %>" data-toggle="tooltip" data-placement="right" title="<%= org_types_tooltip %>">
<i class="fas fa-question-circle fa-reverse" ></i>
<em class="sr-only"></em>
</a>
</dt>
<dd><%= org.org_type_to_s %></dd>
</dl>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/plans/_share_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<%= f.radio_button :visibility, :publicly_visible,
data: { url: visibility_plan_path(@plan),
remote: true, method: :post } %>
<%= _('Public: anyone can view') %>
<%= _('Public: anyone can view or download from the Public DMPs page') %>
<% end %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/usage_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
get :yearly_plans
end
it 'assigns the correct csv data' do
expected = "Month,No. Completed Plans\n" \
expected = "Month,No. Created Plans\n" \
"#{@date.strftime('%b-%y')},#{@plan_stat.count}\n" \
"Total,#{@plan_stat.count}\n"
expect(response.content_type).to eq('text/csv')
Expand Down

0 comments on commit cfc9b39

Please sign in to comment.