mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
use linkable images in dropdowns instead of current page's image
This commit is contained in:
parent
d0b9a77b58
commit
bfa9b59100
@ -96,6 +96,7 @@ class ApplicationController < ActionController::Base
|
||||
linkable_classes += %w(Document Timeline)
|
||||
|
||||
@linkables_cache = {}
|
||||
@linkables_raw = {}
|
||||
linkable_classes.each do |class_name|
|
||||
# class_name = "Character"
|
||||
|
||||
@ -109,6 +110,10 @@ class ApplicationController < ActionController::Base
|
||||
.reject { |content| content.class.name == class_name && content.id == @content.id }
|
||||
end
|
||||
|
||||
@linkables_raw[class_name] = @linkables_cache[class_name]
|
||||
.sort_by { |p| p.name.downcase }
|
||||
.compact
|
||||
|
||||
@linkables_cache[class_name] = @linkables_cache[class_name]
|
||||
.sort_by { |p| p.name.downcase }
|
||||
.map { |c| [c.name, c.id] }
|
||||
|
||||
@ -155,7 +155,7 @@ class User < ApplicationRecord
|
||||
universe_id IN (#{(my_universe_ids + contributable_universe_ids + [-1]).uniq.join(',')})
|
||||
OR
|
||||
(universe_id IS NULL AND user_id = #{self.id.to_i})
|
||||
""").where(archived_at: nil)
|
||||
""")
|
||||
end
|
||||
|
||||
def linkable_timelines
|
||||
|
||||
@ -29,12 +29,12 @@
|
||||
field[:value]
|
||||
)
|
||||
%>
|
||||
<% @linkables_cache.fetch(page_type.name, []).sort_by { |name, id| name.downcase }.each do |name, id| %>
|
||||
<option value="<%= page_type %>-<%= id %>"
|
||||
data-icon="<%= asset_path page.random_image_including_private(format: :thumb) %>"
|
||||
<%= 'selected' if field[:value].include?("#{page_type}-#{id}") %>
|
||||
<% @linkables_raw.fetch(page_type.name, []).each do |linkable| %>
|
||||
<option value="<%= page_type %>-<%= linkable.id %>"
|
||||
data-icon="<%= asset_path linkable.random_image_including_private(format: :thumb) %>"
|
||||
<%= 'selected' if field[:value].include?("#{page_type}-#{linkable.id}") %>
|
||||
>
|
||||
<%= name %>
|
||||
<%= linkable.name %>
|
||||
</option>
|
||||
<% end %>
|
||||
</optgroup>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user