Skip to content
Browse files

filtering by attachment, various bugs and small enhacements

  • Loading branch information...
1 parent 37d4c67 commit a0d46c36cd95898d919bfecc4e6a1c9001b2072a @Bringo Bringo committed Mar 19, 2012
View
6 app/controllers/assets_controller.rb
@@ -19,7 +19,8 @@ def index
pageopts[:page] = 1 if pageopts[:page] == "" || pageopts[:page].to_i < 1
asset_includes = [:titles, {:identifiers => [:identifier_source]}, {:instantiations => [:format, :format_ids, :annotations, :borrowings]}, :descriptions]
the_params = params # so it can be seen inside the search DSL.
- streamable = session[:streamable] # ditto
+ streamable = session[:filter] == "streamable" #ditto
+ attachment = session[:filter] == "attachment"
@search_fields = params[:search_fields]
@show_field_chooser = !!@search_fields
@@ -50,6 +51,9 @@ def index
if streamable
with :online_asset, true
end
+ if attachment
+ with :attachment, true
+ end
end
@query = the_query
@assets = @search_object.results
View
5 app/controllers/options_controller.rb
@@ -1,7 +1,8 @@
class OptionsController < ApplicationController
- def streamable
+ def filter
passed = params[:value].downcase
- session[:streamable] = (passed == "on" || passed == "true" || passed == "1")
+ session[:filter] = passed
+
if session[:search].is_a?(Hash)
session[:search].delete(:page)
redirect_to session[:search]
View
1 app/models/asset.rb
@@ -161,6 +161,7 @@ class Asset < ActiveRecord::Base
time :updated_at
string :uuid
boolean(:online_asset) { self.online? }
+ boolean(:attachment) { self.attachment.present? }
dynamic_string :facets, :multiple => true do
PBCore.config['facets'].inject({}) do |hash, facet|
key = facet[0].to_sym
View
2 app/models/contributor.rb
@@ -21,6 +21,6 @@ def contributor_role_name=(name)
end
def to_s
- contributor_role.nil? ? contributor : "#{contributor_role.name}: #{contributor}"
+ contributor_role.nil? ? contributor : "#{contributor} (#{contributor_role.name})"
end
end
View
2 app/models/creator.rb
@@ -18,6 +18,6 @@ def creator_role_name=(name)
end
def to_s
- creator_role.nil? ? creator : "#{creator_role.name}: #{creator}"
+ creator_role.nil? ? creator : "#{creator} (#{creator_role.name})"
end
end
View
2 app/models/publisher.rb
@@ -20,6 +20,6 @@ def publisher_role_name=(name)
end
def to_s
- publisher_role.nil? ? publisher : "#{publisher_role.name}: #{publisher}"
+ publisher_role.nil? ? publisher : "#{publisher} (#{publisher_role.name})"
end
end
View
8 app/views/assets/_asset_description.html.erb
@@ -0,0 +1,8 @@
+<% if asset.descriptions.present? %>
+ <dl class="asset_dates">
+ <% asset.descriptions.each do |description| %>
+ <dt><%= description.description_type.try(:name) %>:</dt>
+ <dd><%= truncate(description.description, :length => 500, :separator => ' ') %></dd>
+ <% end %>
+ </dl>
+<% end %>
View
1 app/views/assets/_rights_summary_fields.html.erb
@@ -2,4 +2,5 @@
<%= f.input :rights_summary, :required => false %>
<%= f.input :source, :as => :string, :required => false %>
<%= f.input :ref, :as => :string, :required => false %>
+ <%= link_to_remove_fields "remove", f %>
<% end %>
View
5 app/views/assets/index.haml
@@ -9,7 +9,10 @@
%h2
= link_to asset.title, asset_url(asset.uuid)
%h3&= asset.identifier
- = render "asset_date", :asset => asset
+ - if PBCore.config["show_asset_descriptions_in_search_results"].present? and PBCore.config["show_asset_descriptions_in_search_results"] == true
+ = render "asset_description", :asset => asset
+ - else
+ = render "asset_date", :asset => asset
- if asset.has_thumbnail?
= link_to img_thumb_tag(asset.thumbnail, "thumb", "80x60"), asset_url(asset.uuid), :class => "index_thumbnail"
View
5 app/views/layouts/application.haml
@@ -39,8 +39,9 @@
- else
%h1&= yield(:title)
%div.iconLinks
- = link_to("All Assets", set_streamable_path("off"), :id => "all_asset_link", :class => session[:streamable] ? nil : "selected_option")
- = link_to("Streamable Assets", set_streamable_path("on"), :id => "streamable_asset_link", :class => session[:streamable] ? "selected_option" : nil)
+ = link_to("All Assets", set_filter_path("off"), :id => "all_asset_link", :class => (session[:filter] == "off" || session[:filter].nil?) ? nil : "selected_option")
+ = link_to("Assets with PDF", set_filter_path("attachment"), :id => "attachment_asset_link", :class => (session[:filter] == "attachment") ? "selected_option" : nil)
+ = link_to("Streamable Assets", set_filter_path("streamable"), :id => "streamable_asset_link", :class => (session[:filter] == "streamable") ? "selected_option" : nil)
%tr
%td.sidebarMiddle
- if permitted_to? :index, :assets
2 config/deploy
@@ -1 +1 @@
-Subproject commit 46d9c960de4c7ec9047e11a0e1eafefb82ec9168
+Subproject commit e3374a8fe142bcc861a18602d35a9b18d52bc81d
View
2 config/routes.rb
@@ -32,7 +32,7 @@
map.resources :languages, :only => [:index]
map.ids 'ids', :controller => 'last_used_ids', :action => 'index'
- map.set_streamable 'options/streamable/:value', :controller => 'options', :action => 'streamable'
+ map.set_filter 'options/filter/:value', :controller => 'options', :action => 'filter'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
View
BIN public/images/gen/buttons/btnAttachment.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
4 public/stylesheets/application/rollover.css
@@ -2,7 +2,7 @@
* why use javascript and four images when you can use CSS and only two?
*/
-a#all_asset_link, a#streamable_asset_link {
+a#all_asset_link, a#streamable_asset_link, a#attachment_asset_link {
height: 11px;
background-repeat: no-repeat;
background-position: 0px 0px;
@@ -11,6 +11,6 @@ a#all_asset_link, a#streamable_asset_link {
display: inline;
}
-a#all_asset_link:hover, a#streamable_asset_link:hover, a#all_asset_link.selected_option, a#streamable_asset_link.selected_option {
+a#all_asset_link:hover, a#streamable_asset_link:hover, a#attachment_asset_link:hover, a#all_asset_link.selected_option, a#streamable_asset_link.selected_option, a#attachment_asset_link:hover {
background-position: 0px -24px;
}
View
1 public/stylesheets/application/styles.css
@@ -39,6 +39,7 @@ a.searchSelected:link{ font-weight: bold; }
a#all_asset_link { height:12px; padding:5px 0 5px 25px; margin:0 5px; line-height:12px; display:block; float:left; }
a#streamable_asset_link { height:12px; padding:5px 0 5px 25px; margin:0 5px; line-height:12px; display:block; float:left; }
+a#attachment_asset_link { height:12px; padding:5px 0 5px 25px; margin:0 5px; line-height:12px; display:block; float:left; }
/* content*/
.contentTopLinksArea { color: #999999; line-height: 15px; vertical-align: middle; padding-top: 4px; letter-spacing: 0.5px; }
View
5 public/stylesheets/mpr/theme.css
@@ -28,8 +28,8 @@ a.contentLink:hover { color: #508bc7; }
a.footerLink { color: #ccc; }
a.footerLink:hover { color: #81afdf; }
-a#all_asset_link, a#streamable_asset_link { color: #666; }
-a#all_asset_link:hover, a#streamable_asset_link:hover, a#all_asset_link.selected_option, a#streamable_asset_link.selected_option { color: #508bc7; }
+a#all_asset_link, a#streamable_asset_link, a#attachment_asset_link { color: #666; }
+a#all_asset_link:hover, a#streamable_asset_link:hover, a#attachment_asset_link:hover, a#all_asset_link.selected_option, a#streamable_asset_link.selected_option, a#attachment_asset_link.selected_option { color: #508bc7; }
.contentTopLinksArea a { color: #D6D6D6; }
@@ -49,4 +49,5 @@ a#all_asset_link:hover, a#streamable_asset_link:hover, a#all_asset_link.selected
a#all_asset_link { background:transparent url(/images/mpr/buttons/btnAssets.png) 0 -2px no-repeat; }
a#streamable_asset_link { background:transparent url(/images/mpr/buttons/btnStreamable.png) 0 -2px no-repeat; }
+a#attachment_asset_link { background:transparent url(/images/mpr/buttons/btnAttachment.png) 0 -2px no-repeat; }

0 comments on commit a0d46c3

Please sign in to comment.
Something went wrong with that request. Please try again.