From e34135f6779f58852558e03b1b95534c11ca07ae Mon Sep 17 00:00:00 2001 From: Tim Pierce Date: Tue, 28 Oct 2014 11:14:47 -0400 Subject: [PATCH] 4088: filter collection file view by regex Added a "Filter" field for supplying a regular expression to filter filenames. Updated integration tests. --- .../views/collections/_show_files.html.erb | 22 ++++++++++++ .../test/integration/collections_test.rb | 34 +++++++++++++++++++ services/api/test/fixtures/collections.yml | 4 +-- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb index 051fbf4f62..9b39b61d44 100644 --- a/apps/workbench/app/views/collections/_show_files.html.erb +++ b/apps/workbench/app/views/collections/_show_files.html.erb @@ -17,10 +17,29 @@ +
+ <%= form_tag collection_path(@object.uuid), {method: 'get'} do %> + + + <% end %> +

<% end %> +<% + file_regex = nil + if params[:file_regex] + begin + file_regex = Regexp.new(params[:file_regex]) + rescue RegexpError + # If the pattern is not a valid regex, quote it + # (i.e. use it as a simple substring search) + file_regex = Regexp.new(Regexp.quote(params[:file_regex])) + end + end +%> + <% file_tree = @object.andand.files_tree %> <% if file_tree.nil? or file_tree.empty? %>

This collection is empty.

@@ -40,6 +59,9 @@