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
Léo-Paul Géneau
gitlab-ce
Commits
259970ca
Commit
259970ca
authored
Apr 16, 2016
by
Arinde Eniola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
abstract code for removing or getting a param query string from url
parent
ef9f5579
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
17 deletions
+19
-17
app/assets/javascripts/issues.js.coffee
app/assets/javascripts/issues.js.coffee
+3
-17
app/assets/javascripts/lib/url_utility.js.coffee
app/assets/javascripts/lib/url_utility.js.coffee
+16
-0
No files found.
app/assets/javascripts/issues.js.coffee
View file @
259970ca
...
...
@@ -36,20 +36,6 @@
$
(
".selected_issue"
).
bind
"change"
,
Issues
.
checkChanged
getLabelsQueryString
:
->
pageURL
=
decodeURIComponent
(
window
.
location
.
search
.
substring
(
1
))
urlVariables
=
pageURL
.
split
(
'&'
)
labelParams
=
(
variables
for
variables
in
urlVariables
when
variables
.
indexOf
(
'label_name[]'
)
>
-
1
).
join
(
'&'
)
removeLabelsQueryString
:
(
url
)
->
pageURL
=
decodeURIComponent
(
url
)
urlVariables
=
pageURL
.
split
(
'&'
)
Params
=
(
variables
for
variables
in
urlVariables
when
variables
.
indexOf
(
'label_name[]'
)
is
-
1
).
join
(
'&'
)
# Update state filters if present in page
updateStateFilters
:
->
stateFilters
=
$
(
'.issues-state-filters'
)
...
...
@@ -61,9 +47,9 @@
if
stateFilters
.
length
stateFilters
.
find
(
'a'
).
each
->
initialUrl
=
Issues
.
removeLabelsQueryString
(
$
(
this
).
attr
'href
'
)
if
Issues
.
getLabelsQueryString
(
)
newUrl
=
"
#{
gl
.
utils
.
mergeUrlParams
(
newParams
,
initialUrl
)
}
&
#{
Issues
.
getLabelsQueryString
(
)
}
"
initialUrl
=
gl
.
utils
.
removeParamQueryString
(
$
(
this
).
attr
(
'href'
),
'label_name[]
'
)
if
gl
.
utils
.
getParamQueryString
(
'label_name[]'
)
newUrl
=
"
#{
gl
.
utils
.
mergeUrlParams
(
newParams
,
initialUrl
)
}
&
#{
gl
.
utils
.
getParamQueryString
(
'label_name[]'
)
}
"
else
newUrl
=
gl
.
utils
.
mergeUrlParams
(
newParams
,
initialUrl
)
$
(
this
).
attr
'href'
,
newUrl
...
...
app/assets/javascripts/lib/url_utility.js.coffee
View file @
259970ca
...
...
@@ -28,4 +28,20 @@
newUrl
=
"
#{
newUrl
}#{
(
if
newUrl
.
indexOf
(
'?'
)
>
0
then
'&'
else
'?'
)
}#{
paramName
}
=
#{
paramValue
}
"
newUrl
# get parameter query string from url.
w
.
gl
.
utils
.
getParamQueryString
=
(
param
)
->
pageURL
=
decodeURIComponent
(
window
.
location
.
search
.
substring
(
1
))
urlVariables
=
pageURL
.
split
(
'&'
)
(
variables
for
variables
in
urlVariables
when
variables
.
indexOf
(
param
)
>
-
1
).
join
(
'&'
)
# removes parameter query string from url. returns the modified url
w
.
gl
.
utils
.
removeParamQueryString
=
(
url
,
param
)
->
url
=
decodeURIComponent
(
url
)
urlVariables
=
url
.
split
(
'&'
)
(
variables
for
variables
in
urlVariables
when
variables
.
indexOf
(
param
)
is
-
1
).
join
(
'&'
)
)
window
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