implements organizations search for admins
This commit is contained in:
@@ -2,13 +2,17 @@ class Admin::OrganizationsController < Admin::BaseController
|
||||
before_filter :set_valid_filters, only: :index
|
||||
before_filter :parse_filter, only: :index
|
||||
|
||||
load_and_authorize_resource
|
||||
load_and_authorize_resource except: :search
|
||||
|
||||
def index
|
||||
@organizations = @organizations.send(@filter)
|
||||
@organizations = @organizations.includes(:user).order(:name, 'users.email').page(params[:page])
|
||||
end
|
||||
|
||||
def search
|
||||
@organizations = Organization.search(params[:term]).page(params[:page])
|
||||
end
|
||||
|
||||
def verify
|
||||
@organization.verify
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<h2><%= t("admin.organizations.index.title") %></h2>
|
||||
|
||||
<!-- Search organizations -->
|
||||
<%= form_for(User.new, url: search_admin_officials_path, as: :user, method: :get) do |f| %>
|
||||
<%= form_for(Organization.new, url: search_admin_organizations_path, method: :get) do |f| %>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= text_field_tag :email, "", placeholder: t("admin.officials.index.search_email_placeholder") %>
|
||||
<%= text_field_tag :term, "", placeholder: t("admin.organizations.index.search_placeholder") %>
|
||||
</div>
|
||||
<div class="form-inline small-12 medium-6 column">
|
||||
<%= f.submit t("admin.officials.index.search"), class: "button radius success" %>
|
||||
<%= f.submit t("admin.organizations.index.search"), class: "button radius success" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
55
app/views/admin/organizations/search.html.erb
Normal file
55
app/views/admin/organizations/search.html.erb
Normal file
@@ -0,0 +1,55 @@
|
||||
<h2><%= t("admin.organizations.search.title") %></h2>
|
||||
|
||||
<!-- Search organizations -->
|
||||
<%= form_for(Organization.new, url: search_admin_organizations_path, method: :get) do |f| %>
|
||||
<div class="row">
|
||||
<div class="small-12 medium-6 column">
|
||||
<%= text_field_tag :term, "", placeholder: t("admin.organizations.index.search_placeholder") %>
|
||||
</div>
|
||||
<div class="form-inline small-12 medium-6 column">
|
||||
<%= f.submit t("admin.organizations.index.search"), class: "button radius success" %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- /. Search organizations -->
|
||||
|
||||
<h3><%= page_entries_info @organizations %></h3>
|
||||
|
||||
<table id="search-results">
|
||||
<% @organizations.each do |organization| %>
|
||||
<tr>
|
||||
<td><%= organization.name %></td>
|
||||
<td><%= organization.email %></td>
|
||||
<td><%= organization.phone_number %></td>
|
||||
<% if organization.verified? %>
|
||||
<td class="verified">
|
||||
<i class="icon-check"></i>
|
||||
<%= t("admin.organizations.index.verified") %>
|
||||
</td>
|
||||
<% end %>
|
||||
<% if can? :verify, organization %>
|
||||
<td>
|
||||
<%= link_to t("admin.organizations.index.verify"),
|
||||
verify_admin_organization_path(organization, request.query_parameters),
|
||||
method: :put, class: "button radius tiny success"
|
||||
%>
|
||||
</td>
|
||||
<% end %>
|
||||
<% if organization.rejected? %>
|
||||
<td class="rejected">
|
||||
<i class="icon-x"></i>
|
||||
<%= t("admin.organizations.index.rejected") %>
|
||||
</td>
|
||||
<% end %>
|
||||
<% if can? :reject, organization %>
|
||||
<td><%= link_to t("admin.organizations.index.reject"),
|
||||
reject_admin_organization_path(organization, request.query_parameters),
|
||||
method: :put, class: "button radius tiny alert"
|
||||
%>
|
||||
</td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<%= paginate @organizations %>
|
||||
Reference in New Issue
Block a user