Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
4d345bc4
Commit
4d345bc4
authored
Jan 20, 2016
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remember last sort option used.
parent
1553c560
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
2 deletions
+30
-2
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+21
-1
app/models/concerns/cookie_helpers.rb
app/models/concerns/cookie_helpers.rb
+5
-0
app/models/group.rb
app/models/group.rb
+2
-1
app/models/project.rb
app/models/project.rb
+1
-0
app/models/user.rb
app/models/user.rb
+1
-0
No files found.
app/controllers/application_controller.rb
View file @
4d345bc4
...
@@ -297,7 +297,8 @@ class ApplicationController < ActionController::Base
...
@@ -297,7 +297,8 @@ class ApplicationController < ActionController::Base
end
end
def
set_filters_params
def
set_filters_params
params
[
:sort
]
||=
'id_desc'
set_default_sort
params
[
:scope
]
=
'all'
if
params
[
:scope
].
blank?
params
[
:scope
]
=
'all'
if
params
[
:scope
].
blank?
params
[
:state
]
=
'opened'
if
params
[
:state
].
blank?
params
[
:state
]
=
'opened'
if
params
[
:state
].
blank?
...
@@ -404,4 +405,23 @@ class ApplicationController < ActionController::Base
...
@@ -404,4 +405,23 @@ class ApplicationController < ActionController::Base
current_user
.
nil?
&&
root_path
==
request
.
path
current_user
.
nil?
&&
root_path
==
request
.
path
end
end
private
def
set_default_sort
controller_name
=
params
[
:controller
].
sub
(
/Controller\Z/
,
''
).
underscore
cookie_suffix
=
"_sort_
#{
controller_name
}
"
key
=
if
@project
"
#{
@project
.
cookie_key
}#{
cookie_suffix
}
"
elsif
@group
"
#{
@group
.
cookie_key
}#{
cookie_suffix
}
"
else
"
#{
current_user
.
cookie_key
}#{
cookie_suffix
}
"
end
cookies
[
key
]
||=
'id_desc'
cookies
[
key
]
=
params
[
:sort
]
if
params
[
:sort
].
present?
params
[
:sort
]
=
cookies
[
key
]
end
end
end
app/models/concerns/cookie_helpers.rb
0 → 100644
View file @
4d345bc4
module
CookieHelpers
def
cookie_key
"
#{
model_name
.
singular
}
_
#{
id
}
"
end
end
app/models/group.rb
View file @
4d345bc4
...
@@ -19,7 +19,8 @@ require 'file_size_validator'
...
@@ -19,7 +19,8 @@ require 'file_size_validator'
class
Group
<
Namespace
class
Group
<
Namespace
include
Gitlab
::
ConfigHelper
include
Gitlab
::
ConfigHelper
include
Referable
include
Referable
include
CookieHelpers
has_many
:group_members
,
dependent: :destroy
,
as: :source
,
class_name:
'GroupMember'
has_many
:group_members
,
dependent: :destroy
,
as: :source
,
class_name:
'GroupMember'
alias_method
:members
,
:group_members
alias_method
:members
,
:group_members
has_many
:users
,
through: :group_members
has_many
:users
,
through: :group_members
...
...
app/models/project.rb
View file @
4d345bc4
...
@@ -51,6 +51,7 @@ class Project < ActiveRecord::Base
...
@@ -51,6 +51,7 @@ class Project < ActiveRecord::Base
include
AfterCommitQueue
include
AfterCommitQueue
include
CaseSensitivity
include
CaseSensitivity
include
TokenAuthenticatable
include
TokenAuthenticatable
include
CookieHelpers
extend
Gitlab
::
ConfigHelper
extend
Gitlab
::
ConfigHelper
...
...
app/models/user.rb
View file @
4d345bc4
...
@@ -73,6 +73,7 @@ class User < ActiveRecord::Base
...
@@ -73,6 +73,7 @@ class User < ActiveRecord::Base
include
Sortable
include
Sortable
include
CaseSensitivity
include
CaseSensitivity
include
TokenAuthenticatable
include
TokenAuthenticatable
include
CookieHelpers
add_authentication_token_field
:authentication_token
add_authentication_token_field
:authentication_token
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment