user feedbacks: reorganize index page.

* Move search form to index page instead of a separate page.
* Merge creator + timestamp into one column.
* Add category column.
* Fix N+1 query issue.
This commit is contained in:
evazion
2019-10-30 23:24:37 -05:00
parent 1f191d2cdf
commit 55a2c6de2b
5 changed files with 27 additions and 30 deletions

View File

@@ -20,7 +20,7 @@ class UserFeedbacksController < ApplicationController
end
def index
@user_feedbacks = UserFeedback.visible.paginated_search(params, count_pages: true)
@user_feedbacks = UserFeedback.visible.includes(:user, :creator).paginated_search(params, count_pages: true)
respond_with(@user_feedbacks)
end

View File

@@ -9,5 +9,4 @@
<% end %>
<% end %>
<%= subnav_link_to "Listing", user_feedbacks_path %>
<%= subnav_link_to "Search", search_user_feedbacks_path %>
<% end %>

View File

@@ -2,28 +2,45 @@
<div id="a-index">
<h1>User Feedback</h1>
<table class="striped" width="100%">
<%= search_form_for(user_feedbacks_path) do |f| %>
<%= f.input :user_name, input_html: { value: params.dig(:search, :user_name), "data-autocomplete": "user" } %>
<%= f.input :creator_name, input_html: { value: params.dig(:search, :creator_name), "data-autocomplete": "user" } %>
<%= f.input :body_matches, label: "Message", input_html: { value: params.dig(:search, :body_matches) } %>
<%= f.input :category, collection: %w[positive negative neutral], include_blank: true, selected: params.dig(:search, :category) %>
<%= f.submit "Search" %>
<% end %>
<table class="striped autofit">
<thead>
<tr>
<th width="15%">User</th>
<th width="15%">Creator</th>
<th width="15%">When</th>
<th width="45%">Message</th>
<th>User</th>
<th>Message</th>
<th>Category</th>
<th>Creator</th>
<th></th>
</tr>
</thead>
<tbody>
<% @user_feedbacks.each do |feedback| %>
<tr class="feedback-category-<%= feedback.category %>">
<td><%= link_to_user feedback.user %></td>
<td><%= link_to_user feedback.creator %></td>
<td><%= compact_time(feedback.created_at) %></td>
<td>
<%= link_to_user feedback.user %>
<%= link_to "»", user_feedbacks_path(search: { user_name: feedback.user.name }) %>
</td>
<td class="col-expand">
<div class="prose">
<%= format_text(feedback.body) %>
</div>
<%= render "application/update_notice", record: feedback, interval: 0.minutes %>
</td>
<td>
<%= link_to feedback.category.capitalize, user_feedbacks_path(search: { category: feedback.category }) %>
</td>
<td>
<%= link_to_user feedback.creator %>
<%= link_to "»", user_feedbacks_path(search: { creator_name: feedback.creator.name }) %>
<div><%= time_ago_in_words_tagged(feedback.created_at) %></div>
</td>
<td>
<% if feedback.editable_by?(CurrentUser.user) %>
<%= link_to "edit", edit_user_feedback_path(feedback) %>

View File

@@ -1,15 +0,0 @@
<div id="c-user-feedbacks">
<div id="a-search">
<h1>Search User Feedbacks</h1>
<%= search_form_for(user_feedbacks_path) do |f| %>
<%= f.input :user_name, input_html: { value: params.dig(:search, :user_name), "data-autocomplete": "user" } %>
<%= f.input :creator_name, input_html: { value: params.dig(:search, :creator_name), "data-autocomplete": "user" } %>
<%= f.input :body_matches, label: "Message", input_html: { value: params.dig(:search, :body_matches) } %>
<%= f.input :category, collection: %w[positive negative neutral], include_blank: true, selected: params.dig(:search, :category) %>
<%= f.submit "Search" %>
<% end %>
</div>
</div>
<%= render "secondary_links" %>

View File

@@ -293,11 +293,7 @@ Rails.application.routes.draw do
end
end
resource :user_upgrade, :only => [:new, :create, :show]
resources :user_feedbacks do
collection do
get :search
end
end
resources :user_feedbacks
resources :user_name_change_requests, only: [:new, :create, :show, :index]
resources :wiki_pages do
member do