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
2953bc02
Commit
2953bc02
authored
Dec 23, 2020
by
Marvin Karegyeya
Committed by
Kushal Pandya
Dec 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate Bootstrap dropdown to GitLab UI GlDropdown in pikaday.vue
parent
88f935cb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
68 deletions
+43
-68
app/assets/javascripts/vue_shared/components/pikaday.vue
app/assets/javascripts/vue_shared/components/pikaday.vue
+14
-43
changelogs/unreleased/Migrate-Bootstrap-dropdown-to-GitLab-UI-GlDropdown-in-app-assets-javascri.yml
...opdown-to-GitLab-UI-GlDropdown-in-app-assets-javascri.yml
+5
-0
ee/spec/features/epics/update_epic_spec.rb
ee/spec/features/epics/update_epic_spec.rb
+2
-2
spec/frontend/vue_shared/components/pikaday_spec.js
spec/frontend/vue_shared/components/pikaday_spec.js
+22
-23
No files found.
app/assets/javascripts/vue_shared/components/pikaday.vue
View file @
2953bc02
<
script
>
<
script
>
import
Pikaday
from
'
pikaday
'
;
import
{
GlDatepicker
}
from
'
@gitlab/ui
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
pikadayToString
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
parsePikadayDate
,
pikadayToString
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
__
}
from
'
~/locale
'
;
export
default
{
export
default
{
name
:
'
DatePicker
'
,
name
:
'
DatePicker
'
,
components
:
{
components
:
{
Gl
Icon
,
Gl
Datepicker
,
},
},
props
:
{
props
:
{
label
:
{
type
:
String
,
required
:
false
,
default
:
__
(
'
Date picker
'
),
},
selectedDate
:
{
selectedDate
:
{
type
:
Date
,
type
:
Date
,
required
:
false
,
required
:
false
,
...
@@ -31,32 +24,9 @@ export default {
...
@@ -31,32 +24,9 @@ export default {
default
:
null
,
default
:
null
,
},
},
},
},
mounted
()
{
this
.
calendar
=
new
Pikaday
({
field
:
this
.
$el
.
querySelector
(
'
.dropdown-menu-toggle
'
),
theme
:
'
gitlab-theme animate-picker
'
,
format
:
'
yyyy-mm-dd
'
,
container
:
this
.
$el
,
defaultDate
:
this
.
selectedDate
,
setDefaultDate
:
Boolean
(
this
.
selectedDate
),
minDate
:
this
.
minDate
,
maxDate
:
this
.
maxDate
,
parse
:
dateString
=>
parsePikadayDate
(
dateString
),
toString
:
date
=>
pikadayToString
(
date
),
onSelect
:
this
.
selected
.
bind
(
this
),
onClose
:
this
.
toggled
.
bind
(
this
),
firstDay
:
gon
.
first_day_of_week
,
});
this
.
$el
.
append
(
this
.
calendar
.
el
);
this
.
calendar
.
show
();
},
beforeDestroy
()
{
this
.
calendar
.
destroy
();
},
methods
:
{
methods
:
{
selected
(
date
Text
)
{
selected
(
date
)
{
this
.
$emit
(
'
newDateSelected
'
,
this
.
calendar
.
toString
(
dateText
));
this
.
$emit
(
'
newDateSelected
'
,
pikadayToString
(
date
));
},
},
toggled
()
{
toggled
()
{
this
.
$emit
(
'
hidePicker
'
);
this
.
$emit
(
'
hidePicker
'
);
...
@@ -66,12 +36,13 @@ export default {
...
@@ -66,12 +36,13 @@ export default {
</
script
>
</
script
>
<
template
>
<
template
>
<div
class=
"pikaday-container"
>
<gl-datepicker
<div
class=
"dropdown open"
>
:value=
"selectedDate"
<button
type=
"button"
class=
"dropdown-menu-toggle"
data-toggle=
"dropdown"
@
click=
"toggled"
>
:min-date=
"minDate"
<span
class=
"dropdown-toggle-text"
>
{{
label
}}
</span>
:max-date=
"maxDate"
<gl-icon
name=
"chevron-down"
class=
"gl-absolute gl-right-3 gl-top-3 gl-text-gray-500"
/>
start-opened
</button>
@
close=
"toggled"
</div>
@
click=
"toggled"
</div>
@
input=
"selected"
/>
</
template
>
</
template
>
changelogs/unreleased/Migrate-Bootstrap-dropdown-to-GitLab-UI-GlDropdown-in-app-assets-javascri.yml
0 → 100644
View file @
2953bc02
---
title
:
Migrate-Bootstrap-dropdown-to-GitLab-UI-GlDropdown-in-app/assets/javascripts/vue_shared/components/pikaday.vue
merge_request
:
41458
author
:
nuwe1
type
:
other
ee/spec/features/epics/update_epic_spec.rb
View file @
2953bc02
...
@@ -149,8 +149,8 @@ RSpec.describe 'Update Epic', :js do
...
@@ -149,8 +149,8 @@ RSpec.describe 'Update Epic', :js do
it
'opens datepicker when clicking Edit button'
do
it
'opens datepicker when clicking Edit button'
do
page
.
within
(
'.issuable-sidebar .block.start-date'
)
do
page
.
within
(
'.issuable-sidebar .block.start-date'
)
do
click_button
(
'Edit'
)
click_button
(
'Edit'
)
expect
(
find
(
'.value-type-fixed'
)).
to
have_selector
(
'.
pikaday-contain
er'
)
expect
(
find
(
'.value-type-fixed'
)).
to
have_selector
(
'.
gl-datepick
er'
)
expect
(
find
(
'.value-type-fixed'
)).
to
have_selector
(
'.
pikaday-contain
er .pika-single.is-bound'
)
expect
(
find
(
'.value-type-fixed'
)).
to
have_selector
(
'.
gl-datepick
er .pika-single.is-bound'
)
end
end
end
end
end
end
...
...
spec/frontend/vue_shared/components/pikaday_spec.js
View file @
2953bc02
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlDatepicker
}
from
'
@gitlab/ui
'
;
import
datePicker
from
'
~/vue_shared/components/pikaday.vue
'
;
import
datePicker
from
'
~/vue_shared/components/pikaday.vue
'
;
describe
(
'
datePicker
'
,
()
=>
{
describe
(
'
datePicker
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
beforeEach
(()
=>
{
const
buildWrapper
=
(
propsData
=
{})
=>
{
wrapper
=
shallowMount
(
datePicker
,
{
wrapper
=
shallowMount
(
datePicker
,
{
propsData
:
{
propsData
,
label
:
'
label
'
,
},
attachToDocument
:
true
,
});
});
}
)
;
};
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
wrapper
=
null
;
});
});
it
(
'
should emit newDateSelected when GlDatePicker emits the input event
'
,
()
=>
{
const
minDate
=
new
Date
();
const
maxDate
=
new
Date
();
const
selectedDate
=
new
Date
();
const
theDate
=
selectedDate
.
toISOString
().
slice
(
0
,
10
);
it
(
'
should render label text
'
,
()
=>
{
buildWrapper
({
minDate
,
maxDate
,
selectedDate
});
expect
(
wrapper
.
find
(
'
.dropdown-toggle-text
'
)
.
text
()
.
trim
(),
).
toEqual
(
'
label
'
);
});
it
(
'
should show calendar
'
,
()
=>
{
expect
(
wrapper
.
find
(
GlDatepicker
).
props
()).
toMatchObject
({
expect
(
wrapper
.
find
(
'
.pika-single
'
).
element
).
toBeDefined
();
minDate
,
maxDate
,
value
:
selectedDate
,
});
wrapper
.
find
(
GlDatepicker
).
vm
.
$emit
(
'
input
'
,
selectedDate
);
expect
(
wrapper
.
emitted
(
'
newDateSelected
'
)[
0
][
0
]).
toBe
(
theDate
);
});
});
it
(
'
should emit the hidePicker event when GlDatePicker emits the close event
'
,
()
=>
{
buildWrapper
();
it
(
'
should emit hidePicker event when dropdown is clicked
'
,
()
=>
{
wrapper
.
find
(
GlDatepicker
).
vm
.
$emit
(
'
close
'
);
// Removing the bootstrap data-toggle property,
// because it interfers with our click event
delete
wrapper
.
find
(
'
.dropdown-menu-toggle
'
).
element
.
dataset
.
toggle
;
wrapper
.
find
(
'
.dropdown-menu-toggle
'
).
trigger
(
'
click
'
);
expect
(
wrapper
.
emitted
(
'
hidePicker
'
)).
to
Equal
([[]]
);
expect
(
wrapper
.
emitted
(
'
hidePicker
'
)).
to
HaveLength
(
1
);
});
});
});
});
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