From 498f3130928f58e830be3abe74b20d06904af3cd Mon Sep 17 00:00:00 2001 From: radhika Date: Thu, 4 Sep 2014 10:55:12 -0400 Subject: [PATCH] 3654: add selection dropdown to collections pages --- .../app/assets/javascripts/selection.js | 5 + .../app/controllers/actions_controller.rb | 8 +- .../views/collections/_show_files.html.erb | 141 +++++++++++------- .../views/collections/_show_recent.html.erb | 95 +++++++----- 4 files changed, 153 insertions(+), 96 deletions(-) diff --git a/apps/workbench/app/assets/javascripts/selection.js b/apps/workbench/app/assets/javascripts/selection.js index c82b6ef271..fe6270036d 100644 --- a/apps/workbench/app/assets/javascripts/selection.js +++ b/apps/workbench/app/assets/javascripts/selection.js @@ -217,6 +217,11 @@ function enable_disable_selection_actions() { toggleClass('disabled', ($checked.filter('[value*=-j7d0g-]').length > 0) || ($checked.length < 1)); + $('[data-selection-action=combine]'). + closest('li'). + toggleClass('disabled', + ($checked.filter('[value*=-4zz18-]').length < 1) || + ($checked.length != $checked.filter('[value*=-4zz18-]').length)); } $(document). diff --git a/apps/workbench/app/controllers/actions_controller.rb b/apps/workbench/app/controllers/actions_controller.rb index fcca2abe16..7c68ce9f7b 100644 --- a/apps/workbench/app/controllers/actions_controller.rb +++ b/apps/workbench/app/controllers/actions_controller.rb @@ -164,7 +164,13 @@ class ActionsController < ApplicationController l.save! end - redirect_to controller: 'collections', action: :show, id: newc.uuid + if params["show_project"] + respond_to do |format| + format.js {render inline: "location.reload();" } + end + else + redirect_to controller: 'collections', action: :show, id: newc.uuid + end end def report_issue_popup diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb index d888b2e859..6cd99251cf 100644 --- a/apps/workbench/app/views/collections/_show_files.html.erb +++ b/apps/workbench/app/views/collections/_show_files.html.erb @@ -1,62 +1,87 @@ -<% file_tree = @object.andand.files_tree %> -<% if file_tree.nil? or file_tree.empty? %> -

This collection is empty.

-<% else %> - - <% end %> -
  • - <% if size.nil? # This is a subdirectory. %> - <% dirstack.push(File.join(dirname, filename)) %> -
    -
    <%= filename %>
    +
    +
    +
    +
    + +
    -
      - <% else %> - <% link_params = {controller: 'collections', action: 'show_file', - uuid: @object.portable_data_hash, file: file_path, size: size} %> -
      -
      - <%= raw(human_readable_bytes_html(size)) %> - <% if !defined? no_checkboxes or !no_checkboxes %> - <%= check_box_tag 'uuids[]', "#{@object.uuid}/#{file_path}", false, { - :class => 'persistent-selection', - :friendly_type => "File", - :friendly_name => "#{@object.uuid}/#{file_path}", - :href => url_for(controller: 'collections', action: 'show_file', - uuid: @object.portable_data_hash, file: file_path), - :title => "Include #{file_path} in your selections", - } %> - <% end %> - <%= link_to(raw(''), - link_params.merge(disposition: 'inline'), - {title: "View #{file_path}", class: "btn btn-info btn-sm"}) %> - <%= link_to(raw(''), - link_params.merge(disposition: 'attachment'), - {title: "Download #{file_path}", class: "btn btn-info btn-sm"}) %> -
      - <% if CollectionsHelper::is_image(filename) %> -
      <%= filename %>
      -
      -
      - <%= link_to(image_tag("#{url_for @object}/#{file_path}"), - link_params.merge(disposition: 'inline'), - {title: file_path}) %> +
      +
    +

    + + <% file_tree = @object.andand.files_tree %> + <% if file_tree.nil? or file_tree.empty? %> +

    This collection is empty.

    + <% else %> +
      + <% dirstack = [file_tree.first.first] %> + <% file_tree.each_with_index do |(dirname, filename, size), index| %> + <% file_path = CollectionsHelper::file_path([dirname, filename]) %> + <% while dirstack.any? and (dirstack.last != dirname) %> + <% dirstack.pop %>
  • + <% end %> +
  • + <% if size.nil? # This is a subdirectory. %> + <% dirstack.push(File.join(dirname, filename)) %> +
    +
    <%= filename %>
    + " }.join("
  • ")) %> -<% end # if file_tree %> + <% link_params = {controller: 'collections', action: 'show_file', + uuid: @object.portable_data_hash, file: file_path, size: size} %> +
    +
    + <%= raw(human_readable_bytes_html(size)) %> + <%= link_to(raw(''), + link_params.merge(disposition: 'inline'), + {title: "View #{file_path}", class: "btn btn-info btn-sm"}) %> + <%= link_to(raw(''), + link_params.merge(disposition: 'attachment'), + {title: "Download #{file_path}", class: "btn btn-info btn-sm"}) %> +
    + +
    +
    + <% if !defined? no_checkboxes or !no_checkboxes %> + <%= check_box_tag 'uuids[]', "#{@object.uuid}/#{file_path}", false, { + :class => 'persistent-selection', + :friendly_type => "File", + :friendly_name => "#{@object.uuid}/#{file_path}", + :href => url_for(controller: 'collections', action: 'show_file', + uuid: @object.portable_data_hash, file: file_path), + :title => "Include #{file_path} in your selections", + } %> + <% end %> +
    + + <% if CollectionsHelper::is_image(filename) %> +
    <%= filename %>
    +
    + <%= link_to(image_tag("#{url_for @object}/#{file_path}"), + link_params.merge(disposition: 'inline'), + {title: file_path}) %> + <% else %> +
    <%= filename %>
    +
    + <% end %> + + + <% end # if file or directory %> + <% end # file_tree.each %> + <%= raw(dirstack.map { |_| "" }.join("")) %> + <% end # if file_tree %> + + <% content_for :footer_html do %> + + <% end %> -<% content_for :footer_html do %> - -<% end %> + diff --git a/apps/workbench/app/views/collections/_show_recent.html.erb b/apps/workbench/app/views/collections/_show_recent.html.erb index 54fc9f3da5..9573f6e8a8 100644 --- a/apps/workbench/app/views/collections/_show_recent.html.erb +++ b/apps/workbench/app/views/collections/_show_recent.html.erb @@ -1,40 +1,61 @@ -<%= render partial: "paging", locals: {results: @collections, object: @object} %> - -
    - -<%= form_tag do |f| %> - - - - - - - - - - - - - - - - - - - - <%= render partial: 'index_tbody' %> - -
    uuidcontentscreated attags
    - -<% end %> +
    +
    +
    +
    + + +
    +
    +
    +

    -

    + <%= render partial: "paging", locals: {results: @collections, object: @object} %> + +
    + + <%= form_tag do |f| %> + + + + + + + + + + + + + + + + + + + + <%= render partial: 'index_tbody' %> + +
    uuidcontentscreated attags
    -<%= render partial: "paging", locals: {results: @collections, object: @object} %> + <% end %> -<% content_for :footer_js do %> -$(document).on('click', 'form[data-remote] input[type=submit]', function() { - $('table#collections-index tbody').fadeTo(200, 0.3); - return true; -}); -<% end %> +
    + + <%= render partial: "paging", locals: {results: @collections, object: @object} %> + + <% content_for :footer_js do %> + $(document).on('click', 'form[data-remote] input[type=submit]', function() { + $('table#collections-index tbody').fadeTo(200, 0.3); + return true; + }); + <% end %> + +
    -- 2.30.2