Skip to content

Commit

Permalink
feat: listen to the updated date from the datepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
abdelrazzaq-dev committed Jan 17, 2020
1 parent 8dfc43d commit 5cf71a3
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/components/AppDateInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
)
date-picker(
v-if="showPicker"
@date-changed="setLocaleDate"
:dateValue="dateValue"
:locale="locale"
:locales="locales"
Expand Down Expand Up @@ -51,15 +52,19 @@ export default class AppDateInput extends Vue {
@Prop() label?: string;
@Prop() name!: string;
showPicker: boolean = false;
localeDate: string = this.dateValue.toLocaleDateString(this.locale, {
month: "long",
year: "numeric",
day: "numeric"
});
localeDate: string = "";
localeMonths: string[] = generateMonthNameInLocale(
this.locale || navigator.language
);
setLocaleDate(date: Date) {
this.localeDate = date.toLocaleDateString(this.locale, {
month: "long",
year: "numeric",
day: "numeric"
});
}
localeDateChanged() {
const dateMap: string[] = this.localeDate.split(/[ ,-/\\،]/);
if (dateMap.length > 0) {
Expand All @@ -86,5 +91,8 @@ export default class AppDateInput extends Vue {
hide() {
this.showPicker = false;
}
mounted() {
this.setLocaleDate(this.dateValue);
}
}
</script>

0 comments on commit 5cf71a3

Please sign in to comment.