diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 96b30072d..5a8d61ff9 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -131,7 +131,6 @@ def set_form_variables .references(:users) .order(:created_at) @people = Person.order(Arel.sql("LOWER(first_name), LOWER(last_name)")) - @users = User.has_access.includes(:person).left_joins(:person).order(Arel.sql("people.first_name IS NULL, LOWER(people.first_name), LOWER(people.last_name), LOWER(users.email)")) @windows_types = WindowsType.all @workshops = authorized_scope(Workshop.all).includes(:windows_type).order(:title) @categories_grouped = diff --git a/app/views/stories/_form.html.erb b/app/views/stories/_form.html.erb index 15fd78dd5..4d0f94d17 100644 --- a/app/views/stories/_form.html.erb +++ b/app/views/stories/_form.html.erb @@ -274,18 +274,22 @@
<%= f.input :created_by_id, - collection: @users.map { |u| [ u.full_name_with_email, u.id ] }, - prompt: "Select an author", + collection: f.object.created_by.present? ? [[ f.object.created_by.remote_search_label[:label], f.object.created_by.id ]] : [], + selected: f.object.created_by_id, + include_blank: true, label: (f.object.created_by&.person ? ( link_to "Story author", person_path(f.object.created_by.person), class: "hover:underline") : "Story author").html_safe, label_html: { class: "block font-medium mb-1 text-gray-700" }, input_html: { - class: select_caret_class(blank: f.object.created_by_id.blank?), - style: custom_caret_style, - onchange: select_caret_onchange - } %> + class: "w-full px-3 py-2 border border-gray-300 rounded-lg", + data: { + controller: "remote-select", + remote_select_model_value: "user" + } + }, + prompt: "Type to search authors…" %>