-
+
diff --git a/modules/@ergonode/core/src/components/Inputs/DatePicker/DateRangePickerContent.vue b/modules/@ergonode/core/src/components/Inputs/DatePicker/DateRangePickerContent.vue
index 9aaba8cd3..ec2bfd46e 100644
--- a/modules/@ergonode/core/src/components/Inputs/DatePicker/DateRangePickerContent.vue
+++ b/modules/@ergonode/core/src/components/Inputs/DatePicker/DateRangePickerContent.vue
@@ -4,75 +4,23 @@
*/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
@@ -80,10 +28,11 @@
import Fab from '@Core/components/Buttons/Fab';
import Divider from '@Core/components/Dividers/Divider';
import IconArrowSingle from '@Core/components/Icons/Arrows/IconArrowSingle';
+import DatePickerContent from '@Core/components/Inputs/DatePicker/DatePickerContent';
import DatePickerContentHeader from '@Core/components/Inputs/DatePicker/DatePickerContentHeader';
-import DatePickerDays from '@Core/components/Inputs/DatePicker/DatePickerDays';
import DatePickerHeader from '@Core/components/Inputs/DatePicker/DatePickerHeader';
import DatePickerInputHeader from '@Core/components/Inputs/DatePicker/DatePickerInputHeader';
+import DatePickerMonth from '@Core/components/Inputs/DatePicker/DatePickerMonth';
import DatePickerNavigationHeader from '@Core/components/Inputs/DatePicker/DatePickerNavigationHeader';
import {
ARROW,
@@ -105,8 +54,9 @@ import {
export default {
name: 'DateRangePickerContent',
components: {
+ DatePickerContent,
Fab,
- DatePickerDays,
+ DatePickerMonth,
DatePickerContentHeader,
DatePickerNavigationHeader,
IconArrowSingle,
@@ -155,21 +105,6 @@ export default {
weekDays() {
return Object.values(WEEK_DAYS);
},
- lowerBoundCalendarDates() {
- return calendar(this.lowerBoundMonth, this.lowerBoundYear);
- },
- upperBoundCalendarDates() {
- return calendar(this.upperBoundMonth, this.upperBoundYear);
- },
- parsedRange() {
- return Object.keys(this.value).reduce((previous, current) => {
- if (this.value[current]) {
- previous.push(new Date(this.value[current]));
- }
-
- return previous;
- }, []);
- },
fromHeader() {
if (this.value.from) {
return `From ${formatDate(this.value.from, this.format)}`;
@@ -186,77 +121,32 @@ export default {
},
},
methods: {
- onFromHeaderValueChange(value) {
- this.headerFromValue = value;
- },
- onToHeaderValueChange(value) {
- this.headerToValue = value;
- },
- getDisplayingMonthAndYear(month, year) {
- return `${this.getDisplayingMonth(month)} ${year}`;
- },
- getDisplayingMonth(month) {
- return Object.keys(CALENDAR_MONTHS)[Math.max(0, Math.min(month - 1, 11))];
- },
- previousMonth() {
- const {
- month: previousMonth, year: previousYear,
- } = getPreviousMonth(this.lowerBoundMonth, this.lowerBoundYear);
-
- this.lowerBoundMonth = previousMonth;
- this.lowerBoundYear = previousYear;
- this.upperBoundMonth = this.upperBoundMonth > 1
- ? this.upperBoundMonth - 1
- : 12;
- this.upperBoundYear = this.upperBoundMonth === 12
- ? this.upperBoundYear - 1
- : this.upperBoundYear;
- },
- nextMonth() {
- const {
- month: nextMonth, year: nextYear,
- } = getNextMonth(this.upperBoundMonth, this.upperBoundYear);
-
- this.upperBoundMonth = nextMonth;
- this.upperBoundYear = nextYear;
- this.lowerBoundMonth = this.lowerBoundMonth < 12
- ? this.lowerBoundMonth + 1
- : 1;
- this.lowerBoundYear = this.lowerBoundMonth === 1
- ? this.lowerBoundYear + 1
- : this.lowerBoundYear;
- },
onSelectRange(date) {
- const to = this.value.to
- ? new Date(this.value.to)
- : null;
-
- const from = this.value.from
- ? new Date(this.value.from)
- : null;
-
- const dateToInsert = new Date(date.year, date.month - 1, date.day);
+ const {
+ from, to,
+ } = this.value;
- if (from) {
- if (+from > +dateToInsert) {
- this.$emit('input', {
- from: dateToInsert,
- to,
- });
- return;
- }
- } else {
+ if (from && to) {
+ this.$emit('input', {
+ from: date,
+ to: null,
+ });
+ } else if (from && date < from) {
+ this.$emit('input', {
+ from: date,
+ to: null,
+ });
+ } else if (from === null) {
this.$emit('input', {
- from: dateToInsert,
+ from: date,
to,
});
- return;
+ } else {
+ this.$emit('input', {
+ from,
+ to: date,
+ });
}
-
- this.$emit('input', {
- from,
- to: dateToInsert,
- });
},
},
};
@@ -267,10 +157,6 @@ export default {
display: grid;
grid-auto-flow: column;
- &__left, &__right {
- padding: 16px;
- }
-
.interactive-header {
margin-bottom: 8px;
}
diff --git a/modules/@ergonode/core/src/components/Inputs/DatePicker/Node/DatePickerNode.vue b/modules/@ergonode/core/src/components/Inputs/DatePicker/Node/DatePickerNode.vue
index 7e8de86e6..1c500683e 100644
--- a/modules/@ergonode/core/src/components/Inputs/DatePicker/Node/DatePickerNode.vue
+++ b/modules/@ergonode/core/src/components/Inputs/DatePicker/Node/DatePickerNode.vue
@@ -5,7 +5,9 @@
+ v-text="title"
+ @mouseenter="onMouseEnter"
+ @mouseleave="onMouseLeave" />
diff --git a/modules/@ergonode/core/src/models/calendar/calendar.js b/modules/@ergonode/core/src/models/calendar/calendar.js
index b16976d80..acb444600 100644
--- a/modules/@ergonode/core/src/models/calendar/calendar.js
+++ b/modules/@ergonode/core/src/models/calendar/calendar.js
@@ -69,6 +69,24 @@ export const isDate = (date) => {
return isDateObject && isValidDate;
};
+export const getParsedDate = (date) => {
+ if (!date) return null;
+
+ const day = date.getDate();
+ const month = date.getMonth() + 1;
+ const year = date.getFullYear();
+
+ return {
+ day,
+ month,
+ year,
+ };
+};
+
+export const isEqual = (date, withDate) => date.day === withDate.day
+ && date.month === withDate.month
+ && date.year === withDate.year;
+
export const getMonthIndex = (monthDesc) => {
const monthDescriptions = Object.values(CALENDAR_MONTHS);