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
Show 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
>
import
Pikaday
from
'
pikaday
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
parsePikadayDate
,
pikadayToString
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
GlDatepicker
}
from
'
@gitlab/ui
'
;
import
{
pikadayToString
}
from
'
~/lib/utils/datetime_utility
'
;
export
default
{
name
:
'
DatePicker
'
,
components
:
{
Gl
Icon
,
Gl
Datepicker
,
},
props
:
{
label
:
{
type
:
String
,
required
:
false
,
default
:
__
(
'
Date picker
'
),
},
selectedDate
:
{
type
:
Date
,
required
:
false
,
...
...
@@ -31,32 +24,9 @@ export default {
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
:
{
selected
(
date
Text
)
{
this
.
$emit
(
'
newDateSelected
'
,
this
.
calendar
.
toString
(
dateText
));
selected
(
date
)
{
this
.
$emit
(
'
newDateSelected
'
,
pikadayToString
(
date
));
},
toggled
()
{
this
.
$emit
(
'
hidePicker
'
);
...
...
@@ -66,12 +36,13 @@ export default {
</
script
>
<
template
>
<div
class=
"pikaday-container"
>
<div
class=
"dropdown open"
>
<button
type=
"button"
class=
"dropdown-menu-toggle"
data-toggle=
"dropdown"
@
click=
"toggled"
>
<span
class=
"dropdown-toggle-text"
>
{{
label
}}
</span>
<gl-icon
name=
"chevron-down"
class=
"gl-absolute gl-right-3 gl-top-3 gl-text-gray-500"
/>
</button>
</div>
</div>
<gl-datepicker
:value=
"selectedDate"
:min-date=
"minDate"
:max-date=
"maxDate"
start-opened
@
close=
"toggled"
@
click=
"toggled"
@
input=
"selected"
/>
</
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
it
'opens datepicker when clicking Edit button'
do
page
.
within
(
'.issuable-sidebar .block.start-date'
)
do
click_button
(
'Edit'
)
expect
(
find
(
'.value-type-fixed'
)).
to
have_selector
(
'.
pikaday-contain
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'
)
expect
(
find
(
'.value-type-fixed'
)).
to
have_selector
(
'.
gl-datepick
er .pika-single.is-bound'
)
end
end
end
...
...
spec/frontend/vue_shared/components/pikaday_spec.js
View file @
2953bc02
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlDatepicker
}
from
'
@gitlab/ui
'
;
import
datePicker
from
'
~/vue_shared/components/pikaday.vue
'
;
describe
(
'
datePicker
'
,
()
=>
{
let
wrapper
;
beforeEach
(()
=>
{
const
buildWrapper
=
(
propsData
=
{})
=>
{
wrapper
=
shallowMount
(
datePicker
,
{
propsData
:
{
label
:
'
label
'
,
},
attachToDocument
:
true
,
});
propsData
,
});
};
afterEach
(()
=>
{
wrapper
.
destroy
();
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
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.dropdown-toggle-text
'
)
.
text
()
.
trim
(),
).
toEqual
(
'
label
'
);
});
buildWrapper
({
minDate
,
maxDate
,
selectedDate
});
it
(
'
should show calendar
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
.pika-single
'
).
element
).
toBeDefined
();
expect
(
wrapper
.
find
(
GlDatepicker
).
props
()).
toMatchObject
({
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
'
,
()
=>
{
// 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
'
);
wrapper
.
find
(
GlDatepicker
).
vm
.
$emit
(
'
close
'
);
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