Skip to content

Commit 90ee227

Browse files
author
Jose Chirivella
committed
FOUR-6854 Added the extent of DatePick library
* Fixed the date prop value to check if the value exist, to parse it. IF not, default to empty string
1 parent c3da2c3 commit 90ee227

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

src/components/DatePicker.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<script>
2+
import DatePick from "vue-date-pick";
3+
4+
/*
5+
Internal fork of the DatePick library by extending it and fixing the {close,remove} events to target the b-modal
6+
(Bootstrap-Vue) modals to not "focus-in" automatically on the input text.
7+
*/
8+
export default {
9+
extends: DatePick,
10+
methods: {
11+
addCloseEvents() {
12+
if (!this.closeEventListener) {
13+
this.closeEventListener = (e) => this.inspectCloseEvent(e);
14+
["click", "keyup"].forEach((eventName) =>
15+
document.addEventListener(eventName, this.closeEventListener)
16+
);
17+
}
18+
},
19+
removeCloseEvents() {
20+
if (!this.closeEventListener) {
21+
this.closeEventListener = (e) => this.inspectCloseEvent(e);
22+
["click", "keyup"].forEach((eventName) =>
23+
document.addEventListener(eventName, this.closeEventListener)
24+
);
25+
}
26+
}
27+
}
28+
};
29+
</script>

src/components/FormDatePicker.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
<script>
2323
import { createUniqIdsMixin } from "vue-uniq-ids";
24-
import DatePick from "vue-date-pick";
2524
import moment from "moment-timezone";
2625
import Mustache from "mustache";
26+
import DatePicker from "./DatePicker.vue";
2727
import ValidationMixin from "./mixins/validation";
2828
import DataFormatMixin from "./mixins/DataFormat";
2929
import { getUserDateFormat, getUserDateTimeFormat } from "../dateUtils";
@@ -62,7 +62,7 @@ Validator.register(
6262
6363
export default {
6464
components: {
65-
DatePick
65+
"date-pick": DatePicker
6666
},
6767
mixins: [uniqIdsMixin, ValidationMixin, DataFormatMixin],
6868
props: {
@@ -90,7 +90,10 @@ export default {
9090
data() {
9191
return {
9292
validatorErrors: [],
93-
date: "",
93+
date:
94+
!!this.value && this.value.length > 0
95+
? this.parsingInputDate(this.value)
96+
: "",
9497
inputAttributes: {
9598
class: `${this.inputClass}`,
9699
placeholder: this.placeholder,

0 commit comments

Comments
 (0)