Add order options to relationship manager UI (#10404)

This commit is contained in:
Eugen Rochko 2019-03-28 02:16:01 +01:00 committed by GitHub
parent 683013756e
commit 08ec7435ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 5 deletions

View file

@ -31,13 +31,14 @@ class RelationshipsController < ApplicationController
def relationships_scope def relationships_scope
scope = begin scope = begin
if following_relationship? if following_relationship?
current_account.following.joins(:account_stat) current_account.following.eager_load(:account_stat).reorder(nil)
else else
current_account.followers.joins(:account_stat) current_account.followers.eager_load(:account_stat).reorder(nil)
end end
end end
scope.merge!(Follow.recent) scope.merge!(Follow.recent) if params[:order].blank? || params[:order] == 'recent'
scope.merge!(Account.by_recent_status) if params[:order] == 'active'
scope.merge!(mutual_relationship_scope) if mutual_relationship? scope.merge!(mutual_relationship_scope) if mutual_relationship?
scope.merge!(moved_account_scope) if params[:status] == 'moved' scope.merge!(moved_account_scope) if params[:status] == 'moved'
scope.merge!(primary_account_scope) if params[:status] == 'primary' scope.merge!(primary_account_scope) if params[:status] == 'primary'
@ -84,7 +85,7 @@ class RelationshipsController < ApplicationController
end end
def current_params def current_params
params.slice(:page, :status, :relationship, :by_domain, :activity).permit(:page, :status, :relationship, :by_domain, :activity) params.slice(:page, :status, :relationship, :by_domain, :activity, :order).permit(:page, :status, :relationship, :by_domain, :activity, :order)
end end
def action_from_button def action_from_button

View file

@ -7,7 +7,7 @@ module Admin::FilterHelper
CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze
TAGS_FILTERS = %i(hidden).freeze TAGS_FILTERS = %i(hidden).freeze
INSTANCES_FILTERS = %i(limited by_domain).freeze INSTANCES_FILTERS = %i(limited by_domain).freeze
FOLLOWERS_FILTERS = %i(relationship status by_domain activity).freeze FOLLOWERS_FILTERS = %i(relationship status by_domain activity order).freeze
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER + CUSTOM_EMOJI_FILTERS + TAGS_FILTERS + INSTANCES_FILTERS + FOLLOWERS_FILTERS FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER + CUSTOM_EMOJI_FILTERS + TAGS_FILTERS + INSTANCES_FILTERS + FOLLOWERS_FILTERS

View file

@ -25,11 +25,18 @@
%li= filter_link_to t('generic.all'), activity: nil %li= filter_link_to t('generic.all'), activity: nil
%li= filter_link_to t('relationships.dormant'), activity: 'dormant' %li= filter_link_to t('relationships.dormant'), activity: 'dormant'
.filter-subset
%strong= t 'generic.order_by'
%ul
%li= filter_link_to t('relationships.most_recent'), order: nil
%li= filter_link_to t('relationships.last_active'), order: 'active'
= form_for(@form, url: relationships_path, method: :patch) do |f| = form_for(@form, url: relationships_path, method: :patch) do |f|
= hidden_field_tag :page, params[:page] || 1 = hidden_field_tag :page, params[:page] || 1
= hidden_field_tag :relationship, params[:relationship] = hidden_field_tag :relationship, params[:relationship]
= hidden_field_tag :status, params[:status] = hidden_field_tag :status, params[:status]
= hidden_field_tag :activity, params[:activity] = hidden_field_tag :activity, params[:activity]
= hidden_field_tag :order, params[:order]
.batch-table .batch-table
.batch-table__toolbar .batch-table__toolbar

View file

@ -774,6 +774,8 @@ en:
relationships: relationships:
activity: Account activity activity: Account activity
dormant: Dormant dormant: Dormant
last_active: Last active
most_recent: Most recent
moved: Moved moved: Moved
mutual: Mutual mutual: Mutual
primary: Primary primary: Primary