diff --git a/app/dashboards/hold_dashboard.rb b/app/dashboards/hold_dashboard.rb index f37b759b..749a5ef5 100644 --- a/app/dashboards/hold_dashboard.rb +++ b/app/dashboards/hold_dashboard.rb @@ -8,9 +8,10 @@ class HoldDashboard < Administrate::BaseDashboard # which determines how the attribute is displayed # on pages throughout the dashboard. ATTRIBUTE_TYPES = { - thesis: Field::BelongsTo, - author_names: Field::String, - degrees: Field::String, + thesis: Field::BelongsTo.with_options(searchable: true, + searchable_fields: ['title']), + author_names: Field::Text, + degrees: Field::Text, grad_date: Field::DateTime.with_options( format: "%Y %B", ), @@ -20,9 +21,9 @@ class HoldDashboard < Administrate::BaseDashboard date_start: Field::Date, date_end: Field::Date, date_released: Field::Date, - dates_thesis_files_received: Field::String, + dates_thesis_files_received: Field::Text, case_number: Field::String, - status: Field::Select.with_options(searchable: false, collection: ->(field) { field.resource.class.send(field.attribute.to_s.pluralize).keys }), + status: Field::Select.with_options(searchable: true, collection: ->(field) { field.resource.class.send(field.attribute.to_s.pluralize).keys }), processing_notes: Field::Text, created_by: Field::Text, created_at: Field::Date, @@ -92,7 +93,9 @@ class HoldDashboard < Administrate::BaseDashboard # open: ->(resources) { resources.where(open: true) } # }.freeze COLLECTION_FILTERS = { - active: ->(resources) { resources.where(status: :active) } + active: ->(resources) { resources.where(status: :active) }, + expired: ->(resources) { resources.where(status: :expired) }, + released: ->(resources) { resources.where(status: :released) } }.freeze # Overwrite this method to customize how holds are displayed diff --git a/test/integration/admin/admin_hold_test.rb b/test/integration/admin/admin_hold_test.rb index a60c4c90..9a354363 100644 --- a/test/integration/admin/admin_hold_test.rb +++ b/test/integration/admin/admin_hold_test.rb @@ -195,4 +195,31 @@ def teardown assert_response :success assert_select "a[href='/hold_history/#{hold.id}']", "View hold history" end + + test 'can filter active holds' do + mock_auth users(:thesis_admin) + get "/admin/holds?search=active%3A" + assert_response :success + assert_select 'a', 'active' + assert_select 'a', {count: 0, text: 'expired'} + assert_select 'a', {count: 0, text: 'released'} + end + + test 'can filter expired holds' do + mock_auth users(:thesis_admin) + get "/admin/holds?search=expired%3A" + assert_response :success + assert_select 'a', 'expired' + assert_select 'a', {count: 0, text: 'active'} + assert_select 'a', {count: 0, text: 'released'} + end + + test 'can filter released holds' do + mock_auth users(:thesis_admin) + get "/admin/holds?search=released%3A" + assert_response :success + assert_select 'a', 'released' + assert_select 'a', {count: 0, text: 'active'} + assert_select 'a', {count: 0, text: 'expired'} + end end