diff --git a/app/controllers/guidances_controller.rb b/app/controllers/guidances_controller.rb
index 90a7051..c21372c 100644
--- a/app/controllers/guidances_controller.rb
+++ b/app/controllers/guidances_controller.rb
@@ -6,8 +6,8 @@
# GET /guidances
def admin_index
authorize Guidance
- @guidances = policy_scope(Guidance)
- @guidance_groups = GuidanceGroup.where(org_id: current_user.org_id)
+ @guidances = Guidance.by_org(current_user.org).includes(:guidance_group, :themes).page(1)
+ @guidance_groups = GuidanceGroup.by_org(current_user.org).page(1)
end
def admin_new
diff --git a/app/controllers/paginable/guidance_groups_controller.rb b/app/controllers/paginable/guidance_groups_controller.rb
new file mode 100644
index 0000000..a6400d1
--- /dev/null
+++ b/app/controllers/paginable/guidance_groups_controller.rb
@@ -0,0 +1,11 @@
+module Paginable
+ class GuidanceGroupsController < ApplicationController
+ include Paginable
+ # /paginable/guidance_groups/index/:page
+ def index
+ authorize(Guidance)
+ paginable_renderise(partial: 'index',
+ scope: GuidanceGroup.by_org(current_user.org))
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/paginable/guidances_controller.rb b/app/controllers/paginable/guidances_controller.rb
new file mode 100644
index 0000000..5887df5
--- /dev/null
+++ b/app/controllers/paginable/guidances_controller.rb
@@ -0,0 +1,11 @@
+module Paginable
+ class GuidancesController < ApplicationController
+ include Paginable
+ # /paginable/guidances/index/:page
+ def index
+ authorize(Guidance)
+ paginable_renderise(partial: 'index',
+ scope: Guidance.by_org(current_user.org).includes(:guidance_group, :themes))
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/paginable/plans_controller.rb b/app/controllers/paginable/plans_controller.rb
index 4df0a06..d691dda 100644
--- a/app/controllers/paginable/plans_controller.rb
+++ b/app/controllers/paginable/plans_controller.rb
@@ -11,4 +11,15 @@
paginable_renderise(partial: 'organisationally_or_publicly_visible',
scope: Plan.organisationally_or_publicly_visible(current_user))
end
+ # GET /paginable/plans/publicly_visible/:page
+ def publicly_visible
+ paginable_renderise(partial: 'publicly_visible',
+ scope: Plan.publicly_visible)
+ end
+ # GET /paginable/plans/org_admin/:page
+ def org_admin
+ raise Pundit::NotAuthorizedError unless current_user.present? && current_user.can_org_admin?
+ paginable_renderise(partial: 'org_admin',
+ scope: current_user.org.plans)
+ end
end
\ No newline at end of file
diff --git a/app/controllers/paginable/templates_controller.rb b/app/controllers/paginable/templates_controller.rb
index a5f69f7..db35139 100644
--- a/app/controllers/paginable/templates_controller.rb
+++ b/app/controllers/paginable/templates_controller.rb
@@ -2,7 +2,7 @@
include Paginable
include TemplateFilter
- # GET /org_admin/templates/all/:page (AJAX)
+ # GET /paginable/templates/all/:page (AJAX)
# -----------------------------------------------------
def all
raise Pundit::NotAuthorizedError unless Paginable::TemplatePolicy.new(current_user).all?
@@ -23,7 +23,7 @@
scopes: hash[:scopes]}
end
- # GET /org_admin/templates/funders/:page (AJAX)
+ # GET /paginable/templates/funders/:page (AJAX)
# -----------------------------------------------------
def funders
raise Pundit::NotAuthorizedError unless Paginable::TemplatePolicy.new(current_user).funders?
@@ -44,7 +44,7 @@
scopes: hash[:scopes] }
end
- # GET /org_admin/templates/orgs/:page (AJAX)
+ # GET /paginable/templates/orgs/:page (AJAX)
# -----------------------------------------------------
def orgs
raise Pundit::NotAuthorizedError unless Paginable::TemplatePolicy.new(current_user).orgs?
@@ -64,4 +64,15 @@
published: published,
scopes: hash[:scopes]}
end
+
+ # GET /paginable/templates/publicly_visible/:page (AJAX)
+ # -----------------------------------------------------
+ def publicly_visible
+ template_ids = Template.families(Org.funder.pluck(:id)).publicly_visible.pluck(:dmptemplate_id) <<
+ Template.where(is_default: true).valid.published.pluck(:dmptemplate_id)
+
+ paginable_renderise(
+ partial: 'publicly_visible',
+ scope: Template.includes(:org).where(dmptemplate_id: template_ids.uniq.flatten).valid.published)
+ end
end
diff --git a/app/controllers/public_pages_controller.rb b/app/controllers/public_pages_controller.rb
index fe8c78a..3077b53 100644
--- a/app/controllers/public_pages_controller.rb
+++ b/app/controllers/public_pages_controller.rb
@@ -4,13 +4,9 @@
# GET template_index
# -----------------------------------------------------
def template_index
- template_ids = Template.where(org_id: Org.funder.pluck(:id), visibility: Template.visibilities[:publicly_visible]).valid.pluck(:dmptemplate_id).uniq << Template.where(is_default: true, published: true).pluck(:dmptemplate_id)
- @templates = []
- template_ids.flatten.each do |tid|
- t = Template.live(tid)
- @templates << t unless t.nil?
- end
- @templates = @templates.sort{|x,y| x.title <=> y.title } if @templates.count > 1
+ template_ids = Template.families(Org.funder.pluck(:id)).publicly_visible.pluck(:dmptemplate_id) <<
+ Template.where(is_default: true).valid.published.pluck(:dmptemplate_id)
+ @templates = Template.includes(:org).where(dmptemplate_id: template_ids.uniq.flatten).valid.published.order(title: :asc).page(1)
end
# GET template_export/:id
@@ -119,7 +115,6 @@
# GET /plans_index
# ------------------------------------------------------------------------------------
def plan_index
- @plans = Plan.publicly_visible
- @plans = @plans.sort{|x,y| x.title <=> y.title } if @plans.count > 1
+ @plans = Plan.publicly_visible.order(:title => :asc).page(1)
end
end
diff --git a/app/models/guidance.rb b/app/models/guidance.rb
index 24c1cc0..4c5bb5c 100644
--- a/app/models/guidance.rb
+++ b/app/models/guidance.rb
@@ -27,7 +27,15 @@
validates :text, presence: {message: _("can't be blank")}
+ # Retrieves every guidance associated to an org
+ scope :by_org, -> (org) {
+ joins(:guidance_group).merge(GuidanceGroup.by_org(org))
+ }
+ scope :search, -> (term) {
+ search_pattern = "%#{term}%"
+ joins(:guidance_group).where("guidances.text LIKE ? OR guidance_groups.name LIKE ?", search_pattern, search_pattern)
+ }
##
# Determine if a guidance is in a group which belongs to a specified organisation
#
@@ -43,20 +51,6 @@
end
##
- # returns all guidance that belongs to a specified organisation
- #
- # @param org_id [Integer] the integer id for an organisation
- # @return [Array] list of guidance
- def self.by_org(org_id)
- org_guidance = []
- # TODO: re-write below querry when guidance_in_group removed from model
- Org.find_by(id: org_id).guidance_groups.each do |group|
- org_guidance += Guidance.where(guidance_group_id: group.id)
- end
- return org_guidance
- end
-
- ##
# returns all templates belgonging to a specified guidance group
#
# @param guidance_group [Integer] the integer id for an guidance_group
diff --git a/app/models/guidance_group.rb b/app/models/guidance_group.rb
index 8974a37..b898ded 100644
--- a/app/models/guidance_group.rb
+++ b/app/models/guidance_group.rb
@@ -22,10 +22,14 @@
#
# What do they do? do they do it efficiently, and do we need them?
-
-
-
-
+ # Retrieves every guidance group associated to an org
+ scope :by_org, -> (org) {
+ where(org_id: org.id)
+ }
+ scope :search, -> (term) {
+ search_pattern = "%#{term}%"
+ where("name LIKE ?", search_pattern)
+ }
##
# Converts the current guidance group to a string containing the display name.
diff --git a/app/models/plan.rb b/app/models/plan.rb
index 3c0cec8..9aa7c51 100644
--- a/app/models/plan.rb
+++ b/app/models/plan.rb
@@ -52,7 +52,7 @@
# Scope queries
# Note that in ActiveRecord::Enum the mappings are exposed through a class method with the pluralized attribute name (e.g visibilities rather than visibility)
- scope :publicly_visible, -> { where(:visibility => visibilities[:publicly_visible]).order(:title => :asc) }
+ scope :publicly_visible, -> { includes(:template).where(:visibility => visibilities[:publicly_visible]) }
# Retrieves any plan in which the user has an active role and it is not a reviewer
scope :active, -> (user) {
diff --git a/app/models/template.rb b/app/models/template.rb
index c14d83f..0527bf2 100644
--- a/app/models/template.rb
+++ b/app/models/template.rb
@@ -47,7 +47,7 @@
Template.where(templates: { is_default: is_default }).valid().published()
}
- scope :publicly_visible, -> { where(:visibility => Template.visibilities[:publicly_visible]).order(:title => :asc) }
+ scope :publicly_visible, -> { where(:visibility => Template.visibilities[:publicly_visible]) }
# Retrieves template with distinct dmptemplate_id that are valid (e.g. migrated false) and customization_of is nil. Note,
# if organisation ids are passed, the query will filter only those distinct dmptemplate_ids for those organisations
diff --git a/app/policies/guidance_policy.rb b/app/policies/guidance_policy.rb
index 3bcc0d1..09cf419 100644
--- a/app/policies/guidance_policy.rb
+++ b/app/policies/guidance_policy.rb
@@ -19,6 +19,10 @@
user.can_modify_guidance? && guidance.in_group_belonging_to?(user.org_id)
end
+ def index?
+ admin_index?
+ end
+
def admin_index?
user.can_modify_guidance?
end
@@ -58,10 +62,4 @@
def update_questions?
user.can_modify_guidance?
end
-
- class Scope < Scope
- def resolve
- scope = Guidance.includes(:guidance_group, :themes).by_org(user.org_id)
- end
- end
end
\ No newline at end of file
diff --git a/app/views/guidances/admin_index.html.erb b/app/views/guidances/admin_index.html.erb
index 93139ef..3cecb9b 100644
--- a/app/views/guidances/admin_index.html.erb
+++ b/app/views/guidances/admin_index.html.erb
@@ -13,75 +13,11 @@
<%= _('Guidance group list') %>
- <% if @guidance_groups.length > 0 then%>
-
-
-
- <% if @guidance_groups.length > TABLE_FILTER_MIN_ROWS %>
-
-
- <%= render(partial: "shared/table_filter",
- locals: {path: admin_index_guidance_path(current_user.org_id), placeholder: _('Filter guidance groups')}) %>
-
-
- <% end %>
-
- <%= _('Name') %>
- <%= _('Status') %>
- <%= _('Optional subset') %>
- <%= _('Last updated') %>
- <%= _('Actions') %>
-
-
-
- <% !@guidance_groups.each do |guidance_gr| %>
-
-
- <%= guidance_gr.name %>
-
-
- <% if guidance_gr.published.nil? || guidance_gr.published == false then%>
- <%= _('Unpublished')%>
- <% else %>
- <%= _('Published')%>
- <% end %>
-
-
- <% if guidance_gr.optional_subset.nil? || guidance_gr.optional_subset == false then%>
- <%= _('No')%>
- <% else %>
- <%= _('Yes')%>
- <% end %>
-
-
- <%= l guidance_gr.updated_at.to_date, formats: :short %>
-
-
-
-
- <%= _('Actions') %>
-
-
-
-
-
-
- <% end %>
-
-
-
- <%end%>
-
+ <%= paginable_renderise(
+ partial: '/paginable/guidance_groups/index',
+ controller: 'paginable/guidance_groups',
+ action: 'index',
+ scope: @guidance_groups) %>
@@ -96,91 +32,11 @@
- <% if @guidances.length > 0 then%>
-
-
-
- <% if @guidances.length > TABLE_FILTER_MIN_ROWS %>
-
- <%= render(partial: "shared/table_filter",
- locals: {path: admin_index_guidance_path(current_user.org_id), placeholder: _('Filter guidance')}) %>
-
- <% end %>
-
- <%= _('Text') %>
- <%= _('Themes') %>
- <%= _('Guidance group') %>
- <%= _('Status') %>
- <%= _('Last updated') %>
- <%= _('Actions') %>
-
-
-
- <% @guidances.each do |guidance| %>
- <% if guidance.in_group_belonging_to?(current_user.org_id) then %>
-
-
- <%= guidance.text.html_safe%>
-
- <% if guidance.themes.present? then %>
-
- <% guidance.themes.each do |th| %>
- <%= th.title %>
- <% end %>
-
- <% else %>
-
- -
-
- <% end %>
- <% if guidance.guidance_group.present? then %>
-
- <%= guidance.guidance_group.name %>
-
- <% else %>
-
- -
-
- <% end %>
-
- <% if guidance.published.nil? || guidance.published == false then%>
- <%= _('Unpublished')%>
- <% else %>
- <%= _('Published')%>
- <% end %>
-
-
- <%= l guidance.updated_at.to_date, formats: :short %>
-
-
-
-
- <%= _('Actions') %>
-
-
-
-
-
-
- <% end %>
- <% end %>
-
-
-
- <% end %>
+ <%= paginable_renderise(
+ partial: '/paginable/guidances/index',
+ controller: 'paginable/guidances',
+ action: 'index',
+ scope: @guidances) %>
<%= _('Create guidance') %>
diff --git a/app/views/layouts/_paginable.html.erb b/app/views/layouts/_paginable.html.erb
index dc5ab8b..c42df21 100644
--- a/app/views/layouts/_paginable.html.erb
+++ b/app/views/layouts/_paginable.html.erb
@@ -28,14 +28,14 @@
<% if total > Kaminari.config.default_per_page %>
<% if searchable? %>
- <% if paginable %>
+ <% if paginable %>
<%= paginable_search_link(_('View all search results'), 'ALL') %>
+ <% else %>
+ <%= paginable_search_link(_('View less search results'), 1) %>
+ <% end %>
<%= link_to(_('Clear search results'), url_for(controller: controller, action: action, page: 1), { 'data-remote': true, class: 'clear' }) %>
- <% else %>
- <%= paginable_search_link(_('View less search results'), 1) %>
- <% end %>
<% else %>
<% if paginable %>
<%= link_to(_('View all'), url_for(controller: controller, action: action, page: 'ALL'), { 'data-remote': true }) %>
diff --git a/app/views/org_admin/plans/index.html.erb b/app/views/org_admin/plans/index.html.erb
index 6f3cdc5..ebe589e 100644
--- a/app/views/org_admin/plans/index.html.erb
+++ b/app/views/org_admin/plans/index.html.erb
@@ -33,47 +33,13 @@
<% end %>
-
<% if @plans.length > 0 %>
<%= link_to _('Download plans'), org_admin_download_plans_path(format: :csv), target: '_blank', class: 'btn btn-default pull-right' %>
-
-
-
- <% if @plans.length > TABLE_FILTER_MIN_ROWS %>
-
-
- <%= render(partial: "shared/table_filter",
- locals: { placeholder: _('Filter plans')}) %>
-
-
- <% end %>
-
- <%= _('Project Title') %>
- <%= _('Template') %>
- <%= _('Organisation') %>
- <%= _('Owner') %>
- <%= _('Updated') %>
- <%= _('Visibility') %>
-
-
-
- <% @plans.each do |plan| %>
-
-
- <%= link_to "#{plan.title.length > 60 ? "#{plan.title[0..59]} ..." : plan.title}", plan_path(plan) %>
-
- <%= plan.template.title %>
- <%= plan.users.first.org.name %>
- <%= plan.users.first.name(false) %>
- <%= l(plan.latest_update.to_date, formats: :short) %>
-
- <%= plan.visibility === 'is_test' ? _('Test') : raw(display_visibility(plan.visibility)) %>
-
-
- <% end %>
-
-
-
+ <%= paginable_renderise(
+ partial: '/paginable/plans/org_admin',
+ controller: 'paginable/plans',
+ action: 'org_admin',
+ scope: @plans) %>
<% end %>
diff --git a/app/views/paginable/guidance_groups/_index.html.erb b/app/views/paginable/guidance_groups/_index.html.erb
new file mode 100644
index 0000000..9f8e918
--- /dev/null
+++ b/app/views/paginable/guidance_groups/_index.html.erb
@@ -0,0 +1,57 @@
+
+
+
+
+ <%= _('Name') %>
+ <%= _('Status') %> <%= paginable_sort_link('published') %>
+ <%= _('Optional subset') %> <%= paginable_sort_link('optional_subset') %>
+ <%= _('Last updated') %> <%= paginable_sort_link('updated_at') %>
+ <%= _('Actions') %>
+
+
+
+ <% scope.each do |guidance_gr| %>
+
+ <%= guidance_gr.name %>
+
+ <% if guidance_gr.published.nil? || guidance_gr.published == false %>
+ <%= _('Unpublished')%>
+ <% else %>
+ <%= _('Published')%>
+ <% end %>
+
+
+ <% if guidance_gr.optional_subset.nil? || guidance_gr.optional_subset == false %>
+ <%= _('No')%>
+ <% else %>
+ <%= _('Yes')%>
+ <% end %>
+
+ <%= l guidance_gr.updated_at.to_date, formats: :short %>
+
+
+
+ <%= _('Actions') %>
+
+
+
+
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/paginable/guidances/_index.html.erb b/app/views/paginable/guidances/_index.html.erb
new file mode 100644
index 0000000..98761b9
--- /dev/null
+++ b/app/views/paginable/guidances/_index.html.erb
@@ -0,0 +1,71 @@
+
+
+
+
+ <%= _('Text') %> <%= paginable_sort_link('guidances.text') %>
+ <%= _('Themes') %>
+ <%= _('Guidance group') %> <%= paginable_sort_link('guidance_groups.name') %>
+ <%= _('Status') %> <%= paginable_sort_link('guidances.published') %>
+ <%= _('Last updated') %> <%= paginable_sort_link('guidances.updated_at') %>
+ <%= _('Actions') %>
+
+
+
+ <% scope.each do |guidance| %>
+ <% if guidance.in_group_belonging_to?(current_user.org_id) %>
+
+ <%= guidance.text.html_safe %>
+ <% if guidance.themes.present? %>
+
+ <% guidance.themes.each do |th| %>
+ <%= th.title %>
+ <% end %>
+
+ <% else %>
+ -
+ <% end %>
+ <% if guidance.guidance_group.present? %>
+ <%= guidance.guidance_group.name %>
+ <% else %>
+ -
+ <% end %>
+
+ <% if guidance.published.nil? || guidance.published == false %>
+ <%= _('Unpublished')%>
+ <% else %>
+ <%= _('Published')%>
+ <% end %>
+
+
+ <%= l guidance.updated_at.to_date, formats: :short %>
+
+
+
+
+ <%= _('Actions') %>
+
+
+
+
+
+ <% end %>
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/paginable/plans/_org_admin.html.erb b/app/views/paginable/plans/_org_admin.html.erb
new file mode 100644
index 0000000..79d27af
--- /dev/null
+++ b/app/views/paginable/plans/_org_admin.html.erb
@@ -0,0 +1,30 @@
+
+
+
+
+ <%= _('Project Title') %> <%= paginable_sort_link('plans.title') %>
+ <%= _('Template') %> <%= paginable_sort_link('templates.title') %>
+ <%= _('Organisation') %>
+ <%= _('Owner') %>
+ <%= _('Updated') %> <%= paginable_sort_link('plans.updated_at') %>
+ <%= _('Visibility') %>
+
+
+
+ <% scope.each do |plan| %>
+
+
+ <%= link_to "#{plan.title.length > 60 ? "#{plan.title[0..59]} ..." : plan.title}", plan_path(plan) %>
+
+ <%= plan.template.title %>
+ <%= plan.users.first.org.name %>
+ <%= plan.users.first.name(false) %>
+ <%= l(plan.latest_update.to_date, formats: :short) %>
+
+ <%= plan.visibility === 'is_test' ? _('Test') : raw(display_visibility(plan.visibility)) %>
+
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/paginable/plans/_organisationally_or_publicly_visible.html.erb b/app/views/paginable/plans/_organisationally_or_publicly_visible.html.erb
index 1aacad8..a46c18f 100644
--- a/app/views/paginable/plans/_organisationally_or_publicly_visible.html.erb
+++ b/app/views/paginable/plans/_organisationally_or_publicly_visible.html.erb
@@ -7,7 +7,7 @@
-
+
<%= _('Project Title') %> <%= paginable_sort_link('plans.title') %>
diff --git a/app/views/paginable/plans/_privately_visible.html.erb b/app/views/paginable/plans/_privately_visible.html.erb
index fbf9789..eab6346 100644
--- a/app/views/paginable/plans/_privately_visible.html.erb
+++ b/app/views/paginable/plans/_privately_visible.html.erb
@@ -1,5 +1,5 @@
-
+
<%= _('Project Title') %> <%= paginable_sort_link('plans.title') %>
diff --git a/app/views/paginable/plans/_publicly_visible.html.erb b/app/views/paginable/plans/_publicly_visible.html.erb
new file mode 100644
index 0000000..fe147b9
--- /dev/null
+++ b/app/views/paginable/plans/_publicly_visible.html.erb
@@ -0,0 +1,26 @@
+
+
+
+
+ <%= _('Project Title') %> <%= paginable_sort_link('plans.title') %>
+ <%= _('Template') %> <%= paginable_sort_link('templates.title') %>
+ <%= _('Institution') %>
+ <%= _('Owner') %>
+ <%= _('Download') %>
+
+
+
+ <% scope.each do |plan| %>
+
+ <%= plan.title %>
+ <%= plan.template.title %>
+ <%= (plan.owner.nil? || plan.owner.org.nil? ? _('Not Applicable') : plan.owner.org.name) %>
+ <%= (plan.owner.nil? ? _('Unknown') : plan.owner.name(false)) %>
+
+ <%= link_to _('PDF'), plan_export_path(plan, format: :pdf), class: "dmp_table_link", target: '_blank' %>
+
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/paginable/templates/_all.html.erb b/app/views/paginable/templates/_all.html.erb
index 1a4dabd..66a2ab1 100644
--- a/app/views/paginable/templates/_all.html.erb
+++ b/app/views/paginable/templates/_all.html.erb
@@ -1,7 +1,7 @@
<% # locals: templates, current_org %>
-
+
<% if scopes.present? %>
diff --git a/app/views/paginable/templates/_funders.html.erb b/app/views/paginable/templates/_funders.html.erb
index a937784..0acf494 100644
--- a/app/views/paginable/templates/_funders.html.erb
+++ b/app/views/paginable/templates/_funders.html.erb
@@ -1,7 +1,7 @@
<% # locals: templates, current_org %>
-
+
<% if scopes.present? %>
diff --git a/app/views/paginable/templates/_orgs.html.erb b/app/views/paginable/templates/_orgs.html.erb
index 6adab77..c3736e8 100644
--- a/app/views/paginable/templates/_orgs.html.erb
+++ b/app/views/paginable/templates/_orgs.html.erb
@@ -1,7 +1,7 @@
<% # locals: templates, current_org %>
-
+
<% if scopes.present? %>
diff --git a/app/views/paginable/templates/_publicly_visible.html.erb b/app/views/paginable/templates/_publicly_visible.html.erb
new file mode 100644
index 0000000..013fecd
--- /dev/null
+++ b/app/views/paginable/templates/_publicly_visible.html.erb
@@ -0,0 +1,33 @@
+
+
+
+
+ <%= _('Template Name') %> <%= paginable_sort_link('templates.title') %>
+ <%= _('Download') %>
+ <%= _('Organisation Name') %> <%= paginable_sort_link('orgs.name') %>
+ <%= _('Last Updated') %> <%= paginable_sort_link('templates.updated_at') %>
+ <%= _('Funder Links') %>
+ <%= _('Sample Plans') %><%= _('(if available)') %>
+
+
+
+ <% scope.each do |template| %>
+
+ <%= template.title %>
+
+ <%= link_to _('DOCX'), template_export_path(template.dmptemplate_id, format: :docx), target: '_blank' %>
+ <%= link_to _('PDF'), template_export_path(template.dmptemplate_id, format: :pdf), target: '_blank' %>
+
+ <%= template.org.name %>
+ <%= l(template.updated_at.to_date, formats: :short) %>
+
+ <%= raw links_to_a_elements(template.links['funder'], ' ') %>
+
+
+ <%= raw links_to_a_elements(template.links['sample_plan'], ' ') %>
+
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/paginable/themes/_index.html.erb b/app/views/paginable/themes/_index.html.erb
index 7fc335f..54c4610 100644
--- a/app/views/paginable/themes/_index.html.erb
+++ b/app/views/paginable/themes/_index.html.erb
@@ -1,4 +1,4 @@
-
+
<%= _('Name') %> <%= paginable_sort_link('title') %>
diff --git a/app/views/paginable/users/_index.html.erb b/app/views/paginable/users/_index.html.erb
index 3ef5b2e..5a7daf9 100644
--- a/app/views/paginable/users/_index.html.erb
+++ b/app/views/paginable/users/_index.html.erb
@@ -1,7 +1,7 @@
-
+
<%= _('Name') %> <%= paginable_sort_link('firstname') %>
diff --git a/app/views/public_pages/plan_index.html.erb b/app/views/public_pages/plan_index.html.erb
index 5ef3a08..3ba73bd 100644
--- a/app/views/public_pages/plan_index.html.erb
+++ b/app/views/public_pages/plan_index.html.erb
@@ -17,40 +17,11 @@
<% if @plans.count > 0 %>
-
-
-
- <% if @plans.count > TABLE_FILTER_MIN_ROWS %>
-
-
- <%= render(partial: "shared/table_filter",
- locals: {path: public_plans_path, placeholder: _('Filter plans')}) %>
-
-
- <% end %>
-
- <%= _('Project Title') %>
- <%= _('Template') %>
- <%= _('Institution') %>
- <%= _('Owner') %>
- <%= _('Download') %>
-
-
-
- <% @plans.each do |plan| %>
-
- <%= plan.title %>
- <%= plan.template.title %>
- <%= (plan.owner.nil? || plan.owner.org.nil? ? _('Not Applicable') : plan.owner.org.name) %>
- <%= (plan.owner.nil? ? _('Unknown') : plan.owner.name(false)) %>
-
- <%= link_to _('PDF'), plan_export_path(plan, format: :pdf), class: "dmp_table_link", target: '_blank' %>
-
-
- <% end %>
-
-
-
+ <%= paginable_renderise(
+ partial: '/paginable/plans/publicly_visible',
+ controller: 'paginable/plans',
+ action: 'publicly_visible',
+ scope: @plans) %>
<% end %>
\ No newline at end of file
diff --git a/app/views/public_pages/template_index.html.erb b/app/views/public_pages/template_index.html.erb
index 99e8d52..86ed861 100644
--- a/app/views/public_pages/template_index.html.erb
+++ b/app/views/public_pages/template_index.html.erb
@@ -1,7 +1,6 @@
<%= raw _('DMP Templates') %>
-
<% if @templates.count > 0 %>
<%= _('Templates are provided by a funder, an institution, or a trusted party.') %>
<% else %>
@@ -9,51 +8,14 @@
<% end %>
-
<% if @templates.count > 0 %>
-
-
-
- <% if @templates.count > TABLE_FILTER_MIN_ROWS %>
-
-
- <%= render(partial: "shared/table_filter",
- locals: {path: public_templates_path, placeholder: _('Filter templates')}) %>
-
-
- <% end %>
-
- <%= _('Template Name') %>
- <%= _('Download') %>
- <%= _('Organisation Name') %>
- <%= _('Last Updated') %>
- <%= _('Funder Links') %>
- <%= _('Sample Plans') %><%= _('(if available)') %>
-
-
-
- <% @templates.each do |template| %>
-
- <%= template.title %>
-
- <%= link_to _('DOCX'), template_export_path(template.dmptemplate_id, format: :docx), target: '_blank' %>
-
- <%= link_to _('PDF'), template_export_path(template.dmptemplate_id, format: :pdf), target: '_blank' %>
-
- <%= template.org.name %>
- <%= l(template.updated_at.to_date, formats: :short) %>
-
- <%= raw links_to_a_elements(template.links['funder'], ' ') %>
-
-
- <%= raw links_to_a_elements(template.links['sample_plan'], ' ') %>
-
-
- <% end %>
-
-
+ <%= paginable_renderise(
+ partial: '/paginable/templates/publicly_visible',
+ controller: 'paginable/templates',
+ action: 'publicly_visible',
+ scope: @templates) %>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/admin_grant_permissions.html.erb b/app/views/users/admin_grant_permissions.html.erb
new file mode 100644
index 0000000..9ba89a3
--- /dev/null
+++ b/app/views/users/admin_grant_permissions.html.erb
@@ -0,0 +1,57 @@
+<% namesHash = name_and_text %>
+
+
+
<%= _('Edit User Privileges') %>
+
+
+
+
+
+ <%= form_tag( admin_update_permissions_user_path(@user), method: :put) do %>
+
+
+
+
+ <%= _('Name') %>
+
+ <% @perms.each do |perm| %>
+ <% case perm.name when 'grant_permissions' %>
+
+ <%= namesHash[perm.name.to_sym] %>
+
+ <% when 'modify_templates' %>
+
+ <%= namesHash[perm.name.to_sym] %>
+
+ <% when 'modify_guidance' %>
+
+ <%= namesHash[perm.name.to_sym] %>
+
+ <% when 'use_api' %>
+
+ <%= namesHash[perm.name.to_sym] %>
+
+ <% when 'change_org_details' %>
+
+ <%= namesHash[perm.name.to_sym] %>
+
+ <% end %>
+ <% end %>
+
+
+
+
+ <%= @user.name(false) %>
+ <% @perms.each do |perm| %>
+ <%= check_box_tag "perm_ids[]", perm.id, @user.perms.include?(perm) %>
+ <% end %>
+
+
+
+
+
+ <%= submit_tag _('Save'), class: "btn btn-primary" %>
+
+ <% end %>
+
+
diff --git a/config/routes.rb b/config/routes.rb
index 9c126c9..0dfaa50 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -249,6 +249,8 @@
resources :plans, only: [] do
get 'privately_visible/:page', action: :privately_visible, on: :collection, as: :privately_visible
get 'organisationally_or_publicly_visible/:page', action: :organisationally_or_publicly_visible, on: :collection, as: :organisationally_or_publicly_visible
+ get 'publicly_visible/:page', action: :publicly_visible, on: :collection, as: :publicly_visible
+ get 'org_admin/:page', action: :org_admin, on: :collection, as: :org_admin
end
# Paginable actions for users
resources :users, only: [] do
@@ -258,12 +260,20 @@
resources :themes, only: [] do
get 'index/:page', action: :index, on: :collection, as: :index
end
-
# Paginable actions for templates
resources :templates, only: [] do
get 'all/:page', action: :all, on: :collection, as: :all
get 'funders/:page', action: :funders, on: :collection, as: :funders
get 'orgs/:page', action: :orgs, on: :collection, as: :orgs
+ get 'publicly_visible/:page', action: :publicly_visible, on: :collection, as: :publicly_visible
+ end
+ # Paginable actions for guidances
+ resources :guidances, only: [] do
+ get 'index/:page', action: :index, on: :collection, as: :index
+ end
+ # Paginable actions for guidance_groups
+ resources :guidance_groups, only: [] do
+ get 'index/:page', action: :index, on: :collection, as: :index
end
end
diff --git a/test/integration/paginable_flows_test.rb b/test/integration/paginable_flows_test.rb
index a2e2af2..1ec0ea9 100644
--- a/test/integration/paginable_flows_test.rb
+++ b/test/integration/paginable_flows_test.rb
@@ -44,6 +44,10 @@
refute_nil(link_view_less_search_results)
assert_equal(link_view_less_search_results.content, _('View less search results'))
+ link_clear_search_results = css_select('a[href$="/1"]').first
+ refute_nil(link_clear_search_results)
+ assert_equal(link_clear_search_results.content, _('Clear search results'))
+
# Fails if pagination nav is found
assert_empty(css_select('nav.pagination'))
end
diff --git a/test/unit/guidance_test.rb b/test/unit/guidance_test.rb
index 9ef04bf..e67b289 100644
--- a/test/unit/guidance_test.rb
+++ b/test/unit/guidance_test.rb
@@ -37,9 +37,9 @@
# ---------------------------------------------------
test "retrieves guidance by org" do
org = Org.create!(name: 'Tester 123', abbreviation: 'TEST', org_type: 1, links: {"org":[]})
- assert Guidance.by_org(org.id).empty?, "expected the newly created org to have no guidance"
+ assert Guidance.by_org(org).empty?, "expected the newly created org to have no guidance"
- assert_not Guidance.by_org(@user.org.id).empty?, "expected the org to have guidance"
+ assert_not Guidance.by_org(@user.org).empty?, "expected the org to have guidance"
end
# ---------------------------------------------------