Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image ordering in sidebar using sorting options #640

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $icon-font-path: "bootstrap-sass/assets/fonts/bootstrap/";
@import "header";
@import "uploads";
@import "annotations";
@import "sidebar.css";
@import "bootstrap/dist/css/bootstrap.min.css";
@import "leaflet-draw/dist/leaflet.draw.css";
@import "leaflet-illustrate/dist/Leaflet.Illustrate.css";
Expand Down
36 changes: 36 additions & 0 deletions app/assets/stylesheets/sidebar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.image-order{
display: inline-block;
float: right;
margin-right: 32px;
margin-bottom: 10px;
}
.sidebar-heading{
display: inline-block;
}
.image-order-button {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
.image-order {
position: relative;
display: inline-block;
}
.image-order-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.image-order-content a {
color: black;
padding: 7px 10px;
text-decoration: none;
display: block;
}
.image-order-content a:hover {background-color: white;}
.image-order:hover .image-order-content {display: block;}
25 changes: 21 additions & 4 deletions app/views/images/_index.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
<h4>Images</h4>
<div>
<h4 class="sidebar-heading">Images</h4>
<div class="image-order">
<button type="button" class="btn btn-outline-secondary">Order Images</button>
<div class="image-order-content">
<a href="?sort=name">Name</a>
<a href="?sort=size">Size</a>
<a href="?sort=recent">Recent</a>
</div>
</div>
</div>
<% if @map.warpables.empty? %>
<p id="no-images">No images uploaded. </p>
<%end%>
<table class="warpables-all table table-striped">
<tbody>
<% @map.warpables.each do |warpable| %>
<% sort_param = params[:sort] %>
<% if sort_param == 'name' %>
<% ary = @map.warpables.sort { |a, b| a.image_file_name <=> b.image_file_name } %>
<% elsif sort_param == 'size' %>
<% ary = @map.warpables.sort { |a, b| a.image_file_size <=> b.image_file_size } %>
<% else %>
<% ary = @map.warpables.sort { |a, b| b.created_at <=> a.created_at } %>
<% end %>
<% ary.each do |warpable| %>
<tr id="warpable-<%= warpable.id %>">
<td class="warpable">
<%= image_tag warpable.image.url(:thumb),
Expand Down Expand Up @@ -55,7 +73,6 @@
}
})
}

/* wait for map to load if we're on a small screen and it's been hidden */
if ($('body').width() < 400) {
window.toggle_sidebar();
Expand All @@ -70,4 +87,4 @@
</tr>
<% end %>
</tbody>
</table>
</table>