Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def allowed_model(model_param)
"workshop" => Workshop,
"organization" => Organization,
"event" => Event,
"event_registration" => EventRegistration
"event_registration" => EventRegistration,
"resource" => Resource
}[model_param]
end

Expand Down
3 changes: 2 additions & 1 deletion app/models/resource.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Resource < ApplicationRecord
include AuthorCreditable, Featureable, Publishable, TagFilterable, Trendable, WindowsTypeFilterable, RichTextSearchable
include AuthorCreditable, Featureable, Publishable, RemoteSearchable, TagFilterable, Trendable, WindowsTypeFilterable, RichTextSearchable
remote_searchable_by :title
include Rails.application.routes.url_helpers
include ActionText::Attachable
include Mentionable
Expand Down
4 changes: 4 additions & 0 deletions app/policies/resource_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def create?
admin?
end

def search?
authenticated?
end

def update?
admin?
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
under the title on the resource's own page. %>
<div class="nested-fields flex items-start gap-2">
<div class="flex-1 min-w-0 grid grid-cols-1 sm:grid-cols-3 gap-2">
<%= f.collection_select :resource_id, Resource.order(:title), :id, :title,
{ include_blank: "Select a resource…" },
class: "rounded border-gray-300 bg-white shadow-sm px-2 py-1 text-sm" %>
<% resource = f.object.resource %>
<select
name="<%= f.field_name(:resource_id) %>"
id="<%= f.field_id(:resource_id) %>"
data-controller="remote-select"
data-remote-select-model-value="resource"
class="rounded border-gray-300 bg-white shadow-sm px-2 py-1 text-sm">
<option value="">Type to search resources…</option>
<% if resource %>
<option value="<%= resource.id %>" selected><%= resource.title %></option>
<% end %>
</select>
<%= f.text_field :subtitle, placeholder: "Short one-line",
class: "rounded border-gray-300 bg-white shadow-sm px-2 py-1 text-sm" %>
<%= f.text_area :page_content, rows: 2, placeholder: "Shown under the title",
Expand Down