diff --git a/app/controllers/bubbles_controller.rb b/app/controllers/bubbles_controller.rb
index 7864ffe31..d64f76a38 100644
--- a/app/controllers/bubbles_controller.rb
+++ b/app/controllers/bubbles_controller.rb
@@ -9,10 +9,12 @@ class BubblesController < ApplicationController
DISPLAY_COUNT_OPTIONS = [ 6, 12, 18, 24 ].freeze
DEFAULT_DISPLAY_COUNT = 6
+ RECENTLY_POPPED_LIMIT = 100
def index
- @bubbles = @filter.bubbles.published_or_drafted_by(Current.user)
- @display_count = display_count
+ @considering_bubbles = @filter.bubbles.considering
+ @doing_bubbles = @filter.bubbles.doing
+ @popped_bubbles = @filter.with(indexed_by: "popped").bubbles.limit(RECENTLY_POPPED_LIMIT)
end
def create
diff --git a/app/models/filter.rb b/app/models/filter.rb
index 1c94485f4..d3d7df9c2 100644
--- a/app/models/filter.rb
+++ b/app/models/filter.rb
@@ -19,7 +19,7 @@ class Filter < ApplicationRecord
def bubbles
@bubbles ||= begin
result = creator.accessible_bubbles.indexed_by(indexed_by)
- result = result.active unless indexed_by.popped?
+ result = indexed_by.popped? ? result.popped : result.active
result = result.unassigned if assignment_status.unassigned?
result = result.assigned_to(assignees.ids) if assignees.present?
result = result.where(creator_id: creators.ids) if creators.present?
@@ -42,6 +42,10 @@ class Filter < ApplicationRecord
buckets.first if buckets.one?
end
+ def single_workflow
+ buckets.first.workflow if buckets.pluck(:workflow_id).uniq.one?
+ end
+
def cacheable?
buckets.exists?
end
diff --git a/app/models/filter/fields.rb b/app/models/filter/fields.rb
index 37880f230..a9d7ab28b 100644
--- a/app/models/filter/fields.rb
+++ b/app/models/filter/fields.rb
@@ -31,6 +31,14 @@ module Filter::Fields
end
end
+ def with(**fields)
+ dup.tap do |filter|
+ fields.each do |key, value|
+ filter.public_send("#{key}=", value)
+ end
+ end
+ end
+
def default_indexed_by
self.class.default_values[:indexed_by]
end
diff --git a/app/views/bubbles/index.html.erb b/app/views/bubbles/index.html.erb
index b25d51842..026f80100 100644
--- a/app/views/bubbles/index.html.erb
+++ b/app/views/bubbles/index.html.erb
@@ -7,82 +7,8 @@
<% end %>
-
-
- Considering
-
- <% if (unstaged_bubbles = Filter.from_params(@filter.as_params.except(:stage_ids)).tap { |f| f.creator = Current.user }.bubbles.where(stage: nil)).any? %>
- <%= render partial: "bubbles/card_mini", collection: unstaged_bubbles, as: :bubble, cached: true %>
- <% else %>
- Nothing here
- <% end %>
-
-
- <% if workflow = @filter.buckets.first&.workflow %>
-
-
-
-
-
- <% else %>
-
- Doing
-
- <% end %>
-
- <% if (staged_bubbles = @bubbles.where.not(stage: nil)).any? %>
- <%= render partial: "bubbles/card_preview", collection: staged_bubbles, as: :bubble, cached: true %>
- <% else %>
- Nothing here
- <% end %>
-
+ <%= render "bubbles/index/bubbles/considering", bubbles: @considering_bubbles %>
+ <%= render "bubbles/index/bubbles/doing", bubbles: @doing_bubbles, filter: @filter %>
-
-
- Recently closed
-
-
- <% if (popped_bubbles = Filter.from_params(@filter.as_params.except(:stage_ids).merge(indexed_by: "popped")).tap { |f| f.creator = Current.user }.bubbles).any? %>
- <%= render partial: "bubbles/card_preview", collection: popped_bubbles, as: :bubble, cached: true %>
- <% else %>
- Nothing here
- <% end %>
-
-
+<%= render "bubbles/index/bubbles/popped", bubbles: @popped_bubbles, filter: @filter %>
diff --git a/app/views/bubbles/index/_workflow_filter.html.erb b/app/views/bubbles/index/_workflow_filter.html.erb
new file mode 100644
index 000000000..fd078736e
--- /dev/null
+++ b/app/views/bubbles/index/_workflow_filter.html.erb
@@ -0,0 +1,41 @@
+
+
+
+
+
diff --git a/app/views/bubbles/index/bubbles/_considering.html.erb b/app/views/bubbles/index/bubbles/_considering.html.erb
new file mode 100644
index 000000000..8a119b420
--- /dev/null
+++ b/app/views/bubbles/index/bubbles/_considering.html.erb
@@ -0,0 +1,10 @@
+
+
+ Considering
+
+ <% if bubbles.any? %>
+ <%= render partial: "bubbles/card_mini", collection: bubbles, as: :bubble, cached: true %>
+ <% else %>
+ Nothing here
+ <% end %>
+
diff --git a/app/views/bubbles/index/bubbles/_doing.html.erb b/app/views/bubbles/index/bubbles/_doing.html.erb
new file mode 100644
index 000000000..bae9b50c5
--- /dev/null
+++ b/app/views/bubbles/index/bubbles/_doing.html.erb
@@ -0,0 +1,15 @@
+
+ <% if workflow = filter.single_workflow %>
+ <%= render "bubbles/index/workflow_filter", workflow: workflow, filter: filter %>
+ <% else %>
+
+ Doing
+
+ <% end %>
+
+ <% if bubbles.any? %>
+ <%= render partial: "bubbles/card_preview", collection: bubbles, as: :bubble, cached: true %>
+ <% else %>
+ Nothing here
+ <% end %>
+
diff --git a/app/views/bubbles/index/bubbles/_popped.html.erb b/app/views/bubbles/index/bubbles/_popped.html.erb
new file mode 100644
index 000000000..d31bf2500
--- /dev/null
+++ b/app/views/bubbles/index/bubbles/_popped.html.erb
@@ -0,0 +1,12 @@
+
+
+ Recently closed
+
+
+ <% if bubbles.any? %>
+ <%= render partial: "bubbles/card_preview", collection: bubbles, as: :bubble, cached: true %>
+ <% else %>
+ Nothing here
+ <% end %>
+
+