};
var remove_selection_click = function(e) {
- //remove_selection($(this).attr('name'));
remove_selection($(this).val());
};
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('<li><a href="#" class="btn pull-right" id="clear_selections_button">Clear selections</a></li>'
- +'<li class="notification"><table style="width: 100%"></table></li>');
+ $('#selection-form-content').html('<li><input type="submit" name="combine_selected_files_into_collection" id="combine_selected_files_into_collection" value="Combine selected collections and files into a new collection"/></li>'
+ + '<li><a href="#" id="clear_selections_button">Clear selections</a></li>'
+ + '<li class="notification"><table style="width: 100%"></table></li>');
for (var i = 0; i < lst.length; i++) {
- $('#persistent-selection-list > li > table').append("<tr>"
+ $('#selection-form-content > li > table').append("<tr>"
+ "<td>"
- + "<form>"
- + "<input class='remove-selection' type='checkbox' value='" + lst[i].uuid + "' checked='true'></input>"
- + "</form>"
+ + "<input class='remove-selection' name='selection[]' type='checkbox' value='" + lst[i].uuid + "' checked='true'></input>"
+ "</td>"
+ "<td>"
- + "<span style='padding-left: 1em'><a href=\"" + lst[i].href + "\">" + lst[i].name + "</a></span>"
+ + "<div style='padding-left: 1em'><a href=\"" + lst[i].href + "\">" + lst[i].name + "</a></div>"
+ "</td>"
+ "<td style=\"vertical-align: top\">"
$('.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).
--- /dev/null
+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
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
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
<% file_path = "#{file[0]}/#{file[1]}" %>
<tr>
<td>
- <% 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}"
+ } %>
</td>
<td>
<%= file[0] %>
<span class="badge" id="persistent-selection-count"></span>
<span class="caret"></span>
</a>
- <ul class="dropdown-menu" role="menu" id="persistent-selection-list">
+ <ul class="dropdown-menu" role="menu" id="persistent-selection-list">
+ <%= form_tag '/actions' do %>
+ <div id="selection-form-content"></div>
+ <% end %>
</ul>
</li>
match '/collections/graph' => 'collections#graph'
resources :collections
get '/collections/:uuid/*file' => 'collections#show_file', :format => false
+
+ post 'actions' => 'actions#post'
+
root :to => 'users#welcome'
# Send unroutable requests to an arbitrary controller