-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3146 from projectblacklight/document-admin-table-…
…component Use a document component for rendering documents for admins.
- Loading branch information
Showing
10 changed files
with
84 additions
and
10 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
app/components/spotlight/document_admin_table_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<%= content_tag @component, | ||
id: @id, | ||
data: { | ||
'document-id': @document.id.to_s.parameterize, | ||
'document-counter': @counter, | ||
'label-toggle': @document.id | ||
}, | ||
itemscope: true, | ||
itemtype: @document.itemtype, | ||
class: classes.flatten.join(' ') do %> | ||
<% # header bar for doc items in index view -%> | ||
<td class="spotlight-admin-thumbnail"> | ||
<%= thumbnail %> | ||
</td> | ||
<td> | ||
<%# header bar for doc items in index view -%> | ||
<div class="documentHeader row" data-label-toggle="<%= @document.id %>"> | ||
<h5 class="index_title col-md-12"> | ||
<%= helpers.link_to_document(presenter.document, itemprop: 'name') %> | ||
</h5> | ||
</div> | ||
<div class="page-links"> | ||
<%= helpers.view_link presenter.document, helpers.link_to_document(presenter.document) %> · | ||
<%= helpers.exhibit_edit_link presenter.document, [:edit, helpers.current_exhibit, presenter.document] %> | ||
</div> | ||
</td> | ||
<td class="text-nowrap"> | ||
<%= timestamp %> | ||
</td> | ||
<td class="checkbox-toggle"> | ||
<%= render partial: 'document_visibility_control', locals: { document: presenter.document} %> | ||
</td> | ||
<% end %> |
23 changes: 23 additions & 0 deletions
23
app/components/spotlight/document_admin_table_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spotlight | ||
# Displays the document | ||
# This overrides the title method to provide an edit link. | ||
class DocumentAdminTableComponent < Blacklight::DocumentComponent | ||
def initialize(component: 'tr', **kwargs) | ||
super | ||
end | ||
|
||
def classes | ||
super + ['doc-row'] | ||
end | ||
|
||
def timestamp | ||
return unless presenter.document[presenter.configuration.index.timestamp_field] | ||
|
||
l Date.parse(presenter.document[presenter.configuration.index.timestamp_field]) | ||
rescue StandardError | ||
nil | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
app/views/spotlight/catalog/_admin_index_header_default.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
<% # container for a single doc -%> | ||
<tr class="<%= render_document_class document %> doc-row" data-label-toggle="<%= document.id %>" itemscope itemtype="<%= document.itemtype %>"> | ||
<%= render_document_partials document, blacklight_config.view_config(document_index_view_type).partials, :document_counter => document_counter %> | ||
</tr> | ||
|
||
<%- Spotlight.deprecator.warn 'The partial _spotlight/catalog/_document_row.html.erb will be removed; customize the admin display using components instead' %> | ||
<%= render Spotlight::DocumentAdminTableComponent.new(presenter: document_presenter(document)) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters