3781: Add browser->api/keepproxy angular app as Upload tab on collections#show
[arvados.git] / apps / workbench / app / controllers / application_controller.rb
index 7d7d5550b5999efff4108959202fbf1c9401472d..6fea62563d2828e66278b31af5632ca3a8bf9811 100644 (file)
@@ -164,41 +164,31 @@ class ApplicationController < ActionController::Base
   def find_objects_for_index
     @objects ||= model_class
     @objects = @objects.filter(@filters).limit(@limit).offset(@offset)
+    @objects.fetch_multiple_pages(false)
   end
 
   def render_index
-    if params[:partial]
-      respond_to do |f|
-        f.json {
-          if @filters.andand.any?
-            search_filters = @filters.select do |attr,op,val|
-              op == 'ilike' and !val.nil? and !val.eql?('%%')
-            end
-          end
-          if !search_filters || !search_filters.any?  # no search filter was used
-            @next_page_href = next_page_href(partial: params[:partial])
-          else
-            @next_page_href = nil
-          end
+    respond_to do |f|
+      f.json {
+        if params[:partial]
+          @next_page_href = next_page_href(partial: params[:partial], filters: @filters.to_json)
           render json: {
-            content: render_to_string(partial: "show_#{params[:partial]}.html", formats: [:html]),
-                                      next_page_href: @next_page_href
-
+            content: render_to_string(partial: "show_#{params[:partial]}",
+                                      formats: [:html]),
+            next_page_href: @next_page_href
           }
-        }
-      end
-    else
-      respond_to do |f|
-        f.json { render json: @objects }
-        f.html {
-          if params[:tab_pane]
-            render_pane params[:tab_pane]
-          else
-            render
-          end
-        }
-        f.js { render }
-      end
+        else
+          render json: @objects
+        end
+      }
+      f.html {
+        if params[:tab_pane]
+          render_pane params[:tab_pane]
+        else
+          render
+        end
+      }
+      f.js { render }
     end
   end
 
@@ -266,7 +256,9 @@ class ApplicationController < ActionController::Base
         elsif request.method.in? ['GET', 'HEAD']
           render
         else
-          redirect_to params[:return_to] || @object
+          redirect_to (params[:return_to] ||
+                       polymorphic_url(@object,
+                                       anchor: params[:redirect_to_anchor]))
         end
       }
       f.js { render }
@@ -331,15 +323,9 @@ class ApplicationController < ActionController::Base
     @new_resource_attrs.reject! { |k,v| k.to_s == 'uuid' }
     @object ||= model_class.new @new_resource_attrs, params["options"]
     if @object.save
-      respond_to do |f|
-        f.json { render json: @object.attributes.merge(href: url_for(action: :show, id: @object)) }
-        f.html {
-          redirect_to @object
-        }
-        f.js { render }
-      end
+      show
     else
-      self.render_error status: 422
+      render_error status: 422
     end
   end