Skip to content

Commit bfa9b59

Browse files
committed
use linkable images in dropdowns instead of current page's image
1 parent d0b9a77 commit bfa9b59

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

app/controllers/application_controller.rb

+5
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def cache_linkable_content_for_each_content_type
9696
linkable_classes += %w(Document Timeline)
9797

9898
@linkables_cache = {}
99+
@linkables_raw = {}
99100
linkable_classes.each do |class_name|
100101
# class_name = "Character"
101102

@@ -109,6 +110,10 @@ def cache_linkable_content_for_each_content_type
109110
.reject { |content| content.class.name == class_name && content.id == @content.id }
110111
end
111112

113+
@linkables_raw[class_name] = @linkables_cache[class_name]
114+
.sort_by { |p| p.name.downcase }
115+
.compact
116+
112117
@linkables_cache[class_name] = @linkables_cache[class_name]
113118
.sort_by { |p| p.name.downcase }
114119
.map { |c| [c.name, c.id] }

app/models/users/user.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def linkable_documents
155155
universe_id IN (#{(my_universe_ids + contributable_universe_ids + [-1]).uniq.join(',')})
156156
OR
157157
(universe_id IS NULL AND user_id = #{self.id.to_i})
158-
""").where(archived_at: nil)
158+
""")
159159
end
160160

161161
def linkable_timelines

app/views/content/form/field_types/_migration_link.html.erb

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
field[:value]
3030
)
3131
%>
32-
<% @linkables_cache.fetch(page_type.name, []).sort_by { |name, id| name.downcase }.each do |name, id| %>
33-
<option value="<%= page_type %>-<%= id %>"
34-
data-icon="<%= asset_path page.random_image_including_private(format: :thumb) %>"
35-
<%= 'selected' if field[:value].include?("#{page_type}-#{id}") %>
32+
<% @linkables_raw.fetch(page_type.name, []).each do |linkable| %>
33+
<option value="<%= page_type %>-<%= linkable.id %>"
34+
data-icon="<%= asset_path linkable.random_image_including_private(format: :thumb) %>"
35+
<%= 'selected' if field[:value].include?("#{page_type}-#{linkable.id}") %>
3636
>
37-
<%= name %>
37+
<%= linkable.name %>
3838
</option>
3939
<% end %>
4040
</optgroup>

0 commit comments

Comments
 (0)