Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verification System Improvements #58

Merged
merged 6 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Allow mods to toggle sort asc/desc on verification index view.
  • Loading branch information
deadroxy committed Aug 10, 2023
commit e28a815899b29183cd97814f52721177a359cc98
16 changes: 11 additions & 5 deletions app/assets/stylesheets/backstage.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,21 @@
}

#backstage-container .panel-filters a {
margin-top: 0.5em;
margin-left: 0.5em;
margin-right: 0.5em;
margin-bottom: 0.5em;
padding-top: 0.5em;
padding-left: 0.5em;
padding-right: 0.5em;
padding-bottom: 0.5em;
}

#backstage-container .panel-filters a.selected {
padding-right: 0em;
font-weight: 700;
color: var(--light-black-color);
color: var(--light-black-color);
}

#backstage-container .panel-filters a.ordering {
color: var(--light-black-color);
font-family: var(--solid-icon-font);
}

#backstage-container .panel-filters a:hover {
Expand Down
23 changes: 15 additions & 8 deletions app/controllers/verifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,29 @@ def index
else
per_page = 30
end

# f is used to filter reports by scope
# q is used to search for keywords
if (params[:f].present? && Verification::SORT_FILTERS.key?(params[:f].to_sym)) && params[:q].present?
@verifications = eval("Verification."+params[:f]+".search('"+params[:q]+"').order(requested_on: :asc).paginate(page: params[:page], per_page: "+per_page.to_s+")")
@filter_category = params[:f]
elsif params[:f].present? && Verification::SORT_FILTERS.key?(params[:f].to_sym)
@verifications = eval("Verification."+params[:f]+".order(requested_on: :asc).paginate(page: params[:page], per_page: "+per_page.to_s+")")
# o is used to toggle ordering
if params[:f].present? && Verification::SORT_FILTERS.key?(params[:f].to_sym)
@filter_category = params[:f]
elsif params[:q].present?
@verifications = Verification.all.search(params[:q]).order(requested_on: :asc).paginate(page: params[:page], per_page: per_page)
@filter_category = "all"
else
@verifications = Verification.pending.order(requested_on: :asc).paginate(page: params[:page], per_page: per_page)
@filter_category = "pending"
end

if params[:o].present? && params[:o] == "desc"
@ordering = "desc"
else
@ordering = "asc"
end

if params[:q].present?
@verifications = eval("Verification.#{@filter_category}.search('#{params[:q]}').order(requested_on: :#{@ordering}).paginate(page: params[:page], per_page: #{per_page.to_s})")
else
@verifications = eval("Verification.#{@filter_category}.order(requested_on: :#{@ordering}).paginate(page: params[:page], per_page: #{per_page.to_s})")
end
end

def show
Expand Down
4 changes: 3 additions & 1 deletion app/views/verifications/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
<% if @filter_category.to_s == filter[0].to_s %>
<% if params[:q].present? %>
<%= link_to("#{filter[1]} [#{@verifications.nil? ? '0' : @verifications.count}]", verifications_path(q: params[:q], f: filter[0]), class: "filter selected") %>
<%= link_to(@ordering == "asc" ? "&#xf309;".html_safe : "&#xf30c;".html_safe, verifications_path(q: params[:q], f: filter[0], o: @ordering == "asc" ? "desc" : "asc"), class: "ordering") %>
<% else %>
<%= link_to("#{filter[1]} [#{@verifications.nil? ? '0' : @verifications.count}]", verifications_path(f: filter[0]), class: "filter selected") %>
<%= link_to("#{filter[1]} [#{@verifications.nil? ? '0' : @verifications.count}]", verifications_path(f: filter[0]), class: "filter selected") %>
<%= link_to(@ordering == "asc" ? "&#xf309;".html_safe : "&#xf30c;".html_safe, verifications_path(f: filter[0], o: @ordering == "asc" ? "desc" : "asc"), class: "ordering") %>
<% end %>
<% else %>
<% if params[:q].present? %>
Expand Down