Skip to content

Commit

Permalink
FOUR-6854 Added the extent of DatePick library
Browse files Browse the repository at this point in the history
* Fixed the date prop value to check if the value exist, to parse it. IF not, default to empty string
  • Loading branch information
josechirivella committed Jan 9, 2023
1 parent c3da2c3 commit 90ee227
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
29 changes: 29 additions & 0 deletions src/components/DatePicker.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script>
import DatePick from "vue-date-pick";
/*
Internal fork of the DatePick library by extending it and fixing the {close,remove} events to target the b-modal
(Bootstrap-Vue) modals to not "focus-in" automatically on the input text.
*/
export default {
extends: DatePick,
methods: {
addCloseEvents() {
if (!this.closeEventListener) {
this.closeEventListener = (e) => this.inspectCloseEvent(e);
["click", "keyup"].forEach((eventName) =>
document.addEventListener(eventName, this.closeEventListener)
);
}
},
removeCloseEvents() {
if (!this.closeEventListener) {
this.closeEventListener = (e) => this.inspectCloseEvent(e);
["click", "keyup"].forEach((eventName) =>
document.addEventListener(eventName, this.closeEventListener)
);
}
}
}
};
</script>
9 changes: 6 additions & 3 deletions src/components/FormDatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

<script>
import { createUniqIdsMixin } from "vue-uniq-ids";
import DatePick from "vue-date-pick";
import moment from "moment-timezone";
import Mustache from "mustache";
import DatePicker from "./DatePicker.vue";
import ValidationMixin from "./mixins/validation";
import DataFormatMixin from "./mixins/DataFormat";
import { getUserDateFormat, getUserDateTimeFormat } from "../dateUtils";
Expand Down Expand Up @@ -62,7 +62,7 @@ Validator.register(
export default {
components: {
DatePick
"date-pick": DatePicker
},
mixins: [uniqIdsMixin, ValidationMixin, DataFormatMixin],
props: {
Expand Down Expand Up @@ -90,7 +90,10 @@ export default {
data() {
return {
validatorErrors: [],
date: "",
date:
!!this.value && this.value.length > 0
? this.parsingInputDate(this.value)
: "",
inputAttributes: {
class: `${this.inputClass}`,
placeholder: this.placeholder,
Expand Down

0 comments on commit 90ee227

Please sign in to comment.