Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change format in header to be more configurable #167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Here is an example of UMD implementation: https://codepen.io/louismazel/pen/jQWN
| no-keyboard (12) | Boolean | no | false |
| right (13) | Boolean | no | false |
| noClearButton | Boolean | no | false |
| reverseYMOrder | Boolean | no | false |

(1) hint : Is a text that replaces the label/placeholder (Ex : Error designation)

Expand Down Expand Up @@ -240,4 +241,4 @@ This project is licensed under [MIT License](http://en.wikipedia.org/wiki/MIT_Li

# Credit

Open source time proudly sponsored by [Chronotruck](https://www.chronotruck.com)
Open source time proudly sponsored by [Chronotruck](https://www.chronotruck.com)
2 changes: 1 addition & 1 deletion src/VueCtkDateTimePicker/_subs/CustomButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
}"
tabindex="-1"
type="button"
@click.stop="$emit('click')"
@click.prevent.stop="$emit('click')"
@focus="$emit('focus')"
@blur="$emit('blur')"
@mouseover="$emit('mouseover')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
type="button"
tabindex="-1"
class="datepicker-button validate flex align-center justify-content-center"
@click.stop="$emit('validate')"
@click.prevent.stop="$emit('validate')"
>
<span
class="datepicker-button-effect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
</div>
<div
class="datepicker-container-label flex-1 flex justify-content-center"
:class="reverseYMOrder ? 'flex-direction-reversed' : ''"
>
<TransitionGroup
:name="transitionLabelName"
class="h-100 flex align-center flex-1 flex justify-content-right"
class="h-100 flex align-center flex-1 flex"
:class="reverseYMOrder ? 'justify-content-left' : 'justify-content-right'"
>
<CustomButton
v-for="m in [month]"
Expand All @@ -48,6 +50,7 @@
<TransitionGroup
:name="transitionLabelName"
class="h-100 flex align-center flex-1 flex"
:class="reverseYMOrder ? 'justify-content-right' : 'justify-content-left'"
>
<CustomButton
v-for="y in [year]"
Expand Down Expand Up @@ -183,7 +186,8 @@
noShortcuts: { type: Boolean, default: Boolean },
firstDayOfWeek: { type: Number, default: Number },
customShortcuts: { type: Array, default: Array },
visible: { type: Boolean, default: Boolean }
visible: { type: Boolean, default: Boolean },
reverseYMOrder: { type: Boolean, default: false }
},
data () {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@

<script>
import moment from 'moment'
const YEAR_REGEX = new RegExp('([/, -]+)?(YYYYY?|YY|Yr)[年년年]?([/, -]+)?')

export default {
name: 'HeaderPicker',
Expand All @@ -116,6 +117,7 @@
onlyTime: { type: Boolean, default: Boolean },
transitionName: { type: String, default: String },
format: { type: String, default: String },
locale: { type: String, default: String },
timeFormat: { type: String, default: String },
noTime: { type: Boolean, default: Boolean },
range: { type: Boolean, default: Boolean },
Expand All @@ -139,10 +141,10 @@
return date
},
year () {
return this.dateTime.format('YYYY')
return this.dateTime.year()
},
getDateFormatted () {
return this.dateTime.format('ddd D MMM')
return this.dateTime.format(moment.localeData(this.locale).longDateFormat('LL').replace(YEAR_REGEX, ''))
},
isFormatTwelve () {
return this.format ? (this.format.indexOf('a') > -1) || (this.format.indexOf('A') > -1) : false
Expand Down
7 changes: 5 additions & 2 deletions src/VueCtkDateTimePicker/_subs/PickersContainer/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:class="{'inline': inline, 'is-dark': dark, 'visible': visible}"
:style="responsivePosition"
class="datetimepicker flex"
@click.stop
@click.prevent.stop
>
<div
:style="[responsivePosition, width]"
Expand All @@ -22,6 +22,7 @@
:only-time="onlyTime"
:format="format"
:time-format="timeFormat"
:locale="locale"
:transition-name="transitionName"
:no-time="onlyDate"
:dark="dark"
Expand Down Expand Up @@ -51,6 +52,7 @@
:custom-shortcuts="customShortcuts"
:no-keyboard="noKeyboard"
:locale="locale"
:reverse-y-m-order="reverseYMOrder"
@change-month="changeMonth"
@change-year-month="changeYearMonth"
@close="$emit('close')"
Expand Down Expand Up @@ -137,7 +139,8 @@
firstDayOfWeek: { type: Number, default: Number },
customShortcuts: { type: Array, default: Array },
noKeyboard: { type: Boolean, default: false },
right: { type: Boolean, default: false }
right: { type: Boolean, default: false },
reverseYMOrder: { type: Boolean, default: false }
},
data () {
return {
Expand Down
6 changes: 4 additions & 2 deletions src/VueCtkDateTimePicker/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div
v-if="hasPickerOpen && overlay"
class="time-picker-overlay"
@click.stop="toggleDatePicker(false)"
@click.prevent.stop="toggleDatePicker(false)"
/>
<PickersContainer
v-if="!disabled && isMounted"
Expand Down Expand Up @@ -63,6 +63,7 @@
:custom-shortcuts="customShortcuts"
:no-keyboard="noKeyboard"
:right="right"
:reverse-y-m-order="reverseYMOrder"
@validate="validate"
@close="toggleDatePicker(false)"
/>
Expand Down Expand Up @@ -154,7 +155,8 @@
noValueToCustomElem: { type: Boolean, default: false },
noKeyboard: { type: Boolean, default: false },
right: { type: Boolean, default: false },
noClearButton: { type: Boolean, default: false }
noClearButton: { type: Boolean, default: false },
reverseYMOrder: { type: Boolean, default: false }
},
data () {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/VueCtkDateTimePicker/modules/month.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class Month {
}

getFormatted () {
return this.start.format('MMMM')
return this.start.format('MMM')
}

getYear () {
Expand Down
3 changes: 3 additions & 0 deletions src/assets/scss/helpers/_flex.scss
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,6 @@
.flex-grow {
flex-grow: 1;
}
.flex-direction-reversed {
flex-direction: row-reverse;
}