BigW Consortium Gitlab

sorting_helper.rb 3.08 KB
Newer Older
1
module SortingHelper
2 3 4 5 6 7 8 9 10
  def sort_options_hash
    {
      sort_value_name => sort_title_name,
      sort_value_recently_updated => sort_title_recently_updated,
      sort_value_oldest_updated => sort_title_oldest_updated,
      sort_value_recently_created => sort_title_recently_created,
      sort_value_oldest_created => sort_title_oldest_created,
      sort_value_milestone_soon => sort_title_milestone_soon,
      sort_value_milestone_later => sort_title_milestone_later,
11 12
      sort_value_due_date_soon => sort_title_due_date_soon,
      sort_value_due_date_later => sort_title_due_date_later,
13 14 15
      sort_value_largest_repo => sort_title_largest_repo,
      sort_value_recently_signin => sort_title_recently_signin,
      sort_value_oldest_signin => sort_title_oldest_signin,
16
      sort_value_downvotes => sort_title_downvotes,
Thijs Wouters committed
17 18
      sort_value_upvotes => sort_title_upvotes,
      sort_value_priority => sort_title_priority
19 20 21
    }
  end

22
  def projects_sort_options_hash
23
    options = {
24 25 26 27 28 29
      sort_value_name => sort_title_name,
      sort_value_recently_updated => sort_title_recently_updated,
      sort_value_oldest_updated => sort_title_oldest_updated,
      sort_value_recently_created => sort_title_recently_created,
      sort_value_oldest_created => sort_title_oldest_created,
    }
30 31 32 33 34 35

    if current_controller?('admin/projects')
      options.merge!(sort_value_largest_repo => sort_title_largest_repo)
    end

    options
36 37
  end

Thijs Wouters committed
38 39 40 41
  def sort_title_priority
    'Priority'
  end

42 43 44 45 46
  def sort_title_oldest_updated
    'Oldest updated'
  end

  def sort_title_recently_updated
Jacob Schatz committed
47
    'Last updated'
48 49 50
  end

  def sort_title_oldest_created
51
    'Oldest created'
52 53 54
  end

  def sort_title_recently_created
Jacob Schatz committed
55
    'Last created'
56
  end
57 58 59 60 61 62 63 64 65

  def sort_title_milestone_soon
    'Milestone due soon'
  end

  def sort_title_milestone_later
    'Milestone due later'
  end

66
  def sort_title_due_date_soon
67
    'Due soon'
68 69 70
  end

  def sort_title_due_date_later
71
    'Due later'
72 73
  end

74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
  def sort_title_name
    'Name'
  end

  def sort_title_largest_repo
    'Largest repository'
  end

  def sort_title_recently_signin
    'Recent sign in'
  end

  def sort_title_oldest_signin
    'Oldest sign in'
  end

90 91 92 93 94 95 96 97
  def sort_title_downvotes
    'Least popular'
  end

  def sort_title_upvotes
    'Most popular'
  end

Thijs Wouters committed
98 99 100 101
  def sort_value_priority
    'priority'
  end

102 103 104 105 106 107 108 109 110
  def sort_value_oldest_updated
    'updated_asc'
  end

  def sort_value_recently_updated
    'updated_desc'
  end

  def sort_value_oldest_created
111
    'created_asc'
112 113 114
  end

  def sort_value_recently_created
115
    'created_desc'
116 117 118 119 120 121 122 123 124 125
  end

  def sort_value_milestone_soon
    'milestone_due_asc'
  end

  def sort_value_milestone_later
    'milestone_due_desc'
  end

126 127 128 129 130 131 132 133
  def sort_value_due_date_soon
    'due_date_asc'
  end

  def sort_value_due_date_later
    'due_date_desc'
  end

134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
  def sort_value_name
    'name_asc'
  end

  def sort_value_largest_repo
    'repository_size_desc'
  end

  def sort_value_recently_signin
    'recent_sign_in'
  end

  def sort_value_oldest_signin
    'oldest_sign_in'
  end
149 150 151 152 153 154 155 156

  def sort_value_downvotes
    'downvotes_desc'
  end

  def sort_value_upvotes
    'upvotes_desc'
  end
157
end