Skip to content

Commit

Permalink
Show works in workflows to the admin. Fixes #855
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed May 11, 2017
1 parent 35da1cf commit 9ff4298
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 7 deletions.
10 changes: 9 additions & 1 deletion app/assets/stylesheets/hyrax/dashboard.scss
Expand Up @@ -14,13 +14,21 @@ $admin-content-background-color: #f0f0f0 !default;
$admin-vertical-padding: 0 !default;
$admin-panel-border-color: #dedede !default;

.my-works-list {
.works-list {
.highlighted-work {
color: #ffd700;
background-color: $gray-light;
border-radius: 10px;
padding: 2px;
}

.workflow-state {
white-space: nowrap;
}

.media-body {
width: 18vw;
}
}

body.dashboard {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/hyrax/dashboard/works_controller.rb
Expand Up @@ -5,7 +5,7 @@ class WorksController < Hyrax::My::WorksController
before_action :ensure_admin!

def search_builder_class
Hyrax::ActiveWorksSearchBuilder
Hyrax::WorksSearchBuilder
end

private
Expand Down
4 changes: 2 additions & 2 deletions app/presenters/hyrax/workflow_presenter.rb
Expand Up @@ -11,9 +11,9 @@ def state
sipity_entity.workflow_state_name if sipity_entity
end

# TODO: maybe i18n here?
def state_label
state
return unless state
I18n.t("hyrax.workflow.state.#{state}", default: state.humanize)
end

# Returns an array of tuples (key, label) appropriate for a radio group
Expand Down
7 changes: 7 additions & 0 deletions app/search_builders/hyrax/works_search_builder.rb
@@ -0,0 +1,7 @@
module Hyrax
# Returns all works, either active or suppressed.
# This should only be used by an admin user
class WorksSearchBuilder < ActiveWorksSearchBuilder
self.default_processor_chain -= [:only_active_works]
end
end
7 changes: 5 additions & 2 deletions app/views/hyrax/dashboard/works/_default_group.html.erb
@@ -1,16 +1,19 @@
<table class="table table-striped">
<table class="table table-striped works-list">
<caption class="sr-only"><%= t("hyrax.dashboard.my.sr.listing") %> <%= application_name %></caption>
<thead>
<tr>
<th><%= t("hyrax.dashboard.my.heading.title") %></th>
<th class="date"><%= t("hyrax.dashboard.my.heading.date_uploaded") %></th>
<th><%= t("blacklight.search.fields.facet.suppressed_bsi") %></th>
<th><%= t("hyrax.dashboard.my.heading.visibility") %></th>
<th><%= t("hyrax.dashboard.my.heading.action") %></th>
</tr>
</thead>
<tbody>
<% docs.each_with_index do |document, counter| %>
<%= render 'list_works', document: document, counter: counter, presenter: Hyrax::WorkShowPresenter.new(document, current_ability) %>
<%= render 'list_works', document: document,
counter: counter,
presenter: Hyrax::WorkShowPresenter.new(document, current_ability) %>
<% end %>
</tbody>
</table>
1 change: 1 addition & 0 deletions app/views/hyrax/dashboard/works/_list_works.html.erb
Expand Up @@ -24,6 +24,7 @@
</td>

<td class='text-center'><%= document.date_uploaded %></td>
<td class='workflow-state'><%= presenter.workflow.state_label %></td>
<td class='text-center'><%= render_visibility_link document %></td>

<td class='text-center'>
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/my/works/_default_group.html.erb
@@ -1,4 +1,4 @@
<table class="table table-striped my-works-list">
<table class="table table-striped works-list">
<caption class="sr-only"><%= t("hyrax.dashboard.my.sr.listing") %> <%= application_name %></caption>
<% unless params[:display_type] == 'list' %>
<thead>
Expand Down
24 changes: 24 additions & 0 deletions spec/search_builders/hyrax/works_search_builder_spec.rb
@@ -0,0 +1,24 @@
require 'spec_helper'

RSpec.describe Hyrax::WorksSearchBuilder do
describe "::default_processor_chain" do
subject { described_class.default_processor_chain }
let(:blacklight_filters) do
# These filters are in Blacklight::Solr::SearchBuilderBehavior
[
:default_solr_parameters,
:add_query_to_solr,
:add_facet_fq_to_solr,
:add_facetting_to_solr,
:add_solr_fields_to_query,
:add_paging_to_solr,
:add_sorting_to_solr,
:add_group_config_to_solr,
:add_facet_paging_to_solr,
:add_access_controls_to_solr_params
]
end

it { is_expected.to eq blacklight_filters + [:filter_models] }
end
end

0 comments on commit 9ff4298

Please sign in to comment.