Skip to content

Commit 02f1dfb

Browse files
authored
Merge pull request #2981 from DMPRoadmap/development
Merging latest development into master
2 parents 62432b9 + c707405 commit 02f1dfb

File tree

84 files changed

+1748
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+1748
-217
lines changed

.github/workflows/mysql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
4343
# Try to retrieve the gems from the cache
4444
- name: 'Cache Gems'
45-
uses: actions/cache@v1
45+
uses: actions/cache@v2.1.5
4646
with:
4747
path: vendor/bundle
4848
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
@@ -62,7 +62,7 @@ jobs:
6262
6363
# Try to retrieve the yarn JS dependencies from the cache
6464
- name: 'Cache Yarn Packages'
65-
uses: actions/cache@v1
65+
uses: actions/cache@v2.1.5
6666
with:
6767
path: node_modules/
6868
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

.github/workflows/postgres.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
6060
# Try to retrieve the gems from the cache
6161
- name: 'Cache Gems'
62-
uses: actions/cache@v1
62+
uses: actions/cache@v2.1.5
6363
with:
6464
path: vendor/bundle
6565
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
@@ -79,7 +79,7 @@ jobs:
7979
8080
# Try to retrieve the yarn JS dependencies from the cache
8181
- name: 'Cache Yarn Packages'
82-
uses: actions/cache@v1
82+
uses: actions/cache@v2.1.5
8383
with:
8484
path: node_modules/
8585
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

app/assets/images/spinner.gif

31.9 KB
Loading
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.spinner-border {
2+
position: fixed;
3+
top: 48%;
4+
left: 43%;
5+
}
6+
7+
.spinner-border img {
8+
height: 80px;
9+
width: 80px;
10+
}

app/controllers/api/v0/plans_controller.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ def index
6767
params[:per_page] = max_pages if params[:per_page].to_i > max_pages
6868
end
6969

70-
@plans = @user.org.plans.includes([{ roles: :user }, { answers: :question_options },
70+
# Get all the Org Admin plans
71+
org_admin_plans = @user.org.org_admin_plans
72+
@plans = org_admin_plans.includes([{ roles: :user }, { answers: :question_options },
7173
template: [{ phases: {
7274
sections: { questions: %i[question_format themes] }
7375
} }, :org]])

app/controllers/concerns/paginable.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module Paginable
3737
# one approach to just include everything in the double splat `**options` param
3838

3939
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/ParameterLists
40-
def paginable_renderise(partial: nil, controller: nil, action: nil,
40+
def paginable_renderise(partial: nil, template: nil, controller: nil, action: nil,
4141
path_params: {}, query_params: {}, scope: nil,
4242
locals: {}, **options)
4343
unless scope.is_a?(ActiveRecord::Relation)
@@ -50,6 +50,7 @@ def paginable_renderise(partial: nil, controller: nil, action: nil,
5050
# Default options
5151
@paginable_options = {}.merge(options)
5252
@paginable_options[:view_all] = options.fetch(:view_all, true)
53+
@paginable_options[:remote] = options.fetch(:remote, true)
5354
# Assignment for paginable_params based on arguments passed to the method
5455
@args = paginable_params.to_h
5556
@args[:controller] = controller if controller
@@ -72,14 +73,17 @@ def paginable_renderise(partial: nil, controller: nil, action: nil,
7273
locals = locals.merge(
7374
scope: @refined_scope,
7475
paginable_params: @args,
75-
search_term: @args[:search]
76+
search_term: @args[:search],
77+
remote: @paginable_options[:remote]
7678
)
7779
# If this was an ajax call then render as JSON
7880
if options[:format] == :json
7981
render json: { html: render_to_string(layout: "/layouts/paginable",
8082
partial: partial, locals: locals) }
81-
else
83+
elsif partial.present?
8284
render(layout: "/layouts/paginable", partial: partial, locals: locals)
85+
else
86+
render(template: template, locals: locals)
8387
end
8488
end
8589
end
@@ -104,7 +108,7 @@ def paginable_sort_link(sort_field)
104108
sort_link_name(sort_field),
105109
sort_link_url(sort_field),
106110
class: "paginable-action",
107-
data: { remote: true },
111+
data: { remote: @paginable_options[:remote] },
108112
aria: { label: sort_field }
109113
)
110114
end

app/controllers/org_admin/plans_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def index
1515

1616
@super_admin = current_user.can_super_admin?
1717
@clicked_through = params[:click_through].present?
18-
@plans = @super_admin ? Plan.all.page(1) : current_user.org.plans.page(1)
18+
@plans = @super_admin ? Plan.all.page(1) : current_user.org.org_admin_plans.page(1)
1919
end
2020

2121
# GET org_admin/plans/:id/feedback_complete
@@ -61,7 +61,7 @@ def download_plans
6161

6262
plans = CSV.generate do |csv|
6363
csv << header_cols
64-
org.plans.includes(template: :org).order(updated_at: :desc).each do |plan|
64+
org.org_admin_plans.includes(template: :org).order(updated_at: :desc).each do |plan|
6565
csv << [
6666
plan.title.to_s,
6767
plan.template.title.to_s,

app/controllers/paginable/plans_controller.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ def organisationally_or_publicly_visible
3434

3535
# GET /paginable/plans/publicly_visible/:page
3636
def publicly_visible
37-
paginable_renderise(
38-
partial: "publicly_visible",
39-
scope: Plan.publicly_visible.includes(:template),
40-
query_params: { sort_field: "plans.updated_at", sort_direction: :desc },
41-
format: :json
42-
)
37+
# We want the pagination/sort/search to be retained in the URL so redirect instead
38+
# of processing this as a JSON
39+
paginable_params = params.permit(:page, :search, :sort_field, :sort_direction)
40+
redirect_to public_plans_path(paginable_params.to_h)
4341
end
4442

4543
# GET /paginable/plans/org_admin/:page
@@ -49,7 +47,7 @@ def org_admin
4947
# check if current user if super_admin
5048
@super_admin = current_user.can_super_admin?
5149
@clicked_through = params[:click_through].present?
52-
plans = @super_admin ? Plan.all : current_user.org.plans
50+
plans = @super_admin ? Plan.all : current_user.org.org_admin_plans
5351
plans = plans.joins(:template, roles: [user: :org]).where(Role.creator_condition)
5452

5553
paginable_renderise(

app/controllers/paginable/templates_controller.rb

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,10 @@ def customisable
8585
# GET /paginable/templates/publicly_visible/:page (AJAX)
8686
# -----------------------------------------------------
8787
def publicly_visible
88-
templates = Template.live(Template.families(Org.funder.pluck(:id)).pluck(:family_id))
89-
.publicly_visible.pluck(:id) <<
90-
Template.where(is_default: true).unarchived.published.pluck(:id)
91-
paginable_renderise(
92-
partial: "publicly_visible",
93-
scope: Template.joins(:org)
94-
.includes(:org)
95-
.where(id: templates.uniq.flatten)
96-
.published,
97-
query_params: { sort_field: "templates.title", sort_direction: :asc },
98-
format: :json
99-
)
88+
# We want the pagination/sort/search to be retained in the URL so redirect instead
89+
# of processing this as a JSON
90+
paginable_params = params.permit(:page, :search, :sort_field, :sort_direction)
91+
redirect_to public_templates_path(paginable_params.to_h)
10092
end
10193

10294
# GET /paginable/templates/:id/history/:page (AJAX)

app/controllers/plans_controller.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def create
124124
elsif !@plan.template.customization_of.nil?
125125
# We used a customized version of the the funder template
126126
# rubocop:disable Layout/LineLength
127-
msg += " #{_('This plan is based on the')} #{@plan.funder&.name}: '#{@plan.template.title}' #{_('template with customisations by the')} #{plan_params[:org_name]}"
127+
msg += " #{_('This plan is based on the')} #{@plan.funder&.name}: '#{@plan.template.title}' #{_('template with customisations by the')} #{@plan.template.org.name}"
128128
# rubocop:enable Layout/LineLength
129129
else
130130
# We used the specified org's or funder's template
@@ -219,7 +219,16 @@ def show
219219
# doing this when we refactor the Plan editing UI
220220
# GET /plans/:plan_id/phases/:id/edit
221221
def edit
222-
plan = Plan.includes({ template: { phases: { sections: :questions } } }, { answers: :notes })
222+
plan = Plan.includes(
223+
{ template: {
224+
phases: {
225+
sections: {
226+
questions: %i[question_format question_options annotations themes]
227+
}
228+
}
229+
} },
230+
{ answers: :notes }
231+
)
223232
.find(params[:id])
224233
authorize plan
225234
phase_id = params[:phase_id].to_i
@@ -258,7 +267,7 @@ def update
258267

259268
if @plan.update(attrs) # _attributes(attrs)
260269
format.html do
261-
redirect_to plan_contributors_path(@plan),
270+
redirect_to plan_path(@plan),
262271
notice: success_message(@plan, _("saved"))
263272
end
264273
format.json do
@@ -293,7 +302,7 @@ def share
293302
@plan = Plan.find(params[:id])
294303
if @plan.present?
295304
authorize @plan
296-
@plan_roles = @plan.roles
305+
@plan_roles = @plan.roles.where(active: true)
297306
else
298307
redirect_to(plans_path)
299308
end
@@ -306,7 +315,7 @@ def request_feedback
306315
@plan = Plan.find(params[:id])
307316
if @plan.present?
308317
authorize @plan
309-
@plan_roles = @plan.roles
318+
@plan_roles = @plan.roles.where(active: true)
310319
else
311320
redirect_to(plans_path)
312321
end

0 commit comments

Comments
 (0)