From 5a625a53394fa99ef7fb44ab63104b8195d963df Mon Sep 17 00:00:00 2001 From: radhika Date: Wed, 31 May 2017 17:16:48 -0400 Subject: [PATCH] 9587: cleanup trashed_items method --- .../app/controllers/trash_items_controller.rb | 35 +++---------------- .../views/trash_items/_untrash_item.html.erb | 4 ++- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/apps/workbench/app/controllers/trash_items_controller.rb b/apps/workbench/app/controllers/trash_items_controller.rb index 7271fc1798..bbc0b26c83 100644 --- a/apps/workbench/app/controllers/trash_items_controller.rb +++ b/apps/workbench/app/controllers/trash_items_controller.rb @@ -15,7 +15,6 @@ class TrashItemsController < ApplicationController @next_page_filters = next_page_filters('<=') @next_page_href = url_for(partial: :trash_rows, filters: @next_page_filters.to_json) - preload_links_for_objects(@objects.to_a) else @next_page_href = nil end @@ -37,39 +36,13 @@ class TrashItemsController < ApplicationController if params[:search].andand.length.andand > 0 tags = Link.where(any: ['contains', params[:search]]) - @objects = (base_search.limit(limit).offset(offset).where(uuid: tags.collect(&:head_uuid)) | - base_search.where(any: ['contains', params[:search]])). - uniq { |c| c.uuid } + base_search = base_search.limit(limit).offset(offset) + @objects = (base_search.where(uuid: tags.collect(&:head_uuid)) | + base_search.where(any: ['contains', params[:search]])). + uniq { |c| c.uuid } else @objects = base_search.limit(limit).offset(offset) end - - @links = Link.where(head_uuid: @objects.collect(&:uuid)) - @collection_info = {} - @objects.each do |c| - @collection_info[c.uuid] = { - tag_links: [], - wanted: false, - wanted_by_me: false, - provenance: [], - links: [] - } - end - @links.each do |link| - @collection_info[link.head_uuid] ||= {} - info = @collection_info[link.head_uuid] - case link.link_class - when 'tag' - info[:tag_links] << link - when 'resources' - info[:wanted] = true - info[:wanted_by_me] ||= link.tail_uuid == current_user.uuid - when 'provenance' - info[:provenance] << link.name - end - info[:links] << link - end - @request_url = request.url end def untrash_items diff --git a/apps/workbench/app/views/trash_items/_untrash_item.html.erb b/apps/workbench/app/views/trash_items/_untrash_item.html.erb index a40a4be7e1..2ba9dc93f1 100644 --- a/apps/workbench/app/views/trash_items/_untrash_item.html.erb +++ b/apps/workbench/app/views/trash_items/_untrash_item.html.erb @@ -1,5 +1,7 @@ <% if object.editable? %> - <%= link_to({action: 'untrash_items', selection: [object.uuid]}, remote: true, method: :post, data: {confirm: "Un-trash #{object.class_for_display.downcase} '#{object.friendly_link_name}'?"}) do %> + <% msg = "Un-trash '" + if !object.name.blank? then object.name else object.uuid end + "'?" %> + <%= link_to({action: 'untrash_items', selection: [object.uuid]}, remote: true, method: :post, + data: {confirm: msg}) do %> <% end %> <% end %> -- 2.30.2