diff --git a/app/controllers/form_submissions_controller.rb b/app/controllers/form_submissions_controller.rb index 1f4b8b3028..67e180197e 100644 --- a/app/controllers/form_submissions_controller.rb +++ b/app/controllers/form_submissions_controller.rb @@ -1,4 +1,14 @@ class FormSubmissionsController < ApplicationController + def index + authorize! FormSubmission + submissions = FormSubmission.includes(:form, :event, :person) + if params[:person_id].present? + submissions = submissions.where(person_id: params[:person_id]) + @person = Person.find_by(id: params[:person_id]) + end + @form_submissions = submissions.order(created_at: :desc) + end + def show @form_submission = FormSubmission.find(params[:id]) authorize! @form_submission diff --git a/app/controllers/grants_controller.rb b/app/controllers/grants_controller.rb index f45627106e..7c0376929a 100644 --- a/app/controllers/grants_controller.rb +++ b/app/controllers/grants_controller.rb @@ -4,10 +4,14 @@ class GrantsController < ApplicationController def index authorize! - @grants = authorized_scope(Grant.all) - .includes(:donor, scholarships: { allocation: :allocatable }) - .by_deadline - .page(params[:page]) + grants = authorized_scope(Grant.all) + .includes(:donor, scholarships: { allocation: :allocatable }) + .by_deadline + if params[:donor_id].present? && Grant::DONOR_TYPES.include?(params[:donor_type]) + grants = grants.where(donor_id: params[:donor_id], donor_type: params[:donor_type]) + @donor = grants.first&.donor + end + @grants = grants.page(params[:page]) track_index_intent(Grant, @grants, params) end diff --git a/app/controllers/scholarships_controller.rb b/app/controllers/scholarships_controller.rb index 2ffae041a9..8424563c09 100644 --- a/app/controllers/scholarships_controller.rb +++ b/app/controllers/scholarships_controller.rb @@ -13,6 +13,10 @@ def index { grant: :donor }, { recipient: [ { affiliations: { organization: :addresses } }, { event_registrations: :event } ] } ) + if params[:recipient_id].present? + scholarships = scholarships.where(recipient_id: params[:recipient_id]) + @recipient = Person.find_by(id: params[:recipient_id]) + end @funder_groups = ScholarshipsGrouping.new(scholarships).funder_groups @scholarships_count = scholarships.size end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5d84242875..666c4f6ace 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -256,7 +256,11 @@ def form_field_option_source(field) people: "fa-user", organizations: "fa-building", workshops: "fa-chalkboard-user", - resources: "fa-book" + resources: "fa-book", + scholarships: "fa-graduation-cap", + notifications: "fa-bell", + grants: "fa-hand-holding-dollar", + form_submissions: "fa-file-signature" }.freeze # Themed card-style link to a filtered index. The collection drives the diff --git a/app/policies/form_submission_policy.rb b/app/policies/form_submission_policy.rb index 4add36ee46..7dccbbcba0 100644 --- a/app/policies/form_submission_policy.rb +++ b/app/policies/form_submission_policy.rb @@ -1,5 +1,9 @@ class FormSubmissionPolicy < ApplicationPolicy # See https://actionpolicy.evilmartians.io/#/writing_policies + def index? + admin? + end + def show? admin? end diff --git a/app/views/form_submissions/index.html.erb b/app/views/form_submissions/index.html.erb new file mode 100644 index 0000000000..93f6ce5144 --- /dev/null +++ b/app/views/form_submissions/index.html.erb @@ -0,0 +1,68 @@ +<% content_for(:page_bg_class, "admin-only bg-blue-100") %> + +
+ <% if @person %> + Forms submitted by <%= @person.name %>. + <% else %> + Forms submitted across the site. + <% end %> +
+| Form | +Role | +Event | + <% unless @person %>Person | <% end %> +Submitted | ++ |
|---|---|---|---|---|---|
| <%= submission.form&.display_name %> | +<%= submission.role&.humanize %> | +<%= submission.resolved_event&.name %> | + <% unless @person %><%= submission.person&.name %> | <% end %> +<%= submission.created_at.to_fs(:long) %> | ++ <%= link_to "View", form_submission_path(submission), class: "text-blue-600 hover:underline" %> + | +
No form submissions found.
+