sorting_helper.rb 4.24 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's avatar
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
      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,
28
      sort_value_oldest_created => sort_title_oldest_created
29
    }
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

38 39
  def member_sort_options_hash
    {
40 41
      sort_value_access_level_asc => sort_title_access_level_asc,
      sort_value_access_level_desc => sort_title_access_level_desc,
42 43 44 45 46 47 48 49 50
      sort_value_last_joined => sort_title_last_joined,
      sort_value_oldest_joined => sort_title_oldest_joined,
      sort_value_name => sort_title_name_asc,
      sort_value_name_desc => sort_title_name_desc,
      sort_value_recently_signin => sort_title_recently_signin,
      sort_value_oldest_signin => sort_title_oldest_signin
    }
  end

Thijs Wouters's avatar
Thijs Wouters committed
51 52 53 54
  def sort_title_priority
    'Priority'
  end

55 56 57 58 59
  def sort_title_oldest_updated
    'Oldest updated'
  end

  def sort_title_recently_updated
Jacob Schatz's avatar
Jacob Schatz committed
60
    'Last updated'
61 62 63
  end

  def sort_title_oldest_created
64
    'Oldest created'
65 66 67
  end

  def sort_title_recently_created
Jacob Schatz's avatar
Jacob Schatz committed
68
    'Last created'
69
  end
70 71 72 73 74 75 76 77 78

  def sort_title_milestone_soon
    'Milestone due soon'
  end

  def sort_title_milestone_later
    'Milestone due later'
  end

79
  def sort_title_due_date_soon
80
    'Due soon'
81 82 83
  end

  def sort_title_due_date_later
84
    'Due later'
85 86
  end

87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
  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

103 104 105 106 107 108 109 110
  def sort_title_downvotes
    'Least popular'
  end

  def sort_title_upvotes
    'Most popular'
  end

111 112 113 114 115 116 117 118
  def sort_title_last_joined
    'Last joined'
  end

  def sort_title_oldest_joined
    'Oldest joined'
  end

119 120 121 122 123 124 125 126
  def sort_title_access_level_asc
    'Access level, ascending'
  end

  def sort_title_access_level_desc
    'Access level, descending'
  end

127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
  def sort_title_name_asc
    'Name, ascending'
  end

  def sort_title_name_desc
    'Name, descending'
  end

  def sort_value_last_joined
    'last_joined'
  end

  def sort_value_oldest_joined
    'oldest_joined'
  end

143 144 145 146 147 148 149 150
  def sort_value_access_level_asc
    'access_level_asc'
  end

  def sort_value_access_level_desc
    'access_level_desc'
  end

151 152 153 154
  def sort_value_name_desc
    'name_desc'
  end

Thijs Wouters's avatar
Thijs Wouters committed
155 156 157 158
  def sort_value_priority
    'priority'
  end

159 160 161 162 163 164 165 166 167
  def sort_value_oldest_updated
    'updated_asc'
  end

  def sort_value_recently_updated
    'updated_desc'
  end

  def sort_value_oldest_created
168
    'created_asc'
169 170 171
  end

  def sort_value_recently_created
172
    'created_desc'
173 174 175 176 177 178 179 180 181 182
  end

  def sort_value_milestone_soon
    'milestone_due_asc'
  end

  def sort_value_milestone_later
    'milestone_due_desc'
  end

183 184 185 186 187 188 189 190
  def sort_value_due_date_soon
    'due_date_asc'
  end

  def sort_value_due_date_later
    'due_date_desc'
  end

191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
  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
206 207 208 209 210 211 212 213

  def sort_value_downvotes
    'downvotes_desc'
  end

  def sort_value_upvotes
    'upvotes_desc'
  end
214
end