[ARVADOS] updated: e47a4660df55a7f45bcd3df5d4c041e13f194ac7
Git user
git at public.curoverse.com
Fri Mar 24 16:58:47 EDT 2017
Summary of changes:
.../app/controllers/collections_controller.rb | 30 ++++++++++++++++++++++
apps/workbench/app/helpers/application_helper.rb | 4 +--
apps/workbench/app/models/collection.rb | 4 ++-
.../app/views/collections/_show_files.html.erb | 16 +++++++++---
4 files changed, 48 insertions(+), 6 deletions(-)
via e47a4660df55a7f45bcd3df5d4c041e13f194ac7 (commit)
from 0dea965e36e7ac52a789e31b45fc70f1925c4190 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit e47a4660df55a7f45bcd3df5d4c041e13f194ac7
Author: radhika <radhika at curoverse.com>
Date: Fri Mar 24 16:58:20 2017 -0400
3821: Rename collection file path
diff --git a/apps/workbench/app/controllers/collections_controller.rb b/apps/workbench/app/controllers/collections_controller.rb
index c377796..701b590 100644
--- a/apps/workbench/app/controllers/collections_controller.rb
+++ b/apps/workbench/app/controllers/collections_controller.rb
@@ -321,6 +321,36 @@ class CollectionsController < ApplicationController
end
end
+ def update
+ updated_attr = params[:collection].each.select {|a| a[0].andand.start_with? 'rename-file-path:'}
+
+ if updated_attr.size > 0
+ # Is it file rename?
+ file_path = updated_attr[0][0].split('rename-file-path:')[-1]
+
+ new_file_path = updated_attr[0][1]
+ if new_file_path.start_with?('./')
+ # looks good
+ elsif new_file_path.start_with?('/')
+ new_file_path = '.' + new_file_path
+ else
+ new_file_path = './' + new_file_path
+ end
+
+ arv_coll = Arv::Collection.new(@object.manifest_text)
+ arv_coll.rename "./"+file_path, new_file_path
+
+ if @object.update_attributes manifest_text: arv_coll.manifest_text
+ show
+ else
+ self.render_error status: 422
+ end
+ else
+ # Non a file rename; use default
+ super
+ end
+ end
+
protected
def find_usable_token(token_list)
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index 21879a5..0dc16fb 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -274,10 +274,10 @@ module ApplicationHelper
"data-placement" => "bottom",
"data-type" => input_type,
"data-title" => "Edit #{attr.to_s.gsub '_', ' '}",
- "data-name" => attr,
+ "data-name" => htmloptions['selection_path'] || attr,
"data-object-uuid" => object.uuid,
"data-toggle" => "manual",
- "data-value" => attrvalue,
+ "data-value" => htmloptions['data-value'] || attrvalue,
"id" => span_id,
:class => "editable #{is_textile?( object, attr ) ? 'editable-textile' : ''}"
}.merge(htmloptions).merge(ajax_options)
diff --git a/apps/workbench/app/models/collection.rb b/apps/workbench/app/models/collection.rb
index 13f5357..7468333 100644
--- a/apps/workbench/app/models/collection.rb
+++ b/apps/workbench/app/models/collection.rb
@@ -1,6 +1,8 @@
require "arvados/keep"
class Collection < ArvadosBase
+ attr_accessor :filename
+
MD5_EMPTY = 'd41d8cd98f00b204e9800998ecf8427e'
def default_name
@@ -71,7 +73,7 @@ class Collection < ArvadosBase
end
def editable_attributes
- %w(name description manifest_text)
+ %w(name description manifest_text filename)
end
def provenance
diff --git a/apps/workbench/app/views/collections/_show_files.html.erb b/apps/workbench/app/views/collections/_show_files.html.erb
index f7a94fc..fc1ca58 100644
--- a/apps/workbench/app/views/collections/_show_files.html.erb
+++ b/apps/workbench/app/views/collections/_show_files.html.erb
@@ -99,9 +99,14 @@
<i class="fa fa-fw fa-trash-o"></i>
<% end %>
<% end %>
-
<% if CollectionsHelper::is_image(filename) %>
- <i class="fa fa-fw fa-bar-chart-o"></i> <%= filename %></div>
+ <i class="fa fa-fw fa-bar-chart-o"></i>
+ <% if @object.editable? %>
+ <%= render_editable_attribute @object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_path' => 'rename-file-path:'+file_path} %>
+ <% else %>
+ <%= filename %>
+ <% end %>
+ </div>
<div class="collection_files_inline">
<%= link_to(image_tag("#{url_for object}/#{file_path}"),
link_params.merge(disposition: 'inline'),
@@ -109,7 +114,12 @@
</div>
</div>
<% else %>
- <i class="fa fa-fw fa-file" href="<%=object.uuid%>/<%=file_path%>" ></i> <%= filename %></div>
+ <% if @object.editable? %>
+ <i class="fa fa-fw fa-file"></i><%= render_editable_attribute @object, 'filename', filename, {'data-value' => file_path, 'data-toggle' => 'manual', 'selection_path' => 'rename-file-path:'+file_path} %>
+ <% else %>
+ <i class="fa fa-fw fa-file" href="<%=object.uuid%>/<%=file_path%>" ></i> <%= filename %>
+ <% end %>
+ </div>
</div>
<% end %>
</li>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list