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
61e33265
Commit
61e33265
authored
Sep 05, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'winh-search-dropdowns-ee' into 'master'
Make search dropdowns consistent See merge request !2804
parents
e5e3f88e
bafcae5c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
189 additions
and
149 deletions
+189
-149
app/assets/javascripts/gl_dropdown.js
app/assets/javascripts/gl_dropdown.js
+8
-3
app/assets/stylesheets/framework/dropdowns.scss
app/assets/stylesheets/framework/dropdowns.scss
+1
-0
app/assets/stylesheets/pages/search.scss
app/assets/stylesheets/pages/search.scss
+2
-0
spec/javascripts/gl_dropdown_spec.js
spec/javascripts/gl_dropdown_spec.js
+178
-146
No files found.
app/assets/javascripts/gl_dropdown.js
View file @
61e33265
...
@@ -654,10 +654,15 @@ GitLabDropdown = (function() {
...
@@ -654,10 +654,15 @@ GitLabDropdown = (function() {
if
(
!
selected
)
{
if
(
!
selected
)
{
fieldName
=
this
.
options
.
fieldName
;
fieldName
=
this
.
options
.
fieldName
;
field
=
this
.
dropdown
.
parent
().
find
(
"
input[name='
"
+
fieldName
+
"
'][value='
"
+
value
+
"
']
"
);
if
(
value
)
{
field
=
this
.
dropdown
.
parent
().
find
(
`input[name='
${
fieldName
}
'][value='
${
value
}
']`
);
if
(
field
.
length
)
{
if
(
field
.
length
)
{
selected
=
true
;
selected
=
true
;
}
}
}
else
{
field
=
this
.
dropdown
.
parent
().
find
(
`input[name='
${
fieldName
}
']`
);
selected
=
!
field
.
length
;
}
}
}
// Set URL
// Set URL
if
(
this
.
options
.
url
!=
null
)
{
if
(
this
.
options
.
url
!=
null
)
{
...
...
app/assets/stylesheets/framework/dropdowns.scss
View file @
61e33265
...
@@ -757,6 +757,7 @@
...
@@ -757,6 +757,7 @@
button
{
button
{
border-radius
:
0
;
border-radius
:
0
;
padding
:
8px
16px
;
padding
:
8px
16px
;
white-space
:
normal
;
// make sure the text color is not overriden
// make sure the text color is not overriden
&
.text-danger
{
&
.text-danger
{
...
...
app/assets/stylesheets/pages/search.scss
View file @
61e33265
...
@@ -190,6 +190,8 @@ input[type="checkbox"]:hover {
...
@@ -190,6 +190,8 @@ input[type="checkbox"]:hover {
}
}
.search-holder
{
.search-holder
{
@include
new-style-dropdown
;
@media
(
min-width
:
$screen-sm-min
)
{
@media
(
min-width
:
$screen-sm-min
)
{
display
:
-
webkit-flex
;
display
:
-
webkit-flex
;
display
:
flex
;
display
:
flex
;
...
...
spec/javascripts/gl_dropdown_spec.js
View file @
61e33265
...
@@ -4,7 +4,10 @@ import '~/gl_dropdown';
...
@@ -4,7 +4,10 @@ import '~/gl_dropdown';
import
'
~/lib/utils/common_utils
'
;
import
'
~/lib/utils/common_utils
'
;
import
'
~/lib/utils/url_utility
'
;
import
'
~/lib/utils/url_utility
'
;
(()
=>
{
describe
(
'
glDropdown
'
,
function
describeDropdown
()
{
preloadFixtures
(
'
static/gl_dropdown.html.raw
'
);
loadJSONFixtures
(
'
projects.json
'
);
const
NON_SELECTABLE_CLASSES
=
'
.divider, .separator, .dropdown-header, .dropdown-menu-empty-link
'
;
const
NON_SELECTABLE_CLASSES
=
'
.divider, .separator, .dropdown-header, .dropdown-menu-empty-link
'
;
const
SEARCH_INPUT_SELECTOR
=
'
.dropdown-input-field
'
;
const
SEARCH_INPUT_SELECTOR
=
'
.dropdown-input-field
'
;
const
ITEM_SELECTOR
=
`.dropdown-content li:not(
${
NON_SELECTABLE_CLASSES
}
)`
;
const
ITEM_SELECTOR
=
`.dropdown-content li:not(
${
NON_SELECTABLE_CLASSES
}
)`
;
...
@@ -39,10 +42,6 @@ import '~/lib/utils/url_utility';
...
@@ -39,10 +42,6 @@ import '~/lib/utils/url_utility';
remoteCallback
=
callback
.
bind
({},
data
);
remoteCallback
=
callback
.
bind
({},
data
);
};
};
describe
(
'
Dropdown
'
,
function
describeDropdown
()
{
preloadFixtures
(
'
static/gl_dropdown.html.raw
'
);
loadJSONFixtures
(
'
projects.json
'
);
function
initDropDown
(
hasRemote
,
isFilterable
,
extraOpts
=
{})
{
function
initDropDown
(
hasRemote
,
isFilterable
,
extraOpts
=
{})
{
const
options
=
Object
.
assign
({
const
options
=
Object
.
assign
({
selectable
:
true
,
selectable
:
true
,
...
@@ -52,9 +51,8 @@ import '~/lib/utils/url_utility';
...
@@ -52,9 +51,8 @@ import '~/lib/utils/url_utility';
fields
:
[
'
name
'
]
fields
:
[
'
name
'
]
},
},
text
:
project
=>
(
project
.
name_with_namespace
||
project
.
name
),
text
:
project
=>
(
project
.
name_with_namespace
||
project
.
name
),
id
:
project
=>
project
.
id
id
:
project
=>
project
.
id
,
},
extraOpts
);
},
extraOpts
);
this
.
dropdownButtonElement
=
$
(
'
#js-project-dropdown
'
,
this
.
dropdownContainerElement
).
glDropdown
(
options
);
this
.
dropdownButtonElement
=
$
(
'
#js-project-dropdown
'
,
this
.
dropdownContainerElement
).
glDropdown
(
options
);
}
}
...
@@ -222,5 +220,39 @@ import '~/lib/utils/url_utility';
...
@@ -222,5 +220,39 @@ import '~/lib/utils/url_utility';
.
trigger
(
'
focus
'
);
.
trigger
(
'
focus
'
);
expect
(
$searchInput
.
val
()).
toEqual
(
'
g
'
);
expect
(
$searchInput
.
val
()).
toEqual
(
'
g
'
);
});
});
describe
(
'
renderItem
'
,
()
=>
{
describe
(
'
without selected value
'
,
()
=>
{
let
dropdown
;
beforeEach
(()
=>
{
const
dropdownOptions
=
{
};
const
$dropdownDiv
=
$
(
'
<div />
'
);
$dropdownDiv
.
glDropdown
(
dropdownOptions
);
dropdown
=
$dropdownDiv
.
data
(
'
glDropdown
'
);
});
it
(
'
marks items without ID as active
'
,
()
=>
{
const
dummyData
=
{
};
const
html
=
dropdown
.
renderItem
(
dummyData
,
null
,
null
);
const
link
=
html
.
querySelector
(
'
a
'
);
expect
(
link
).
toHaveClass
(
'
is-active
'
);
});
it
(
'
does not mark items with ID as active
'
,
()
=>
{
const
dummyData
=
{
id
:
'
ea
'
};
const
html
=
dropdown
.
renderItem
(
dummyData
,
null
,
null
);
const
link
=
html
.
querySelector
(
'
a
'
);
expect
(
link
).
not
.
toHaveClass
(
'
is-active
'
);
});
});
});
});
})
()
;
});
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