Skip to content

Commit

Permalink
Merge pull request #5380 from avalonmediasystem/new_mo_show
Browse files Browse the repository at this point in the history
First pass redesign of media object page
  • Loading branch information
masaball authored Sep 29, 2023
2 parents 0d16202 + 7cc481e commit 5d164cd
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 48 deletions.
12 changes: 12 additions & 0 deletions app/javascript/components/Ramp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ const Ramp = ({
base_url,
mo_id,
master_files_count,
title,
expand_structure,
admin_links,
share,
timeline,
playlist,
thumbnail,
in_progress,
cdl
Expand All @@ -56,11 +60,19 @@ const Ramp = ({
{ master_files_count > 0 &&
<React.Fragment>
<MediaPlayer enableFileDownload={false} />
<div className="ramp--rails-title">
{ <div className="object-title" dangerouslySetInnerHTML={{ __html: title.content }} /> }
</div>
<div className="ramp--rails-content">
{ timeline.canCreate && <div className="mr-1" dangerouslySetInnerHTML={{ __html: timeline.content }} /> }
{ playlist.canCreate && <div className="mr-1" dangerouslySetInnerHTML={{ __html: playlist.content }} />}
{ share.canShare && <div className="share-tabs" dangerouslySetInnerHTML={{ __html: share.content }} /> }
{ admin_links.canUpdate && <div className="mr-1" dangerouslySetInnerHTML={{ __html: admin_links.content }} /> }
{ thumbnail.canCreate && <div className="mr-1" dangerouslySetInnerHTML={{ __html: thumbnail.content }} /> }
</div>
<div className="ramp--rails-expand-structure">
{ <div className="mr-1" dangerouslySetInnerHTML={{ __html: expand_structure.content }} /> }
</div>
<StructuredNavigation />
</React.Fragment>
}
Expand Down
137 changes: 132 additions & 5 deletions app/javascript/components/Ramp.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
/*
* Copyright 2011-2023, The Trustees of Indiana University and Northwestern
* University. Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
Expand All @@ -28,16 +28,51 @@
}
}

.ramp--rails-title {
font-size: 2rem !important;
margin-top: 1rem !important;
}

.ramp--rails-content {
display: flex;

#administrative_options {
text-align: right !important;
}

.btn-sm {
padding: 0 0;
}

.share-tabs {
flex-grow: 2;
}

#share-list {
margin-left: -9.25rem;
}

.svg-add-to-playlist {
width: 35px;
margin: 0;
}

.bgColor {
fill: white;
}

#add-to-playlist-btn:hover {
.bgColor {
fill: #f2f2f2;
}
}

.foregroundColor {
fill: none;
stroke: #2a5459;
stroke-width: 2;
stroke-miterlimit: 10;
}
}

.ramp--supplemental-files {
Expand All @@ -51,3 +86,95 @@
font-size: 1.25rem;
}
}

.nav.nav-tabs {
background-color:#fff;
border:1px solid #e2e7e9;
border-top-left-radius:.5rem;
border-top-right-radius:.5rem;
display:-ms-flexbox;
display:flex;
-ms-flex-wrap:wrap;
flex-wrap:wrap;

.nav-item {
border:none;
background-color:transparent;
border-bottom:1px solid #e2e7e9;
color:#243142;
cursor:pointer;
-ms-flex-positive:1;
flex-grow:1;
line-height:1;
padding:1rem;
position:relative;
z-index:100;
}
.nav-item:not(:first-child) {
border-left:1px solid #e2e7e9;
margin-left:-1px;
}
.nav-item:hover {
background-color:#f8f9fa;
color:#0e1825;
}
.nav-item:hover:after {
background-color:#e2e7e9;
bottom:0;
content:"";
display:block;
height:.25rem;
left:0;
position:absolute;
width:100%;
}
.nav-item:focus {
outline:.125rem solid #328bb8;
outline-offset:.125rem;
background-color:#edfafd;
}
.nav-item:focus:not(:focus-visible) {
outline:none;
}
.nav-item[aria-selected=true] {
background-color:#f8f9fa;
}
.nav-item[aria-selected=true]:after {
bottom:0;
background-color:#2a5459;
content:"";
display:block;
height:.25rem;
left:0;
position:absolute;
width:100%;
}
}

.tab-pane {
padding:1rem;
border-bottom-left-radius:.5rem;
border-bottom-right-radius:.5rem;
}
.tab-pane:focus {
outline:.125rem solid #006298;
outline-offset:-.125rem;
}
.tab-pane:focus:not(:focus-visible) {
outline:none;
}

#expand_all_sections {
display: flex !important;
justify-content: flex-end;
padding-bottom: .5rem !important;
}

.accordion-toggle-icon {
align-items: center;
color: #4c5a69;
}

.icn-expand-all {
width: 20px;
}
30 changes: 3 additions & 27 deletions app/views/media_objects/_administrative_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,15 @@ Unless required by applicable law or agreed to in writing, software distributed
--- END LICENSE_HEADER BLOCK ---
%>
<% if can? :update, @media_object %>
<p>
<ul class="unstyled" style="display: none;">
<li>
<% if @media_object.published? %>
<span class="label label-success">Published</span> Authorized users can view the item</li>
<% else %>
<span class="label label-important">Unpublished</span> Users cannot view the item</li>
<% end %>
<li>
<% unless @media_object.discover_groups.include? "nobody" %>
<span class="label label-success">Visible</span> Users can search for the item</li>
<% else %>
<span class="label label-important">Hidden</span> Users cannot search for the item</li>
<% end %>
</ul>
</p>
<div id="administrative_options" class="mb-3">
<div id="administrative_options" class="mb-3" style="margin-top: 10px;">
<%= link_to 'Edit', edit_media_object_path(@media_object), class: 'btn btn-primary' %>
<% if @media_object.published? %>
<% if can?(:unpublish, @media_object) %>
<%= link_to 'Unpublish', update_status_media_object_path(@media_object, status:'unpublish'), method: :put, class: 'btn btn-outline' %>
<%= link_to 'Unpublish', update_status_media_object_path(@media_object, status:'unpublish'), method: :put, class: 'btn btn-primary' %>
<% end %>
<% else %>
<%= link_to 'Publish', update_status_media_object_path(@media_object, status:'publish'), method: :put, class: 'btn btn-outline' %>
<% end %>
<%# This might not be the best approach because it makes accidental
deletion possible just by following a link. Need to revisit when
extra cycles are available %>
<% if can? :destroy, @media_object %>
<%= link_to 'Delete', confirm_remove_media_object_path(@media_object), class: 'btn btn-link' %>
<%= link_to 'Publish', update_status_media_object_path(@media_object, status:'publish'), method: :put, class: 'btn btn-primary' %>
<% end %>
<% if Settings.intercom.present? and can? :intercom_push, @media_object %>
Expand Down
30 changes: 30 additions & 0 deletions app/views/media_objects/_expand_structure.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<%#
Copyright 2011-2023, The Trustees of Indiana University and Northwestern
University. Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
--- END LICENSE_HEADER BLOCK ---
%>

<div id="expand_all_sections">
<button class="btn btn-outline" id="expand_all_btn">
<span class="accordion-toggle-icon icn-expand-all">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-down" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"></path>
</svg>
</span>
Expand
<% #TODO: Retrieve count of sections and return here %>
Section(s)
</button>
</div>
<% #TODO: Wire button to expand all sections of the structure or remove if accordion styling cannot be worked out before 7.7 release %>
4 changes: 4 additions & 0 deletions app/views/media_objects/_item_view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ Unless required by applicable law or agreed to in writing, software distributed
base_url: request.protocol+request.host_with_port,
mo_id: @media_object.id,
master_files_count: @media_object.master_files.size,
title: { content: render('title') },
expand_structure: { content: render('expand_structure') },
admin_links: { canUpdate: (current_ability.can? :update, @media_object), content: render('administrative_links') },
share: { canShare: (will_partial_list_render? :share), content: lending_enabled?(@media_object) ? (render('share') if can_stream) : render('share') },
timeline: { canCreate: (current_ability.can? :create, Timeline), content: lending_enabled?(@media_object) ? (render('timeline') if can_stream) : render('timeline') },
thumbnail: { canCreate: (current_ability.can? :edit, @media_object), content: lending_enabled?(@media_object) ? (render('thumbnail') if can_stream) : render('thumbnail') },
playlist: { canCreate: (current_ability.can? :create, Playlist), content: lending_enabled?(@media_object) ? (render('playlist') if can_stream) : render('playlist') },
in_progress: in_progress,
cdl: { enabled: lending_enabled?(@media_object), can_stream: can_stream, embed: render('embed_checkout'), destroy: render('destroy_checkout') }
}
Expand Down
37 changes: 37 additions & 0 deletions app/views/media_objects/_playlist.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<%#
Copyright 2011-2023, The Trustees of Indiana University and Northwestern
University. Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
--- END LICENSE_HEADER BLOCK ---
%>

<div id="add-to-playlist-button">
<button type="button" class="btn btn-outline btn-sm" id="add-to-playlist-btn" data-toggle="modal" data-target="#playlistModal" style="margin-top: 10px;" >
<span class='sr-only'>Add all to playlist</span>
<svg version="1.1" class="svg-add-to-playlist " xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 32 29" xml:space="preserve">
<g>
<g>
<path class="bgColor" d="M32,24c0,2.8-2.2,5-5,5H5c-2.8,0-5-2.2-5-5V5c0-2.8,2.2-5,5-5h22c2.8,0,5,2.2,5,5V24z"></path>
</g>
</g>
<g>
<line class="foregroundColor" x1="5.1" y1="8.2" x2="20" y2="8.2"></line>
<line class="foregroundColor" x1="5.1" y1="12.5" x2="18.7" y2="12.5"></line>
<line class="foregroundColor" x1="5.2" y1="17.2" x2="15" y2="17.2"></line>
<line class="foregroundColor" x1="16.9" y1="17.1" x2="28" y2="17.1"></line>
<line class="foregroundColor" x1="22.5" y1="22.7" x2="22.4" y2="11.6"></line>
</g>
</svg>
</button>
</div>

<% # TODO: Build add to playlist modal %>
25 changes: 25 additions & 0 deletions app/views/media_objects/_title.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<%#
Copyright 2011-2023, The Trustees of Indiana University and Northwestern
University. Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
--- END LICENSE_HEADER BLOCK ---
%>

<div class="page-title-wrapper">
<h2>
<% unless @media_object.title.blank? %>
<%= @media_object.title %><%= " / #{@media_object.statement_of_responsibility}" if @media_object.statement_of_responsibility.present? %>
<% else %>
<%= @media_object.id %>
<% end %>
</h2>
</div>
11 changes: 0 additions & 11 deletions app/views/media_objects/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,4 @@ Unless required by applicable law or agreed to in writing, software distributed
<% @page_title = t('media_objects.show.title', :media_object_title => (@media_object.title || @media_object.id), :application_name => application_name) %>
<div class="page-title-wrapper">
<h1>
<% unless @media_object.title.blank? %>
<%= @media_object.title %><%= " / #{@media_object.statement_of_responsibility}" if @media_object.statement_of_responsibility.present? %>
<% else %>
<%= @media_object.id %>
<% end %>
</h1>
</div>

<%= render 'administrative_links' %>
<%= render 'item_view' %>
10 changes: 5 additions & 5 deletions spec/features/media_object_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright 2011-2023, The Trustees of Indiana University and Northwestern
# University. Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
#
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
Expand All @@ -30,14 +30,14 @@
expect(page.has_content?('Default Unit')).to be_truthy
end
describe 'metadata display' do
it 'displays the title properly' do
# NOTE: Skipped tests, need JS to render with Ramp integration
skip 'displays the title properly' do
title = 'Hello World'
media_object.title = title
media_object.save
visit media_object_path(media_object)
expect(page.has_content?(title)).to be_truthy
end
# NOTE: Skipped tests, need JS to render with Ramp integration
skip 'displays the date properly' do
date = '1997'
media_object.date_issued = date
Expand Down

0 comments on commit 5d164cd

Please sign in to comment.