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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
0acc3e2b
Commit
0acc3e2b
authored
Dec 13, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix conflict for app/assets/javascripts/search_autocomplete.js
parent
12cc5bef
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
335 deletions
+1
-335
app/assets/javascripts/search_autocomplete.js
app/assets/javascripts/search_autocomplete.js
+1
-335
No files found.
app/assets/javascripts/search_autocomplete.js
View file @
0acc3e2b
/* eslint-disable
no-return-assign, one-var, no-var, no-underscore-dangle, one-var-declaration-per-line, no-unused-vars, no-cond-assign, consistent-return, object-shorthand, prefer-arrow-callback, func-names, space-before-function-paren, prefer-template, quotes, class-methods-use-thi
s, no-sequences, wrap-iife, no-lonely-if, no-else-return, no-param-reassign, vars-on-top, max-len */
/* eslint-disable
comma-dangle, no-return-assign, one-var, no-var, no-underscore-dangle, one-var-declaration-per-line, no-unused-vars, no-cond-assign, consistent-return, object-shorthand, prefer-arrow-callback, func-names, space-before-function-paren, prefer-template, quotes, class-methods-use-this, no-unused-expression
s, no-sequences, wrap-iife, no-lonely-if, no-else-return, no-param-reassign, vars-on-top, max-len */
import
{
isInGroupsPage
,
isInProjectPage
,
getGroupSlug
,
getProjectSlug
}
from
'
./lib/utils/common_utils
'
;
<<<<<<<
HEAD
/**
* Search input in top navigation bar.
* On click, opens a dropdown
* As the user types it filters the results
* When the user clicks `x` button it cleans the input and closes the dropdown.
*/
((
global
)
=>
{
const
KEYCODE
=
{
ESCAPE
:
27
,
BACKSPACE
:
8
,
ENTER
:
13
,
UP
:
38
,
DOWN
:
40
,
};
class
SearchAutocomplete
{
constructor
({
wrap
,
optsEl
,
autocompletePath
,
projectId
,
projectRef
}
=
{})
{
this
.
bindEventContext
();
this
.
wrap
=
wrap
||
$
(
'
.search
'
);
this
.
optsEl
=
optsEl
||
this
.
wrap
.
find
(
'
.search-autocomplete-opts
'
);
this
.
autocompletePath
=
autocompletePath
||
this
.
optsEl
.
data
(
'
autocomplete-path
'
);
this
.
projectId
=
projectId
||
(
this
.
optsEl
.
data
(
'
autocomplete-project-id
'
)
||
''
);
this
.
projectRef
=
projectRef
||
(
this
.
optsEl
.
data
(
'
autocomplete-project-ref
'
)
||
''
);
this
.
dropdown
=
this
.
wrap
.
find
(
'
.dropdown
'
);
this
.
dropdownToggle
=
this
.
wrap
.
find
(
'
.js-dropdown-search-toggle
'
);
this
.
dropdownContent
=
this
.
dropdown
.
find
(
'
.dropdown-content
'
);
this
.
locationBadgeEl
=
this
.
getElement
(
'
.location-badge
'
);
this
.
scopeInputEl
=
this
.
getElement
(
'
#scope
'
);
this
.
searchInput
=
this
.
getElement
(
'
.search-input
'
);
this
.
projectInputEl
=
this
.
getElement
(
'
#search_project_id
'
);
this
.
groupInputEl
=
this
.
getElement
(
'
#group_id
'
);
this
.
searchCodeInputEl
=
this
.
getElement
(
'
#search_code
'
);
this
.
repositoryInputEl
=
this
.
getElement
(
'
#repository_ref
'
);
this
.
clearInput
=
this
.
getElement
(
'
.js-clear-input
'
);
this
.
saveOriginalState
();
// Only when user is logged in
if
(
gon
.
current_user_id
)
{
this
.
createAutocomplete
();
}
this
.
searchInput
.
addClass
(
'
disabled
'
);
this
.
saveTextLength
();
this
.
bindEvents
();
this
.
dropdownToggle
.
dropdown
();
}
// Finds an element inside wrapper element
bindEventContext
()
{
this
.
onSearchInputBlur
=
this
.
onSearchInputBlur
.
bind
(
this
);
this
.
onClearInputClick
=
this
.
onClearInputClick
.
bind
(
this
);
this
.
onSearchInputFocus
=
this
.
onSearchInputFocus
.
bind
(
this
);
this
.
onSearchInputKeyUp
=
this
.
onSearchInputKeyUp
.
bind
(
this
);
this
.
onSearchInputKeyDown
=
this
.
onSearchInputKeyDown
.
bind
(
this
);
}
getElement
(
selector
)
{
return
this
.
wrap
.
find
(
selector
);
}
=======
const
KEYCODE
=
{
ESCAPE
:
27
,
BACKSPACE
:
8
,
...
...
@@ -90,7 +29,6 @@ function setSearchOptions() {
if
(
$groupOptionsDataEl
.
length
)
{
gl
.
groupOptions
=
gl
.
groupOptions
||
{};
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
var
groupPath
=
$groupOptionsDataEl
.
data
(
'
group-path
'
);
...
...
@@ -101,24 +39,6 @@ function setSearchOptions() {
};
}
<<<<<<<
HEAD
createAutocomplete
()
{
return
this
.
searchInput
.
glDropdown
({
filterInputBlur
:
false
,
filterable
:
true
,
filterRemote
:
true
,
highlight
:
true
,
enterCallback
:
false
,
filterInput
:
'
input#search
'
,
search
:
{
fields
:
[
'
text
'
],
},
id
:
this
.
getSearchText
,
data
:
this
.
getData
.
bind
(
this
),
selectable
:
true
,
clicked
:
this
.
onClick
.
bind
(
this
),
});
=======
if
(
$dashboardOptionsDataEl
.
length
)
{
gl
.
dashboardOptions
=
{
issuesPath
:
$dashboardOptionsDataEl
.
data
(
'
issues-path
'
),
...
...
@@ -150,7 +70,6 @@ export default class SearchAutocomplete {
// Only when user is logged in
if
(
gon
.
current_user_id
)
{
this
.
createAutocomplete
();
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
}
this
.
searchInput
.
addClass
(
'
disabled
'
);
this
.
saveTextLength
();
...
...
@@ -170,68 +89,6 @@ export default class SearchAutocomplete {
return
this
.
wrap
.
find
(
selector
);
}
<<<<<<<
HEAD
getData
(
term
,
callback
)
{
if
(
!
term
)
{
const
contents
=
this
.
getCategoryContents
();
if
(
contents
)
{
this
.
searchInput
.
data
(
'
glDropdown
'
).
filter
.
options
.
callback
(
contents
);
this
.
enableAutocomplete
();
}
return
;
}
// Prevent multiple ajax calls
if
(
this
.
loadingSuggestions
)
{
return
;
}
this
.
loadingSuggestions
=
true
;
return
$
.
get
(
this
.
autocompletePath
,
{
project_id
:
this
.
projectId
,
project_ref
:
this
.
projectRef
,
term
:
term
,
},
(
response
)
=>
{
var
firstCategory
,
i
,
lastCategory
,
len
,
suggestion
;
// Hide dropdown menu if no suggestions returns
if
(
!
response
.
length
)
{
this
.
disableAutocomplete
();
return
;
}
const
data
=
[];
// List results
firstCategory
=
true
;
for
(
i
=
0
,
len
=
response
.
length
;
i
<
len
;
i
+=
1
)
{
suggestion
=
response
[
i
];
// Add group header before list each group
if
(
lastCategory
!==
suggestion
.
category
)
{
if
(
!
firstCategory
)
{
data
.
push
(
'
separator
'
);
}
if
(
firstCategory
)
{
firstCategory
=
false
;
}
data
.
push
({
header
:
suggestion
.
category
,
});
lastCategory
=
suggestion
.
category
;
}
data
.
push
({
id
:
(
suggestion
.
category
.
toLowerCase
())
+
"
-
"
+
suggestion
.
id
,
category
:
suggestion
.
category
,
text
:
suggestion
.
label
,
url
:
suggestion
.
url
,
});
}
// Add option to proceed with the search
if
(
data
.
length
)
{
data
.
push
(
'
separator
'
);
data
.
push
({
text
:
"
Result name contains
\"
"
+
term
+
"
\"
"
,
url
:
"
/search?search=
"
+
term
+
"
&project_id=
"
+
(
this
.
projectInputEl
.
val
())
+
"
&group_id=
"
+
(
this
.
groupInputEl
.
val
()),
=======
saveOriginalState
()
{
return
this
.
originalState
=
this
.
serializeState
();
}
...
...
@@ -303,67 +160,9 @@ export default class SearchAutocomplete {
}
data
.
push
({
header
:
suggestion
.
category
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
});
lastCategory
=
suggestion
.
category
;
}
<<<<<<<
HEAD
return
callback
(
data
);
})
.
always
(()
=>
{
this
.
loadingSuggestions
=
false
;
});
}
getCategoryContents
()
{
const
userId
=
gon
.
current_user_id
;
const
userName
=
gon
.
current_username
;
const
{
projectOptions
,
groupOptions
,
dashboardOptions
}
=
gl
;
// Get options
let
options
;
if
(
isInGroupsPage
()
&&
groupOptions
)
{
options
=
groupOptions
[
getGroupSlug
()];
}
else
if
(
isInProjectPage
()
&&
projectOptions
)
{
options
=
projectOptions
[
getProjectSlug
()];
}
else
if
(
dashboardOptions
)
{
options
=
dashboardOptions
;
}
const
{
issuesPath
,
mrPath
,
name
,
issuesDisabled
}
=
options
;
const
baseItems
=
[];
if
(
name
)
{
baseItems
.
push
({
header
:
`
${
name
}
`
,
});
}
const
issueItems
=
[
{
text
:
'
Issues assigned to me
'
,
url
:
`
${
issuesPath
}
/?assignee_username=
${
userName
}
`
,
},
{
text
:
"
Issues I've created
"
,
url
:
`
${
issuesPath
}
/?author_username=
${
userName
}
`
,
},
];
const
mergeRequestItems
=
[
{
text
:
'
Merge requests assigned to me
'
,
url
:
`
${
mrPath
}
/?assignee_username=
${
userName
}
`
,
},
{
text
:
"
Merge requests I've created
"
,
url
:
`
${
mrPath
}
/?author_username=
${
userName
}
`
,
},
];
let
items
;
if
(
issuesDisabled
)
{
items
=
baseItems
.
concat
(
mergeRequestItems
);
}
else
{
items
=
baseItems
.
concat
(...
issueItems
,
'
separator
'
,
...
mergeRequestItems
);
=======
data
.
push
({
id
:
(
suggestion
.
category
.
toLowerCase
())
+
"
-
"
+
suggestion
.
id
,
category
:
suggestion
.
category
,
...
...
@@ -419,7 +218,6 @@ export default class SearchAutocomplete {
},
{
text
:
"
Merge requests I've created
"
,
url
:
mrPath
+
"
/?author_username=
"
+
userName
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
}
];
if
(
options
.
issuesDisabled
)
{
...
...
@@ -446,18 +244,6 @@ export default class SearchAutocomplete {
};
}
<<<<<<<
HEAD
serializeState
()
{
return
{
// Search Criteria
search_project_id
:
this
.
projectInputEl
.
val
(),
group_id
:
this
.
groupInputEl
.
val
(),
search_code
:
this
.
searchCodeInputEl
.
val
(),
repository_ref
:
this
.
repositoryInputEl
.
val
(),
scope
:
this
.
scopeInputEl
.
val
(),
// Location badge
_location
:
this
.
locationBadgeEl
.
text
(),
=======
bindEvents
()
{
this
.
searchInput
.
on
(
'
keydown
'
,
this
.
onSearchInputKeyDown
);
this
.
searchInput
.
on
(
'
keyup
'
,
this
.
onSearchInputKeyUp
);
...
...
@@ -468,34 +254,10 @@ export default class SearchAutocomplete {
return
this
.
locationBadgeEl
.
on
(
'
click
'
,
(
function
(
_this
)
{
return
function
()
{
return
_this
.
searchInput
.
focus
();
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
};
})(
this
));
}
<<<<<<<
HEAD
bindEvents
()
{
this
.
searchInput
.
on
(
'
keydown
'
,
this
.
onSearchInputKeyDown
);
this
.
searchInput
.
on
(
'
keyup
'
,
this
.
onSearchInputKeyUp
);
this
.
searchInput
.
on
(
'
focus
'
,
this
.
onSearchInputFocus
);
this
.
searchInput
.
on
(
'
blur
'
,
this
.
onSearchInputBlur
);
this
.
clearInput
.
on
(
'
click
'
,
this
.
onClearInputClick
);
this
.
locationBadgeEl
.
on
(
'
click
'
,
()
=>
this
.
searchInput
.
focus
());
}
enableAutocomplete
()
{
// No need to enable anything if user is not logged in
if
(
!
gon
.
current_user_id
)
{
return
;
}
// If the dropdown is closed, we'll open it
if
(
!
this
.
dropdown
.
hasClass
(
'
open
'
))
{
this
.
loadingSuggestions
=
false
;
this
.
dropdownToggle
.
dropdown
(
'
toggle
'
);
return
this
.
searchInput
.
removeClass
(
'
disabled
'
);
}
=======
enableAutocomplete
()
{
var
_this
;
// No need to enable anything if user is not logged in
...
...
@@ -507,20 +269,13 @@ export default class SearchAutocomplete {
this
.
loadingSuggestions
=
false
;
this
.
dropdown
.
addClass
(
'
open
'
).
trigger
(
'
shown.bs.dropdown
'
);
return
this
.
searchInput
.
removeClass
(
'
disabled
'
);
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
}
}
// Saves last length of the entered text
<<<<<<<
HEAD
onSearchInputKeyDown
()
{
return
this
.
saveTextLength
();
}
=======
onSearchInputKeyDown
()
{
return
this
.
saveTextLength
();
}
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
onSearchInputKeyUp
(
e
)
{
switch
(
e
.
keyCode
)
{
...
...
@@ -562,14 +317,6 @@ export default class SearchAutocomplete {
this
.
wrap
.
toggleClass
(
'
has-value
'
,
!!
e
.
target
.
value
);
}
<<<<<<<
HEAD
onSearchInputFocus
()
{
this
.
isFocused
=
true
;
this
.
wrap
.
addClass
(
'
search-active
'
);
if
(
this
.
getValue
()
===
''
)
{
return
this
.
getData
();
}
=======
// Avoid falsy value to be returned
onSearchInputClick
(
e
)
{
return
e
.
stopImmediatePropagation
();
...
...
@@ -580,7 +327,6 @@ export default class SearchAutocomplete {
this
.
wrap
.
addClass
(
'
search-active
'
);
if
(
this
.
getValue
()
===
''
)
{
return
this
.
getData
();
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
}
}
...
...
@@ -616,29 +362,12 @@ export default class SearchAutocomplete {
return
this
.
wrap
.
is
(
'
.has-location-badge
'
);
}
<<<<<<<
HEAD
restoreOriginalState
()
{
var
i
,
input
,
inputs
,
len
;
inputs
=
Object
.
keys
(
this
.
originalState
);
for
(
i
=
0
,
len
=
inputs
.
length
;
i
<
len
;
i
+=
1
)
{
input
=
inputs
[
i
];
this
.
getElement
(
"
#
"
+
input
).
val
(
this
.
originalState
[
input
]);
}
if
(
this
.
originalState
.
_location
===
''
)
{
return
this
.
locationBadgeEl
.
hide
();
}
else
{
return
this
.
addLocationBadge
({
value
:
this
.
originalState
.
_location
,
});
}
=======
restoreOriginalState
()
{
var
i
,
input
,
inputs
,
len
;
inputs
=
Object
.
keys
(
this
.
originalState
);
for
(
i
=
0
,
len
=
inputs
.
length
;
i
<
len
;
i
+=
1
)
{
input
=
inputs
[
i
];
this
.
getElement
(
"
#
"
+
input
).
val
(
this
.
originalState
[
input
]);
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
}
if
(
this
.
originalState
.
_location
===
''
)
{
return
this
.
locationBadgeEl
.
hide
();
...
...
@@ -689,24 +418,6 @@ export default class SearchAutocomplete {
return
this
.
dropdownContent
.
html
(
html
);
}
<<<<<<<
HEAD
onClick
(
item
,
$el
,
e
)
{
if
(
location
.
pathname
.
indexOf
(
item
.
url
)
!==
-
1
)
{
if
(
!
e
.
metaKey
)
e
.
preventDefault
();
if
(
!
this
.
badgePresent
)
{
if
(
item
.
category
===
'
Projects
'
)
{
this
.
projectInputEl
.
val
(
item
.
id
);
this
.
addLocationBadge
({
value
:
'
This project
'
,
});
}
if
(
item
.
category
===
'
Groups
'
)
{
this
.
groupInputEl
.
val
(
item
.
id
);
this
.
addLocationBadge
({
value
:
'
This group
'
,
});
}
=======
onClick
(
item
,
$el
,
e
)
{
if
(
location
.
pathname
.
indexOf
(
item
.
url
)
!==
-
1
)
{
if
(
!
e
.
metaKey
)
e
.
preventDefault
();
...
...
@@ -722,7 +433,6 @@ export default class SearchAutocomplete {
this
.
addLocationBadge
({
value
:
'
This group
'
});
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
}
}
$el
.
removeClass
(
'
is-active
'
);
...
...
@@ -730,48 +440,4 @@ export default class SearchAutocomplete {
return
this
.
searchInput
.
val
(
''
).
focus
();
}
}
<<<<<<<
HEAD
global
.
SearchAutocomplete
=
SearchAutocomplete
;
$
(
function
()
{
var
$projectOptionsDataEl
=
$
(
'
.js-search-project-options
'
);
var
$groupOptionsDataEl
=
$
(
'
.js-search-group-options
'
);
var
$dashboardOptionsDataEl
=
$
(
'
.js-search-dashboard-options
'
);
if
(
$projectOptionsDataEl
.
length
)
{
gl
.
projectOptions
=
gl
.
projectOptions
||
{};
var
projectPath
=
$projectOptionsDataEl
.
data
(
'
project-path
'
);
gl
.
projectOptions
[
projectPath
]
=
{
name
:
$projectOptionsDataEl
.
data
(
'
name
'
),
issuesPath
:
$projectOptionsDataEl
.
data
(
'
issues-path
'
),
issuesDisabled
:
$projectOptionsDataEl
.
data
(
'
issues-disabled
'
),
mrPath
:
$projectOptionsDataEl
.
data
(
'
mr-path
'
),
};
}
if
(
$groupOptionsDataEl
.
length
)
{
gl
.
groupOptions
=
gl
.
groupOptions
||
{};
var
groupPath
=
$groupOptionsDataEl
.
data
(
'
group-path
'
);
gl
.
groupOptions
[
groupPath
]
=
{
name
:
$groupOptionsDataEl
.
data
(
'
name
'
),
issuesPath
:
$groupOptionsDataEl
.
data
(
'
issues-path
'
),
mrPath
:
$groupOptionsDataEl
.
data
(
'
mr-path
'
),
};
}
if
(
$dashboardOptionsDataEl
.
length
)
{
gl
.
dashboardOptions
=
{
issuesPath
:
$dashboardOptionsDataEl
.
data
(
'
issues-path
'
),
mrPath
:
$dashboardOptionsDataEl
.
data
(
'
mr-path
'
),
};
}
});
})(
window
.
gl
||
(
window
.
gl
=
{}));
=======
}
>>>>>>>
2
f1fd0d9bbedfec1d84550fd7fe14aebe91713aa
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