diff --git a/app/controllers/admin/assets_controller.rb b/app/controllers/admin/assets_controller.rb index ce7fcb1..d67b717 100644 --- a/app/controllers/admin/assets_controller.rb +++ b/app/controllers/admin/assets_controller.rb @@ -12,6 +12,8 @@ def index @template_name = 'index' if !@page.nil? render :partial => 'admin/assets/search_results.html.haml', :layout => false + elsif params[:repaginate].present? + render :partial => 'admin/assets/actions.html.haml', :locals => { :assets => @assets }, :layout => false else render :partial => 'admin/assets/asset_table.html.haml', :locals => { :assets => @assets }, :layout => false end diff --git a/app/views/admin/assets/_actions.html.haml b/app/views/admin/assets/_actions.html.haml new file mode 100644 index 0000000..c2d09f3 --- /dev/null +++ b/app/views/admin/assets/_actions.html.haml @@ -0,0 +1,4 @@ +#actions + = pagination_for @assets, :depaginate => false, :filter => params[:filter] + %ul + %li= link_to((image('plus', :alt => '') + ' ' + t('paperclipped.new_asset')), new_admin_asset_path) diff --git a/app/views/admin/assets/index.html.haml b/app/views/admin/assets/index.html.haml index 36b5d9e..dc701a8 100644 --- a/app/views/admin/assets/index.html.haml +++ b/app/views/admin/assets/index.html.haml @@ -6,23 +6,19 @@ - form_tag(admin_assets_path,:id => 'filesearchform', :method => 'get') do %input{ :type => "search", :id => "search", :name => "search" , :value => params[:search] } = submit_tag t("paperclipped.search") + = observe_field 'search', :frequency => 1, :update => 'actions', :url => { :controller => 'assets', :action=> 'index', :repaginate => '1' }, :method => 'get', :with => "'search=' + escape(value)" = observe_field 'search', :frequency => 1, :update => 'assets_table', :url => { :controller => 'assets', :action=> 'index' }, :method => 'get', :with => "'search=' + escape(value)" == #{t('paperclipped.types_to_find')}: - %span - = link_to t("paperclipped.images"), "#" - %span - = link_to t("paperclipped.others"), "#" - %span - = link_to t("paperclipped.audio"), "#" - %span - = link_to t("paperclipped.movies"), "#" + - ['images', 'others', 'audio', 'movies'].each do |filter| + %span + - options = (params[:filter].present? and params[:filter][filter.singularize].present? and params[:filter][filter.singularize] == '1') ? {:class => :pressed} : nil + = link_to t("paperclipped.#{filter}"), "#", options #type_boxes{ :style => "display: none" } - = check_box_tag 'filter[audio]', '1', false, :id => 'audio-check' - = check_box_tag 'filter[image]', '1', false, :id => 'images-check' - = check_box_tag 'filter[other]', '1', false, :id => 'others-check' - = check_box_tag 'filter[movie]', '1', false, :id => 'movies-check' + - ['images', 'others', 'audio', 'movies'].each do |filter| + = check_box_tag "filter[#{filter.singularize}]", '1', (params[:filter].present? and params[:filter][filter.singularize].present? and params[:filter][filter.singularize] == '1'), :id => "#{filter}-check" + - if false #current_user.admin? # turned off for now, this might be too dangerous to reveal .regenerator = link_to t('paperclipped.regenerate_all_thumbnails') , refresh_admin_assets_path, :confirm => 'Beware that this will take a while and consume considerable resources on your server. Are you sure you want to continue?' @@ -32,7 +28,4 @@ = render :partial => 'assets_container' - render_region :bottom do |bottom| - #actions - = pagination_for @assets, :depaginate => false - %ul - %li= link_to((image('plus', :alt => '') + ' ' + t('paperclipped.new_asset')), new_admin_asset_path) + = render :partial => 'actions' diff --git a/public/javascripts/admin/assets.js b/public/javascripts/admin/assets.js index 088d4ce..036a749 100644 --- a/public/javascripts/admin/assets.js +++ b/public/javascripts/admin/assets.js @@ -133,6 +133,13 @@ Asset.FileTypes = Behavior.create({ method: 'get', onComplete: 'assets_table' }); + new Ajax.Updater('actions', search_form.action, { + asynchronous: true, + evalScripts: true, + parameters: Form.serialize(search_form) + "&repaginate=1", + method: 'get', + onComplete: 'actions' + }); } });