Skip to content

Commit

Permalink
Merge branch 'release/2.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamDASILVA committed Jun 20, 2020
2 parents 76f841c + 6fb1ff4 commit 4cb6ffe
Show file tree
Hide file tree
Showing 20 changed files with 121 additions and 56 deletions.
1 change: 1 addition & 0 deletions docs/css/app.279467f4.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/css/app.bb77194d.css

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link rel=icon href=favicon.ico><title>vue-ctk-date-time-picker</title><link href=css/app.bb77194d.css rel=preload as=style><link href=js/app.cb3df652.js rel=preload as=script><link href=js/chunk-vendors.5c79952b.js rel=preload as=script><link href=css/app.bb77194d.css rel=stylesheet></head><body><noscript><strong>We're sorry but vue-ctk-date-time-picker doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.5c79952b.js></script><script src=js/app.cb3df652.js></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link rel=icon href=favicon.ico><title>vue-ctk-date-time-picker</title><link href=css/app.279467f4.css rel=preload as=style><link href=js/app.ac586109.js rel=preload as=script><link href=js/chunk-vendors.a81c6b06.js rel=preload as=script><link href=css/app.279467f4.css rel=stylesheet></head><body><noscript><strong>We're sorry but vue-ctk-date-time-picker doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=js/chunk-vendors.a81c6b06.js></script><script src=js/app.ac586109.js></script></body></html>
2 changes: 2 additions & 0 deletions docs/js/app.ac586109.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/js/app.ac586109.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions docs/js/app.cb3df652.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/js/app.cb3df652.js.map

This file was deleted.

8 changes: 0 additions & 8 deletions docs/js/chunk-vendors.5c79952b.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/js/chunk-vendors.5c79952b.js.map

This file was deleted.

8 changes: 8 additions & 0 deletions docs/js/chunk-vendors.a81c6b06.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/js/chunk-vendors.a81c6b06.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-ctk-date-time-picker",
"version": "2.4.0",
"version": "2.5.0",
"description": "A vue component for select date & time (by Chronotruck)",
"author": "Louis Mazel <[email protected]>",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/VueCtkDateTimePicker/_subs/CustomButton/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class="custom-button-effect"
/>
<span
class="custom-button-content flex align-center justify-content-center flex-1"
class="custom-button-content flex align-center justify-content-center"
:style="[colorStyle]"
>
<slot :style="[colorStyle]" />
Expand Down
5 changes: 4 additions & 1 deletion src/VueCtkDateTimePicker/_subs/CustomInput/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
: null
},
hasClearButton () {
return !this.noClearButton && !this.disabled && this.value
return !this.noClearButton && !this.isDisabled && this.value
},
/**
* Returns true if the field is disabled
Expand Down Expand Up @@ -164,6 +164,9 @@
&-clear-button {
position: absolute;
right: 12px;
top: 0px;
bottom: 0px;
margin: auto 0;
}
&.has-error {
.field-input {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<CustomButton
v-for="m in [month]"
:key="m.month"
class="date-buttons lm-fs-16 padding-button"
class="date-buttons lm-fs-16 padding-button flex-1"
:color="color"
:dark="dark"
@click="selectingYearMonth = 'month'"
Expand All @@ -53,7 +53,7 @@
<CustomButton
v-for="y in [year]"
:key="y"
class="date-buttons lm-fs-16 padding-button"
class="date-buttons lm-fs-16 padding-button flex-1"
:color="color"
:dark="dark"
@click="selectingYearMonth = 'year'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,21 +145,10 @@
return ArrayMinuteRange(0, 60, twoDigit, this.minuteInterval, this._disabledMinutes)
},
apms () {
const ampm = this.isTwelveFormat
? this.minTime
? moment(this.minTime, 'hh:mm a').format('a')
: this.maxTime
? moment(this.maxTime, 'hh:mm a').format('a')
: ''
: ''
const upper = ampm
? [{ value: ampm.toUpperCase(), item: ampm.toUpperCase() }]
: [{ value: 'AM', item: 'AM' }, { value: 'PM', item: 'PM' }]
const lower = ampm
? [{ value: ampm, item: ampm }]
: [{ value: 'am', item: 'am' }, { value: 'pm', item: 'pm' }]
return this.isTwelveFormat
? this.format.includes('A') ? upper : lower
? this.format.includes('A')
? [{ value: 'AM', item: 'AM' }, { value: 'PM', item: 'PM' }]
: [{ value: 'am', item: 'am' }, { value: 'pm', item: 'pm' }]
: null
},
columns () {
Expand Down Expand Up @@ -288,9 +277,11 @@
onScrollHours: debounce(function (scroll) {
const value = this.getValue(scroll)
const hour = this.isTwelveFormat
? this.apm.toLowerCase() === 'am'
? value + 1
: (value + 1 + 12)
? this.apm
? this.apm.toLowerCase() === 'am'
? value + 1
: (value + 1 + 12)
:value
: value
if (this.isHoursDisabled(hour)) return
this.hour = hour === 24 && !this.isTwelveFormat ? 23 : hour
Expand Down Expand Up @@ -368,28 +359,30 @@
return null
}
},
initPositionView () {
async initPositionView () {
this.noScrollEvent = true
const containers = ['hours', 'minutes']
if (this.apms) containers.push('apms')
setTimeout(() => {
containers.forEach((container) => {
const elem = this.$refs[container][0]
elem.scrollTop = 0
const selected = elem.querySelector(`.time-picker-column-item.active`)
if (selected) {
const boundsSelected = selected.getBoundingClientRect()
const boundsElem = elem.getBoundingClientRect()
const timePickerHeight = this.$refs['time-picker'].clientHeight
if (boundsSelected && boundsElem) {
elem.scrollTop = (28 / 2) + boundsSelected.top - boundsElem.top - timePickerHeight / 2
}
await this.$nextTick()
containers.forEach((container) => {
const elem = this.$refs[container][0]
if (!elem) return false
elem.scrollTop = 0
const selected = elem.querySelector(`.time-picker-column-item.active`)
if (selected) {
const boundsSelected = selected.getBoundingClientRect()
const boundsElem = elem.getBoundingClientRect()
const timePickerHeight = this.$refs['time-picker'].clientHeight
if (boundsSelected && boundsElem) {
elem.scrollTop = (28 / 2) + boundsSelected.top - boundsElem.top - timePickerHeight / 2
}
setTimeout(() => {
this.noScrollEvent = false
}, 500)
})
}, 0)
}
setTimeout(() => {
this.noScrollEvent = false
}, 500)
})
},
getAvailableHour () {
const availableHours = this.hours.find((element) => {
Expand Down
8 changes: 8 additions & 0 deletions src/VueCtkDateTimePicker/_subs/PickersContainer/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@
}
}
@media screen and (max-width: 415px) {
$header-size: 58px;
$footer-size: 41px;
.pickers-container {
-webkit-flex-direction: column;
-ms-flex-direction: column;
Expand All @@ -397,6 +400,11 @@
bottom: 0;
right: 0;
left: 0;
.pickers-container {
height: calc(100% - #{$header-size} - #{$footer-size});
}
.datepicker {
border-radius: 0 !important;
bottom: 0 !important;
Expand Down
4 changes: 3 additions & 1 deletion src/VueCtkDateTimePicker/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,10 @@
updateMomentLocale(value, this.firstDayOfWeek)
}
},
mounted () {
created () {
updateMomentLocale(this.locale, this.firstDayOfWeek)
},
mounted () {
this.pickerPosition = this.getPosition()
this.pickerOpen = this.open
if (this.hasCustomElem) {
Expand Down
59 changes: 59 additions & 0 deletions tests/unit/VueCtkDateTimePicker/CustomInput/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { shallowMount } from '@vue/test-utils'

import CustomInput from '@/VueCtkDateTimePicker/_subs/CustomInput'
import CustomButton from '@/VueCtkDateTimePicker/_subs/CustomButton'

describe('VueCtkDateTimePicker/CustomInput', () => {
let wrapper
Expand Down Expand Up @@ -72,6 +73,64 @@ describe('VueCtkDateTimePicker/CustomInput', () => {
/**
* TODO: Add clear button test cases
*/
describe('clear button', () => {
it('should be defined if the "noClearButton" prop is not defined, the input is not disabled and there is a value', () => {
const wrapper = shallowMount(CustomInput, {
propsData: {
value: '2020-06-20 12:00:00',
noClearButton: false
},
attrs: {
disabled: false
}
})

const button = wrapper.find(CustomButton)
expect(button.exists()).toBeTruthy()
expect(button.is(CustomButton)).toBeTruthy()
})

it('should undefined if the "noClearButton" prop is defined or the input is disabled or there is no value', () => {
let wrapper = shallowMount(CustomInput, {
propsData: {
value: '2020-06-20 12:00:00',
noClearButton: true
},
attrs: {
disabled: false
}
})

let button = wrapper.find('.field-clear-button')
expect(button.exists()).toBeFalsy()

wrapper = shallowMount(CustomInput, {
propsData: {
value: null,
noClearButton: false
},
attrs: {
disabled: false
}
})

button = wrapper.find('.field-clear-button')
expect(button.exists()).toBeFalsy()

wrapper = shallowMount(CustomInput, {
propsData: {
value: '2020-06-20 12:00:00',
noClearButton: false
},
attrs: {
disabled: true
}
})

button = wrapper.find('.field-clear-button')
expect(button.exists()).toBeFalsy()
})
})

afterEach(() => {
wrapper.destroy()
Expand Down

0 comments on commit 4cb6ffe

Please sign in to comment.