Skip to content

Commit 98ac533

Browse files
committed
Fixed limits error
1 parent 36f7f6b commit 98ac533

File tree

5 files changed

+41
-32
lines changed

5 files changed

+41
-32
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"name": "vue-functional-calendar",
88
"description": "Lightweight, high-performance calendar component based on Vue.js",
9-
"version": "2.5.3",
9+
"version": "2.5.4",
1010
"license": "MIT",
1111
"repository": {
1212
"type": "git",

src/Demo.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
:date-format="'dd/mm/yyyy'"
77
:is-multiple="true"
88
:calendars-count="1"
9+
:with-time-picker="true"
10+
:limits="{min: '25/06/2019', max: '01/07/2019'}"
911
:change-month-function="true"
1012
></FunctionalCalendar>
1113
<!--<functional-calendar class="demo-calendar"-->
@@ -97,7 +99,7 @@
9799
}
98100
99101
.demo-calendar {
100-
width: 256px;
102+
width: 300px;
101103
/*height: 400px;*/
102104
margin: 100px;
103105
}

src/assets/scss/calendar.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ input.vfc-single-input {
196196
content: ' ';
197197
height: 26px;
198198
width: 2px;
199-
background-color: #FFFFFF;
199+
background-color: $white;
200200
}
201201

202202
.vfc-close:before {
@@ -216,8 +216,8 @@ input.vfc-single-input {
216216
width: 100%;
217217
background-color: $royalblue;
218218
text-align: left;
219-
color: #FFFFFF;
220-
font-size: 20px;
219+
color: $white;
220+
font-size: 16px;
221221
padding-top: 15px;
222222
padding-bottom: 15px;
223223
border-radius: .28571429rem .28571429rem 0 0;
@@ -441,7 +441,7 @@ input.vfc-single-input {
441441
vertical-align: middle;
442442

443443
&.vfc-today {
444-
background-color: #ff8498;
444+
background-color: $lightred;
445445
color: $white;
446446
}
447447

@@ -480,7 +480,7 @@ input.vfc-single-input {
480480
}
481481

482482
&.vfc-hide {
483-
color: #d9d9d9;
483+
color: $lightgrey;
484484

485485
&:after {
486486

@@ -520,7 +520,7 @@ input.vfc-single-input {
520520
}
521521

522522
&.vfc-hover:hover {
523-
background-color: #dadada;
523+
background-color: $lightgreyHover;
524524
z-index: 100;
525525
}
526526
}

src/assets/scss/variables.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
$black: #000000 !default;
22
$white: #FFFFFF !default;
3+
$lightgrey: #d9d9d9 !default;
4+
$lightgreyHover: #dadada !default;;
35
$powderblue: #B0E0E6 !default;
46
$lightskyblue: #8fd8ec !default;
57
$royalblue: #66b3cc !default;
68
$steelblue: #4682B4 !default;
7-
$gainsboro: #bfbfbf !default;
9+
$gainsboro: #bfbfbf !default;
10+
$lightred: #ff8498 !default;

src/components/FunctionalCalendar.vue

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -200,29 +200,7 @@
200200
'calendar.currentDate': {
201201
handler(value) {
202202
this.$emit('input', this.calendar);
203-
if (this.fConfigs.limits) {
204-
let min = new Date(helpCalendar.getDateFromFormat(this.fConfigs.limits.min));
205-
min.setDate(1);
206-
min.setHours(0, 0, 0, 0);
207-
let max = new Date(helpCalendar.getDateFromFormat(this.fConfigs.limits.max));
208-
max.setDate(1);
209-
max.setHours(0, 0, 0, 0);
210-
211-
this.allowPreDate = true;
212-
this.allowNextDate = true;
213-
214-
let current = new Date(value);
215-
current.setDate(1);
216-
current.setHours(0, 0, 0, 0);
217-
218-
if (current <= min) {
219-
this.allowPreDate = false;
220-
}
221-
222-
if (current >= max) {
223-
this.allowNextDate = false;
224-
}
225-
}
203+
this.checkLimits(value);
226204
}
227205
},
228206
'calendar.dateRange.start.date': {
@@ -298,6 +276,7 @@
298276
this.setCalendarData();
299277
this.listRendering();
300278
this.markChooseDays();
279+
this.checkLimits(this.calendar.currentDate);
301280
},
302281
updateCalendar() {
303282
this.setExistingCalendarData();
@@ -880,6 +859,31 @@
880859
checkDateRangeEnd(date) {
881860
return date === this.fConfigs.markedDateRange.end;
882861
},
862+
checkLimits(value) {
863+
if (this.fConfigs.limits) {
864+
let min = new Date(helpCalendar.getDateFromFormat(this.fConfigs.limits.min));
865+
min.setDate(1);
866+
min.setHours(0, 0, 0, 0);
867+
let max = new Date(helpCalendar.getDateFromFormat(this.fConfigs.limits.max));
868+
max.setDate(1);
869+
max.setHours(0, 0, 0, 0);
870+
871+
this.allowPreDate = true;
872+
this.allowNextDate = true;
873+
874+
let current = new Date(value);
875+
current.setDate(1);
876+
current.setHours(0, 0, 0, 0);
877+
878+
if (current <= min) {
879+
this.allowPreDate = false;
880+
}
881+
882+
if (current >= max) {
883+
this.allowNextDate = false;
884+
}
885+
}
886+
},
883887
getTransition_() {
884888
if (!this.fConfigs.transition)
885889
return '';

0 commit comments

Comments
 (0)