Skip to content

Commit 47be9ba

Browse files
Merge pull request #3174 from DMPRoadmap/development
Update master prior to v3.1.1 (brakeman fails on end of life warning, so ignoring.)
2 parents 7cac435 + 5f6eaab commit 47be9ba

File tree

17 files changed

+45
-41
lines changed

17 files changed

+45
-41
lines changed

app/controllers/api/v0/plans_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ def index
7373

7474
# Get all the Org Admin plans
7575
org_admin_plans = @user.org.org_admin_plans
76-
@plans = org_admin_plans.includes([{ roles: :user }, { answers: :question_options },
77-
template: [{ phases: {
78-
sections: { questions: %i[question_format themes] }
79-
} }, :org]])
76+
@plans = org_admin_plans.preload([{ roles: :user }, { answers: :question_options },
77+
template: [{ phases: {
78+
sections: { questions: %i[question_format themes] }
79+
} }, :org]])
8080

8181
# Filter on list of users
8282
user_ids = extract_param_list(params, 'user')

app/controllers/paginable/templates_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ def history
105105
paginable_renderise(
106106
partial: 'history',
107107
scope: @templates,
108-
query_params: { sort_field: 'templates.title', sort_direction: :asc },
109-
locals: { current: @templates.maximum(:version) }
108+
query_params: { sort_field: 'templates.version', sort_direction: :desc },
109+
locals: { current: @templates.maximum(:version) },
110+
format: :json
110111
)
111112
end
112113
end

app/controllers/plan_exports_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ def show_docx
8585
def show_pdf
8686
render pdf: file_name,
8787
margin: @formatting[:margin],
88+
# wkhtmltopdf behavior is based on the OS so force the zoom level
89+
# See 'Gotchas' section of https://github.com/mileszs/wicked_pdf
90+
zoom: 0.78125,
8891
footer: {
8992
center: format(_('Created using %{application_name}. Last modified %{date}'),
9093
application_name: ApplicationService.application_name,

app/javascript/src/utils/accordion.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,23 @@
3131
* </div>
3232
*/
3333
$(() => {
34-
$('body').on('click', '.accordion-controls', (e) => {
34+
$('body').on('click', '.accordion-controls a', (e) => {
3535
e.preventDefault();
3636
const currentTarget = $(e.currentTarget);
3737
const target = $(e.target);
3838
const direction = target.attr('data-toggle-direction');
39+
const parentTargetName = currentTarget.parent().attr('data-parent');
3940
if (direction) {
4041
// Selects all .panel elements where the parent is currentTarget.attr('data-parent') and
4142
// after gets the immediately children whose class selector is panel-collapse
42-
$(`#${currentTarget.attr('data-parent')} > .panel`).children('.panel-collapse').each((i, el) => {
43+
const parentTarget = $(`#${parentTargetName}`).length ? $(`#${parentTargetName}`) : $(`.${parentTargetName}`);
44+
$(parentTarget).find('.panel').find('.panel-collapse').each((i, el) => {
4345
const panelCollapse = $(el);
4446
// Expands or collapses the panel according to the
4547
// direction passed (e.g. show --> expands, hide --> collapses)
4648
if (direction === 'show') {
47-
if (!panelCollapse.hasClass('in')) {
48-
panelCollapse.prev().trigger('click');
49+
if (!panelCollapse.find('.panel-body').attr('data-loaded') || !panelCollapse.hasClass('in')) {
50+
panelCollapse.prev()[0].click();
4951
}
5052
} else {
5153
panelCollapse.collapse(direction);

app/javascript/src/utils/sectionUpdate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ export const updateSectionProgress = (id, numSecAnswers, numSecQuestions) => {
1919

2020
// given a question id find the containing div
2121
// used inconditional questions
22-
export const getQuestionDiv = (id) => $(`#answer-form-${id}`).closest('.row');
22+
export const getQuestionDiv = (id) => $(`#answer-form-${id}`).closest('.question-body');

app/models/concerns/exportable_plan.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,14 @@ def prepare_coversheet
131131
hash
132132
end
133133
# rubocop:enable Metrics/AbcSize
134-
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
135134

136-
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity
135+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
137136
def prepare_coversheet_for_csv(csv, _headings, hash)
138-
csv << [if hash[:attribution].many?
139-
_('Creators: ')
140-
else
141-
_('Creator:')
142-
end, format(_('%{authors}'), authors: hash[:attribution].join(', '))]
137+
csv << if Array(hash[:attribution]).many?
138+
[_('Creators: '), format(_('%{authors}'), authors: Array(hash[:attribution]).join(', '))]
139+
else
140+
[_('Creator:'), format(_('%{authors}'), authors: hash[:attribution])]
141+
end
143142
csv << ['Affiliation: ', format(_('%{affiliation}'), affiliation: hash[:affiliation])]
144143
csv << if hash[:funder].present?
145144
[_('Template: '), format(_('%{funder}'), funder: hash[:funder])]
@@ -161,10 +160,9 @@ def prepare_coversheet_for_csv(csv, _headings, hash)
161160
csv << []
162161
csv << []
163162
end
164-
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity
163+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
165164

166165
# rubocop:disable Metrics/AbcSize, Metrics/BlockLength, Metrics/MethodLength
167-
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
168166
# rubocop:disable Metrics/ParameterLists
169167
def show_section_for_csv(csv, phase, section, headings, unanswered, hash)
170168
section[:questions].each do |question|

app/models/phase.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def num_answers_not_removed(plan)
139139
end
140140

141141
def visibility_allowed?(plan)
142-
value = Rational(num_answered_questions(plan), plan.num_questions) * 100
142+
value = Rational(num_answered_questions(plan), plan.num_questions).to_f * 100
143143
value >= Rails.configuration.x.plans.default_percentage_answered.to_f
144144
end
145145
end

app/policies/department_policy.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ class DepartmentPolicy < ApplicationPolicy
66
# NOTE: @user is the signed_in_user and @record is an instance of Department
77

88
def index?
9-
(@user.can_org_admin? && @user.org.id == @department.org_id) ||
10-
@user.can_super_admin?
9+
@user.can_org_admin? || @user.can_super_admin?
1110
end
1211

1312
def new?

app/views/org_admin/sections/_section.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@
4646
<% end %>
4747
</div>
4848
</div>
49-
</div>
49+
</div>

app/views/org_admin/sections/_section_group.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- TODO: Move this away from using ID attr -->
2-
<div class="panel-group section-group"
2+
<div class="panel-group section-group sections_accordion"
33
data-modifiable="<%= modifiable %>"
44
id="<%= panel_id %>"
55
role="tablist">
@@ -12,4 +12,4 @@
1212
data_parent: panel_id,
1313
draggable: draggable_for_section?(section) } %>
1414
<% end%>
15-
</div>
15+
</div>

0 commit comments

Comments
 (0)