Skip to content

Commit

Permalink
Displays processing icon when a work still is being processed
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorcorrea committed Jan 27, 2016
1 parent ea5e0ee commit 57ba4d5
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 26 deletions.
6 changes: 6 additions & 0 deletions app/controllers/concerns/sufia/works_controller_behavior.rb
Expand Up @@ -17,6 +17,12 @@ def new
super
end

def edit
work = GenericWork.find(params[:id])
throw "Cannot edit a work that still is being processed" if work.processing?
super
end

protected

def show_presenter
Expand Down
4 changes: 4 additions & 0 deletions app/models/concerns/sufia/solr_document_behavior.rb
Expand Up @@ -81,5 +81,9 @@ def collections
def generic_work?
hydra_model == 'GenericWork'
end

def upload_set_id
Array(self[Solrizer.solr_name("isPartOf", :symbol)]).first
end
end
end
8 changes: 7 additions & 1 deletion app/presenters/sufia/work_show_presenter.rb
@@ -1,7 +1,7 @@
module Sufia
class WorkShowPresenter < ::CurationConcerns::WorkShowPresenter
# delegate fields from Sufia::Works::Metadata to solr_document
delegate :based_near, :depositor, :identifier, :resource_type, :tag, to: :solr_document
delegate :based_near, :depositor, :identifier, :resource_type, :tag, :upload_set_id, to: :solr_document

def editor?
current_ability.can?(:edit, solr_document)
Expand Down Expand Up @@ -33,6 +33,12 @@ def itemtype
'http://schema.org/CreativeWork'
end

def processing?
return false if upload_set_id.nil?
upload_set = UploadSet.find(upload_set_id)
upload_set.status.first == "processing".freeze
end

private

def featured?
Expand Down
10 changes: 4 additions & 6 deletions app/views/collections/_show_document_list_row.html.erb
@@ -1,12 +1,10 @@
<% id = document.id %>
<% presenter = document.is_a?(GenericWork) ? Sufia::WorkShowPresenter.new(document, nil) : nil %>
<tr id="document_<%= id %>" class="<%= cycle("", "zebra") %>">
<td>&nbsp;
<%# TODO is there a processing concept for a work ?? see #1122 & #1123 %>
<%# This block is for adding/removing the magic wand while batch updates are processing %>
<%# if gf.processing? %>
<!--<i class="glyphicon glyphicon-time <%#= 'ss-'+gf.batch.id %>"/>-->
<%# elsif current_user and gf.depositor != current_user.user_key %>
<% if current_user and document.depositor != current_user.user_key %>
<% if presenter && presenter.processing? %>
<i class="glyphicon glyphicon-time <%= 'ss-'+presenter.upload_set_id %>"/>
<% elsif current_user and document.depositor != current_user.user_key %>
<i class="glyphicon glyphicon-share-alt"/>
<% end %>
</td>
Expand Down
34 changes: 19 additions & 15 deletions app/views/curation_concerns/base/_show_actions.html.erb
Expand Up @@ -5,24 +5,28 @@
<% if Sufia.config.citations %>
<%= link_to "Citations", sufia.citations_work_path(@presenter), id: 'citations', class: 'btn btn-default' %>
<% end %>
<% if @presenter.editor? %>
<%= link_to "Edit This #{@presenter.human_readable_type}", edit_polymorphic_path([main_app, @presenter]), class: 'btn btn-default' %>
<%= link_to "Delete This #{@presenter.human_readable_type}", [main_app, @presenter], class: 'btn btn-danger pull-right', data: { confirm: "Delete this #{@presenter.human_readable_type}?" }, method: :delete %>
<% end %>
<%= link_to 'Export to EndNote', polymorphic_path([main_app, @presenter], format: 'endnote'), class: 'btn btn-default' %>
<%= link_to 'Export to Zotero', sufia.static_path('zotero'), id: 'zoteroLink', name: 'zotero', class: 'btn btn-default' %>
<%= link_to 'Export to Mendeley', sufia.static_path('mendeley'), id: 'mendeleyLink', name: 'mendeley', class: 'btn btn-default' %>
<% if @presenter.processing? %>
<% # Question: Should we disable the buttons instead? %>
<p>This work is being processed</p>
<% else %>
<% if @presenter.editor? %>
<%= link_to "Edit This #{@presenter.human_readable_type}", edit_polymorphic_path([main_app, @presenter]), class: 'btn btn-default' %>
<%= link_to "Delete This #{@presenter.human_readable_type}", [main_app, @presenter], class: 'btn btn-danger pull-right', data: { confirm: "Delete this #{@presenter.human_readable_type}?" }, method: :delete %>
<% end %>
<%= link_to 'Export to EndNote', polymorphic_path([main_app, @presenter], format: 'endnote'), class: 'btn btn-default' %>
<%= link_to 'Export to Zotero', sufia.static_path('zotero'), id: 'zoteroLink', name: 'zotero', class: 'btn btn-default' %>
<%= link_to 'Export to Mendeley', sufia.static_path('mendeley'), id: 'mendeleyLink', name: 'mendeley', class: 'btn btn-default' %>
<% if @presenter.display_feature_link? %>
<%= link_to "Feature", sufia.featured_work_path(@presenter, format: :json),
data: {behavior: 'feature'}, id: 'featureLink', name: 'featureLink', class: 'btn btn-default' %>
<% end %>
<% if @presenter.display_feature_link? %>
<%= link_to "Feature", sufia.featured_work_path(@presenter, format: :json),
data: {behavior: 'feature'}, id: 'featureLink', name: 'featureLink', class: 'btn btn-default' %>
<% end %>
<% if @presenter.display_unfeature_link? %>
<%= link_to "Unfeature", sufia.featured_work_path(@presenter, format: :json),
data: {behavior: 'unfeature'}, id: 'unfeatureLink', name: 'unfeatureLink', class: 'btn btn-default' %>
<% if @presenter.display_unfeature_link? %>
<%= link_to "Unfeature", sufia.featured_work_path(@presenter, format: :json),
data: {behavior: 'unfeature'}, id: 'unfeatureLink', name: 'unfeatureLink', class: 'btn btn-default' %>
<% end %>
<% end %>

<!-- COinS hook for Zotero -->
<span class="Z3988" title="<%= export_as_openurl_ctx_kev(@presenter) %>"></span>
</div>
2 changes: 1 addition & 1 deletion app/views/my/_index_partials/_default_group.html.erb
Expand Up @@ -15,7 +15,7 @@
<% docs.each_with_index do |document,counter| %>
<% case document.hydra_model %>
<% when "GenericWork" %>
<%= render partial: 'my/_index_partials/list_works', locals: { document: document, counter: counter } %>
<%= render partial: 'my/_index_partials/list_works', locals: { document: document, counter: counter, presenter: Sufia::WorkShowPresenter.new(document, current_ability) } %>
<% when "Collection" %>
<%= render partial: 'my/_index_partials/list_collections', locals: {document: document, counter: counter} %>
<% else %>
Expand Down
6 changes: 5 additions & 1 deletion app/views/my/_index_partials/_list_works.html.erb
Expand Up @@ -2,7 +2,11 @@

<td>
<label for="batch_document_<%= document.id %>" class="sr-only"><%=t("sufia.dashboard.my.sr.batch_checkbox")%></label>
<%= batch_edit_select(document) %>&nbsp;
<% if presenter.processing? %>
<i class="glyphicon glyphicon-time <%= 'ss-'+presenter.upload_set_id %>"/>
<% else %>
<%= batch_edit_select(document) %>&nbsp;
<% end %>
</td>

<td>
Expand Down
3 changes: 2 additions & 1 deletion spec/views/my/_list_works.html.erb_spec.rb
Expand Up @@ -10,14 +10,15 @@
let(:config) { My::WorksController.new.blacklight_config }
let(:members) { [SolrDocument.new(collection.to_solr)] }
let(:user) { FactoryGirl.create(:user) }
let(:presenter) { Sufia::WorkShowPresenter.new(doc, nil) }

before do
expect(Sufia::CollectionMemberService).to receive(:run).with(doc).and_return(members)
allow(view).to receive(:blacklight_config) { config }
view.lookup_context.prefixes = %w(collections)
assign(:collection, collection)
@user = user
render 'my/_index_partials/list_works', document: doc
render 'my/_index_partials/list_works', document: doc, presenter: presenter
end

it 'the line item displays the work and its actions' do
Expand Down
2 changes: 1 addition & 1 deletion sufia.gemspec
Expand Up @@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
spec.version = version
spec.license = 'Apache2'

spec.add_dependency 'curation_concerns', '~> 0.4'
spec.add_dependency 'curation_concerns', '~> 0.5'
spec.add_dependency 'hydra-batch-edit', '~> 1.1'
spec.add_dependency 'hydra-head', '< 9.6.0'
spec.add_dependency 'browse-everything', '~> 0.4'
Expand Down

0 comments on commit 57ba4d5

Please sign in to comment.