From: Peter Amstutz Date: Fri, 28 Feb 2014 18:47:58 +0000 (-0500) Subject: POST works to actions controller, still need to implement the actual action to build... X-Git-Tag: 1.1.0~2709^2~114^2~6 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/550e20e00518ce51054e9c52549e77f74d033eba POST works to actions controller, still need to implement the actual action to build the manifest. --- diff --git a/apps/workbench/app/assets/javascripts/selection.js b/apps/workbench/app/assets/javascripts/selection.js index c8ec8100ac..ef1c59230b 100644 --- a/apps/workbench/app/assets/javascripts/selection.js +++ b/apps/workbench/app/assets/javascripts/selection.js @@ -40,7 +40,6 @@ jQuery(function($){ }; var remove_selection_click = function(e) { - //remove_selection($(this).attr('name')); remove_selection($(this).val()); }; @@ -49,23 +48,26 @@ jQuery(function($){ update_count(); } + var combine_selected_files_into_collection = function () { + + } + var update_count = function(e) { var lst = get_selection_list(); $("#persistent-selection-count").text(lst.length); if (lst.length > 0) { - $('#persistent-selection-list').html('
  • Clear selections
  • ' - +'
  • '); + $('#selection-form-content').html('
  • ' + + '
  • Clear selections
  • ' + + '
  • '); for (var i = 0; i < lst.length; i++) { - $('#persistent-selection-list > li > table').append("" + $('#selection-form-content > li > table').append("" + "" - + "
    " - + "" - + "
    " + + "" + "" + "" - + "" + lst[i].name + "" + + "
    " + lst[i].name + "
    " + "" + "" @@ -93,6 +95,7 @@ jQuery(function($){ $('.remove-selection').on('click', remove_selection_click); $('#clear_selections_button').on('click', clear_selections); + $('#combine_selected_files_into_collection').on('click', combine_selected_files_into_collection); }; $(document). diff --git a/apps/workbench/app/controllers/actions_controller.rb b/apps/workbench/app/controllers/actions_controller.rb new file mode 100644 index 0000000000..94bfd1e8e8 --- /dev/null +++ b/apps/workbench/app/controllers/actions_controller.rb @@ -0,0 +1,27 @@ +class ActionsController < ApplicationController + def combine_selected_files_into_collection + lst = [] + params["selection"].each do |s| + m = CollectionsHelper.match(s) + if m + lst.append(m[1] + m[2]) + end + end + + collections = Collection.where(uuid: lst) + + collections.each do |c| + puts c.manifest_text + end + + '/' + end + + def post + if params["combine_selected_files_into_collection"] + redirect_to combine_selected_files_into_collection + else + redirect_to :back + end + end +end diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 412f86ce07..2790f96472 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base around_filter :thread_clear around_filter :thread_with_mandatory_api_token, :except => [:render_exception, :render_not_found] around_filter :thread_with_optional_api_token - before_filter :find_object_by_uuid, :except => [:index, :render_exception, :render_not_found] + before_filter :find_object_by_uuid, :except => [:index, :post, :render_exception, :render_not_found] before_filter :check_user_agreements, :except => [:render_exception, :render_not_found] before_filter :check_user_notifications, :except => [:render_exception, :render_not_found] theme :select_theme diff --git a/apps/workbench/app/helpers/collections_helper.rb b/apps/workbench/app/helpers/collections_helper.rb index df0ba22eac..7b548dfb84 100644 --- a/apps/workbench/app/helpers/collections_helper.rb +++ b/apps/workbench/app/helpers/collections_helper.rb @@ -6,6 +6,6 @@ module CollectionsHelper end def self.match(uuid) - /^([a-f0-9]{32}(\+[0-9]+)?)(\+.*)?$/.match(uuid.to_s) + /^([a-f0-9]{32})(\+[0-9]+)?(\+.*?)?(\/.*)?$/.match(uuid.to_s) end end diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb index 705ded388a..a8535ab259 100644 --- a/apps/workbench/app/views/collections/_show_files.html.erb +++ b/apps/workbench/app/views/collections/_show_files.html.erb @@ -19,14 +19,13 @@ <% file_path = "#{file[0]}/#{file[1]}" %> - <% fp2 = file_path[2..-1] if file_path[0..1] == './' %> - <% fp2 ||= file_path %> -<%= check_box_tag 'uuids[]', @object.uuid+file_path, false, { - :class => 'persistent-selection', - :friendly_type => "File", - :friendly_name => "#{@object.uuid}/#{fp2}", - :href => "#{url_for controller: 'collections', action: 'show', id: @object.uuid }/#{file_path}" - } %> + <% puts "#{file[0]} #{file[1]} #{file_path}" %> + <%= 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', id: @object.uuid }/#{file_path}" + } %> <%= file[0] %> diff --git a/apps/workbench/app/views/layouts/application.html.erb b/apps/workbench/app/views/layouts/application.html.erb index 68f0e109bd..abef47136f 100644 --- a/apps/workbench/app/views/layouts/application.html.erb +++ b/apps/workbench/app/views/layouts/application.html.erb @@ -121,7 +121,10 @@ -