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
Boxiang Sun
gitlab-ce
Commits
8b9a4963
Commit
8b9a4963
authored
Jun 24, 2016
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated dropdowns to use field instead
Allows a bit more flexibilty and keeps the current functionality
parent
c160aae6
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
75 additions
and
40 deletions
+75
-40
app/assets/javascripts/compare_autocomplete.js.coffee
app/assets/javascripts/compare_autocomplete.js.coffee
+41
-0
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+2
-0
app/assets/javascripts/gl_dropdown.js.coffee
app/assets/javascripts/gl_dropdown.js.coffee
+16
-3
app/assets/javascripts/project.js.coffee
app/assets/javascripts/project.js.coffee
+2
-3
app/assets/stylesheets/framework/dropdowns.scss
app/assets/stylesheets/framework/dropdowns.scss
+3
-8
app/assets/stylesheets/pages/projects.scss
app/assets/stylesheets/pages/projects.scss
+1
-13
app/views/projects/compare/_form.html.haml
app/views/projects/compare/_form.html.haml
+8
-10
app/views/projects/compare/_ref_dropdown.html.haml
app/views/projects/compare/_ref_dropdown.html.haml
+1
-2
app/views/shared/_ref_switcher.html.haml
app/views/shared/_ref_switcher.html.haml
+1
-1
No files found.
app/assets/javascripts/compare_autocomplete.js.coffee
0 → 100644
View file @
8b9a4963
class
@
CompareAutocomplete
constructor
:
->
@
initDropdown
()
initDropdown
:
->
$
(
'.js-compare-dropdown'
).
each
->
$dropdown
=
$
(
@
)
selected
=
$dropdown
.
data
(
'selected'
)
$dropdown
.
glDropdown
(
data
:
(
term
,
callback
)
->
$
.
ajax
(
url
:
$dropdown
.
data
(
'refs-url'
)
data
:
ref
:
$dropdown
.
data
(
'ref'
)
).
done
(
refs
)
->
callback
(
refs
)
selectable
:
true
filterable
:
true
filterByText
:
true
fieldName
:
$dropdown
.
attr
(
'name'
)
filterInput
:
'input[type="text"]'
renderRow
:
(
ref
)
->
if
ref
.
header
?
$
(
'<li />'
)
.
addClass
(
'dropdown-header'
)
.
text
(
ref
.
header
)
else
link
=
$
(
'<a />'
)
.
attr
(
'href'
,
'#'
)
.
addClass
(
if
ref
is
selected
then
'is-active'
else
''
)
.
text
(
ref
)
.
attr
(
'data-ref'
,
escape
(
ref
))
$
(
'<li />'
)
.
append
(
link
)
id
:
(
obj
,
$el
)
->
$el
.
attr
(
'data-ref'
)
toggleLabel
:
(
obj
,
$el
)
->
$el
.
text
().
trim
()
)
app/assets/javascripts/dispatcher.js.coffee
View file @
8b9a4963
...
@@ -138,6 +138,8 @@ class Dispatcher
...
@@ -138,6 +138,8 @@ class Dispatcher
new
Project
()
new
Project
()
new
ProjectAvatar
()
new
ProjectAvatar
()
switch
path
[
1
]
switch
path
[
1
]
when
'compare'
new
CompareAutocomplete
()
when
'edit'
when
'edit'
shortcut_handler
=
new
ShortcutsNavigation
()
shortcut_handler
=
new
ShortcutsNavigation
()
new
ProjectNew
()
new
ProjectNew
()
...
...
app/assets/javascripts/gl_dropdown.js.coffee
View file @
8b9a4963
...
@@ -456,6 +456,8 @@ class GitLabDropdown
...
@@ -456,6 +456,8 @@ class GitLabDropdown
rowClicked
:
(
el
)
->
rowClicked
:
(
el
)
->
fieldName
=
@
options
.
fieldName
fieldName
=
@
options
.
fieldName
isInput
=
$
(
@
el
).
is
(
'input'
)
if
@
renderedData
if
@
renderedData
groupName
=
el
.
data
(
'group'
)
groupName
=
el
.
data
(
'group'
)
if
groupName
if
groupName
...
@@ -466,9 +468,18 @@ class GitLabDropdown
...
@@ -466,9 +468,18 @@ class GitLabDropdown
selectedObject
=
@
renderedData
[
selectedIndex
]
selectedObject
=
@
renderedData
[
selectedIndex
]
value
=
if
@
options
.
id
then
@
options
.
id
(
selectedObject
,
el
)
else
selectedObject
.
id
value
=
if
@
options
.
id
then
@
options
.
id
(
selectedObject
,
el
)
else
selectedObject
.
id
if
isInput
field
=
$
(
@
el
)
else
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
'][value='
#{
value
}
']"
)
field
=
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
'][value='
#{
value
}
']"
)
if
el
.
hasClass
(
ACTIVE_CLASS
)
if
el
.
hasClass
(
ACTIVE_CLASS
)
el
.
removeClass
(
ACTIVE_CLASS
)
el
.
removeClass
(
ACTIVE_CLASS
)
if
isInput
field
.
val
(
''
)
else
field
.
remove
()
field
.
remove
()
# Toggle the dropdown label
# Toggle the dropdown label
...
@@ -490,6 +501,8 @@ class GitLabDropdown
...
@@ -490,6 +501,8 @@ class GitLabDropdown
else
else
if
not
@
options
.
multiSelect
or
el
.
hasClass
(
'dropdown-clear-active'
)
if
not
@
options
.
multiSelect
or
el
.
hasClass
(
'dropdown-clear-active'
)
@
dropdown
.
find
(
".
#{
ACTIVE_CLASS
}
"
).
removeClass
ACTIVE_CLASS
@
dropdown
.
find
(
".
#{
ACTIVE_CLASS
}
"
).
removeClass
ACTIVE_CLASS
unless
isInput
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
).
remove
()
@
dropdown
.
parent
().
find
(
"input[name='
#{
fieldName
}
']"
).
remove
()
if
!
value
?
if
!
value
?
...
...
app/assets/javascripts/project.js.coffee
View file @
8b9a4963
...
@@ -67,7 +67,7 @@ class @Project
...
@@ -67,7 +67,7 @@ class @Project
selectable
:
true
selectable
:
true
filterable
:
true
filterable
:
true
filterByText
:
true
filterByText
:
true
fieldName
:
$dropdown
.
data
(
'field-name'
)
fieldName
:
'ref'
renderRow
:
(
ref
)
->
renderRow
:
(
ref
)
->
if
ref
.
header
?
if
ref
.
header
?
$
(
'<li />'
)
$
(
'<li />'
)
...
@@ -87,6 +87,5 @@ class @Project
...
@@ -87,6 +87,5 @@ class @Project
toggleLabel
:
(
obj
,
$el
)
->
toggleLabel
:
(
obj
,
$el
)
->
$el
.
text
().
trim
()
$el
.
text
().
trim
()
clicked
:
(
e
)
->
clicked
:
(
e
)
->
unless
$dropdown
.
hasClass
(
'js-compare-dropdown'
)
$dropdown
.
closest
(
'form'
).
submit
()
$dropdown
.
closest
(
'form'
).
submit
()
)
)
app/assets/stylesheets/framework/dropdowns.scss
View file @
8b9a4963
...
@@ -48,6 +48,9 @@
...
@@ -48,6 +48,9 @@
border
:
1px
solid
$dropdown-toggle-border-color
;
border
:
1px
solid
$dropdown-toggle-border-color
;
border-radius
:
$border-radius-base
;
border-radius
:
$border-radius-base
;
outline
:
0
;
outline
:
0
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
overflow
:
hidden
;
.fa
{
.fa
{
position
:
absolute
;
position
:
absolute
;
...
@@ -58,14 +61,6 @@
...
@@ -58,14 +61,6 @@
font-size
:
10px
;
font-size
:
10px
;
}
}
.dropdown-toggle-text
{
display
:
block
;
min-height
:
19px
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
overflow
:
hidden
;
}
&
:hover
,
{
&
:hover
,
{
border-color
:
$dropdown-toggle-hover-border-color
;
border-color
:
$dropdown-toggle-hover-border-color
;
...
...
app/assets/stylesheets/pages/projects.scss
View file @
8b9a4963
...
@@ -633,19 +633,7 @@ pre.light-well {
...
@@ -633,19 +633,7 @@ pre.light-well {
}
}
}
}
.compare-input-group
{
.compare-form-group
{
&
.input-group
.input-group-addon
{
@media
(
min-width
:
$screen-sm-min
)
{
width
:
1%
;
}
}
.dropdown-menu-toggle
{
width
:
100%
;
border-top-left-radius
:
0
;
border-bottom-left-radius
:
0
;
}
.dropdown-menu
{
.dropdown-menu
{
width
:
300px
;
width
:
300px
;
}
}
...
...
app/views/projects/compare/_form.html.haml
View file @
8b9a4963
...
@@ -2,18 +2,16 @@
...
@@ -2,18 +2,16 @@
.clearfix
.clearfix
-
if
params
[
:to
]
&&
params
[
:from
]
-
if
params
[
:to
]
&&
params
[
:from
]
=
link_to
'switch'
,
{
from:
params
[
:to
],
to:
params
[
:from
]},
{
class:
'commits-compare-switch has-tooltip'
,
title:
'Switch base of comparison'
}
=
link_to
'switch'
,
{
from:
params
[
:to
],
to:
params
[
:from
]},
{
class:
'commits-compare-switch has-tooltip'
,
title:
'Switch base of comparison'
}
.form-group
.form-group.dropdown.compare-form-group.js-compare-from-dropdown
=
hidden_field_tag
:from
,
params
[
:from
]
.input-group.inline-input-group
.input-group.inline-input-group.compare-input-group.dropdown
%span
.input-group-addon
from
%span
.input-group-addon
from
=
dropdown_toggle
h
(
params
[
:from
].
presence
||
''
),
{
toggle:
"dropdown"
,
refs_url:
refs_namespace_project_path
(
@project
.
namespace
,
@project
),
field_name:
'from'
,
selected:
params
[
:from
]
},
{
toggle_class:
"js-project-refs-dropdown js-compare-dropdown"
}
=
text_field_tag
:from
,
params
[
:from
],
class:
"form-control js-compare-dropdown"
,
required:
true
,
data:
{
refs_url:
refs_namespace_project_path
(
@project
.
namespace
,
@project
),
toggle:
"dropdown"
,
target:
".js-compare-from-dropdown"
,
selected:
params
[
:from
].
presence
}
=
render
"ref_dropdown"
=
render
"ref_dropdown"
=
"..."
=
"..."
.form-group
.form-group.dropdown.compare-form-group.js-compare-to-dropdown
=
hidden_field_tag
:to
,
params
[
:to
]
.input-group.inline-input-group
.input-group.inline-input-group.compare-input-group.dropdown
%span
.input-group-addon
to
%span
.input-group-addon
to
=
dropdown_toggle
h
(
params
[
:from
].
presence
||
''
),
{
toggle:
"dropdown"
,
refs_url:
refs_namespace_project_path
(
@project
.
namespace
,
@project
),
field_name:
'to'
,
selected:
params
[
:to
]
},
{
toggle_class:
"js-project-refs-dropdown js-compare-dropdown"
}
=
text_field_tag
:to
,
params
[
:to
],
class:
"form-control js-compare-dropdown"
,
required:
true
,
data:
{
refs_url:
refs_namespace_project_path
(
@project
.
namespace
,
@project
),
toggle:
"dropdown"
,
target:
".js-compare-to-dropdown"
,
selected:
params
[
:to
].
presence
}
=
render
"ref_dropdown"
=
render
"ref_dropdown"
=
button_tag
"Compare"
,
class:
"btn btn-create commits-compare-btn"
=
button_tag
"Compare"
,
class:
"btn btn-create commits-compare-btn"
...
...
app/views/projects/compare/_ref_dropdown.html.haml
View file @
8b9a4963
.dropdown-menu.dropdown-menu-selectable
.dropdown-menu.dropdown-menu-selectable
=
dropdown_title
"Switch branch/tag"
=
dropdown_title
"Select branch/tag"
=
dropdown_filter
"Search branches and tags"
=
dropdown_content
=
dropdown_content
=
dropdown_loading
=
dropdown_loading
app/views/shared/_ref_switcher.html.haml
View file @
8b9a4963
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
-
@options
&&
@options
.
each
do
|
key
,
value
|
-
@options
&&
@options
.
each
do
|
key
,
value
|
=
hidden_field_tag
key
,
value
,
id:
nil
=
hidden_field_tag
key
,
value
,
id:
nil
.dropdown
.dropdown
=
dropdown_toggle
dropdown_toggle_text
,
{
toggle:
"dropdown"
,
selected:
dropdown_toggle_text
,
field_name:
'ref'
,
ref:
@ref
,
refs_url:
refs_namespace_project_path
(
@project
.
namespace
,
@project
)
},
{
toggle_class:
"js-project-refs-dropdown"
}
=
dropdown_toggle
dropdown_toggle_text
,
{
toggle:
"dropdown"
,
selected:
dropdown_toggle_text
,
ref:
@ref
,
refs_url:
refs_namespace_project_path
(
@project
.
namespace
,
@project
)
},
{
toggle_class:
"js-project-refs-dropdown"
}
.dropdown-menu.dropdown-menu-selectable
{
class:
(
"dropdown-menu-align-right"
if
local_assigns
[
:align_right
])
}
.dropdown-menu.dropdown-menu-selectable
{
class:
(
"dropdown-menu-align-right"
if
local_assigns
[
:align_right
])
}
=
dropdown_title
"Switch branch/tag"
=
dropdown_title
"Switch branch/tag"
=
dropdown_filter
"Search branches and tags"
=
dropdown_filter
"Search branches and tags"
...
...
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