From f97f243abfaaae4b04d0dc7fc02e6f54685b16fb Mon Sep 17 00:00:00 2001 From: radhika Date: Sat, 12 Jul 2014 23:08:00 -0400 Subject: [PATCH] 3140: address tab content mangling issue when infinte scrolling is applied to tabs due to large data. --- .../app/controllers/application_controller.rb | 15 ++++--- .../app/controllers/projects_controller.rb | 45 +++++++++++-------- .../projects/_show_data_collections.html.erb | 9 +++- .../_show_jobs_and_pipelines.html.erb | 9 +++- .../projects/_show_other_objects.html.erb | 9 +++- .../_show_pipeline_templates.html.erb | 9 +++- .../views/projects/_show_subprojects.html.erb | 9 +++- .../projects/_show_tab_contents.html.erb | 16 +------ 8 files changed, 78 insertions(+), 43 deletions(-) diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb index 7d7ea9534b..ea460912df 100644 --- a/apps/workbench/app/controllers/application_controller.rb +++ b/apps/workbench/app/controllers/application_controller.rb @@ -132,12 +132,15 @@ class ApplicationController < ActionController::Base end helper_method :next_page_offset - def next_page_offset - if @objects.respond_to?(:result_offset) and - @objects.respond_to?(:result_limit) and - @objects.respond_to?(:items_available) - next_offset = @objects.result_offset + @objects.result_limit - if next_offset < @objects.items_available + def next_page_offset objects=nil + if !objects + objects = @objects + end + if objects.respond_to?(:result_offset) and + objects.respond_to?(:result_limit) and + objects.respond_to?(:items_available) + next_offset = objects.result_offset + objects.result_limit + if next_offset < objects.items_available next_offset else nil diff --git a/apps/workbench/app/controllers/projects_controller.rb b/apps/workbench/app/controllers/projects_controller.rb index 91d6e8a713..108cb601dd 100644 --- a/apps/workbench/app/controllers/projects_controller.rb +++ b/apps/workbench/app/controllers/projects_controller.rb @@ -8,7 +8,7 @@ class ProjectsController < ApplicationController end def show_pane_list - %w(Contents Permissions Advanced) + %w(Data_collections Jobs_and_pipelines Pipeline_templates Subprojects Other_objects Permissions Advanced) end def remove_item @@ -79,28 +79,14 @@ class ProjectsController < ApplicationController end @objects = @object.contents(limit: 50, include_linked: true, + filters: params[:filters], offset: params[:offset] || 0) @share_links = Link.filter([['head_uuid', '=', @object.uuid], ['link_class', '=', 'permission']]) @logs = Log.limit(10).filter([['object_uuid', '=', @object.uuid]]) - @objects_and_names = [] - @objects.each do |object| - if !(name_links = @objects.links_for(object, 'name')).empty? - name_links.each do |name_link| - @objects_and_names << [object, name_link] - end - elsif object.respond_to? :name - @objects_and_names << [object, object] - else - @objects_and_names << [object, - Link.new(owner_uuid: @object.uuid, - tail_uuid: @object.uuid, - head_uuid: object.uuid, - link_class: "name", - name: "")] - end - end + @objects_and_names = get_objects_and_names @objects + if params[:partial] respond_to do |f| f.json { @@ -131,4 +117,27 @@ class ProjectsController < ApplicationController @updates = params['project'] super end + + helper_method :get_objects_and_names + def get_objects_and_names(objects) + objects_and_names = [] + objects.each do |object| + if !(name_links = objects.links_for(object, 'name')).empty? + name_links.each do |name_link| + objects_and_names << [object, name_link] + end + elsif object.respond_to? :name + objects_and_names << [object, object] + else + objects_and_names << [object, + Link.new(owner_uuid: @object.uuid, + tail_uuid: @object.uuid, + head_uuid: object.uuid, + link_class: "name", + name: "")] + end + end + objects_and_names + end + end diff --git a/apps/workbench/app/views/projects/_show_data_collections.html.erb b/apps/workbench/app/views/projects/_show_data_collections.html.erb index c632324055..9198c653dc 100644 --- a/apps/workbench/app/views/projects/_show_data_collections.html.erb +++ b/apps/workbench/app/views/projects/_show_data_collections.html.erb @@ -55,4 +55,11 @@ <% end %> <% end %> -<%= render partial: 'show_tab_contents', locals: {project: @object, objects_and_names: @objects_and_names, data_kind: ['arvados#collection']} %> +<% + filters = [['uuid', 'is_a', "arvados#collection"]] + @objects = @object.contents({limit: 50, include_linked: true, :filters => filters}) + objects_and_names = get_objects_and_names @objects + page_offset = next_page_offset @objects +%> + +<%= render partial: 'show_tab_contents', locals: {project: @object, objects_and_names: objects_and_names, filters: filters, page_offset: page_offset} %> diff --git a/apps/workbench/app/views/projects/_show_jobs_and_pipelines.html.erb b/apps/workbench/app/views/projects/_show_jobs_and_pipelines.html.erb index 619e51b077..9b42452f69 100644 --- a/apps/workbench/app/views/projects/_show_jobs_and_pipelines.html.erb +++ b/apps/workbench/app/views/projects/_show_jobs_and_pipelines.html.erb @@ -1 +1,8 @@ -<%= render partial: 'show_tab_contents', locals: {project: @object, objects_and_names: @objects_and_names, data_kind: ['arvados#job', 'arvados#pipelineInstance']} %> +<% + filters = [['uuid', 'is_a', ["arvados#pipelineInstance","arvados#job"]]] + @objects = @object.contents({limit: 50, include_linked: true, :filters => filters}) + objects_and_names = get_objects_and_names @objects + page_offset = next_page_offset @objects +%> + +<%= render partial: 'show_tab_contents', locals: {project: @object, objects_and_names: objects_and_names, filters: filters, page_offset: page_offset} %> diff --git a/apps/workbench/app/views/projects/_show_other_objects.html.erb b/apps/workbench/app/views/projects/_show_other_objects.html.erb index 7a87413be5..3275ac74af 100644 --- a/apps/workbench/app/views/projects/_show_other_objects.html.erb +++ b/apps/workbench/app/views/projects/_show_other_objects.html.erb @@ -1 +1,8 @@ -<%= render partial: 'show_tab_contents', locals: {project: @object, objects_and_names: @objects_and_names, data_kind: []} %> +<% + filters = [['uuid', 'is_a', ["arvados#human","arvados#specimen","arvados#trait"]]] + @objects = @object.contents({limit: 50, include_linked: true, :filters => filters}) + objects_and_names = get_objects_and_names @objects + page_offset = next_page_offset @objects +%> + +<%= render partial: 'show_tab_contents', locals: {project: @object, objects_and_names: objects_and_names, filters: filters, page_offset: page_offset} %> diff --git a/apps/workbench/app/views/projects/_show_pipeline_templates.html.erb b/apps/workbench/app/views/projects/_show_pipeline_templates.html.erb index 26082c0951..5497f12a5f 100644 --- a/apps/workbench/app/views/projects/_show_pipeline_templates.html.erb +++ b/apps/workbench/app/views/projects/_show_pipeline_templates.html.erb @@ -1 +1,8 @@ -<%= render partial: 'show_tab_contents', locals: {project: @object, objects_and_names: @objects_and_names, data_kind: ['arvados#pipelineTemplate']} %> +<% + filters = [['uuid', 'is_a', "arvados#pipelineTemplate"]] + @objects = @object.contents({limit: 50, include_linked: true, :filters => filters}) + objects_and_names = get_objects_and_names @objects + page_offset = next_page_offset @objects +%> + +<%= render partial: 'show_tab_contents', locals: {project: @object, objects_and_names: objects_and_names, filters: filters, page_offset: page_offset} %> diff --git a/apps/workbench/app/views/projects/_show_subprojects.html.erb b/apps/workbench/app/views/projects/_show_subprojects.html.erb index cd9c3e613b..6e93a4a93a 100644 --- a/apps/workbench/app/views/projects/_show_subprojects.html.erb +++ b/apps/workbench/app/views/projects/_show_subprojects.html.erb @@ -1 +1,8 @@ -<%= render partial: 'show_tab_contents', locals: {project: @object, objects_and_names: @objects_and_names, data_kind: ['arvados#group']} %> +<% + filters = [['uuid', 'is_a', "arvados#group"]] + @objects = @object.contents({limit: 50, include_linked: true, :filters => filters}) + objects_and_names = get_objects_and_names @objects + page_offset = next_page_offset @objects +%> + +<%= render partial: 'show_tab_contents', locals: {project: @object, objects_and_names: objects_and_names, filters: filters, page_offset: page_offset} %> diff --git a/apps/workbench/app/views/projects/_show_tab_contents.html.erb b/apps/workbench/app/views/projects/_show_tab_contents.html.erb index e95ba72077..ee9ef4d341 100644 --- a/apps/workbench/app/views/projects/_show_tab_contents.html.erb +++ b/apps/workbench/app/views/projects/_show_tab_contents.html.erb @@ -24,25 +24,13 @@ - <% - selected_objects_and_names = [] - specific_data_kinds = ['arvados#collection', 'arvados#group', 'arvados#job', 'arvados#pipelineInstance', 'arvados#pipelineTemplate'] - @objects_and_names.each do |object, name_link| - if !data_kind.any? && !specific_data_kinds.include?(object.kind) - selected_objects_and_names << [object, name_link] - elsif data_kind.include?(object.kind) - selected_objects_and_names << [object, name_link] - end - end - %> - - - <%= render partial: 'show_contents_rows', locals: {project: @object, objects_and_names: selected_objects_and_names} %> + "> + <%= render partial: 'show_contents_rows', locals: {project: @object, objects_and_names: objects_and_names} %> -- 2.39.5