@@ -10,12 +10,10 @@ import {
1010 updateWeekday ,
1111 nextDay ,
1212 prevDay ,
13- today
13+ today ,
1414} from '../utils/Timestamp.js'
1515
16- export const useMoveEmits = [
17- 'moved'
18- ]
16+ export const useMoveEmits = [ 'moved' ]
1917
2018/**
2119 * export of default funtion
@@ -35,16 +33,10 @@ export const useMoveEmits = [
3533 * @param {import('vue').Ref } param.emittedValue reactive sting that is emitted when changed (YYYY-MM-DD)
3634 * @param {Function } param.emit Vue emit function
3735 */
38- export default function ( props , {
39- parsedView,
40- parsedValue,
41- weekdaySkips,
42- direction,
43- maxDays,
44- times,
45- emittedValue,
46- emit
47- } ) {
36+ export default function (
37+ props ,
38+ { parsedView, parsedValue, weekdaySkips, direction, maxDays, times, emittedValue, emit } ,
39+ ) {
4840 /**
4941 * Moves the calendar the desired amount. This is based on the 'view'.
5042 * A month calendar moves by prev/next month
@@ -53,7 +45,7 @@ export default function (props, {
5345 * @param {Number } amount The amount to move (default 1)
5446 * @fires 'moved' with current Timestamp
5547 */
56- function move ( amount = 1 ) {
48+ function move ( amount = 1 ) {
5749 if ( amount === 0 ) {
5850 emittedValue . value = today ( )
5951 return
@@ -64,50 +56,52 @@ export default function (props, {
6456 const limit = forward ? DAYS_IN_MONTH_MAX : DAY_MIN
6557 let count = forward ? amount : - amount
6658 direction . value = forward ? 'next' : 'prev'
67- const dayCount = weekdaySkips . value . filter ( x => x !== 0 ) . length
59+ const dayCount = weekdaySkips . value . filter ( ( x ) => x !== 0 ) . length
6860
6961 while ( -- count >= 0 ) {
7062 switch ( parsedView . value ) {
7163 case 'month' :
64+ // set to 1st or last day of the month
7265 moved . day = limit
73- mover ( moved )
74- updateWeekday ( moved )
75- while ( weekdaySkips . value [ moved . weekday ] === 0 ) {
66+ moved = mover ( moved )
67+ moved = updateWeekday ( moved )
68+ while ( weekdaySkips . value [ moved . weekday ] === 0 ) {
7669 moved = addToDate ( moved , { day : forward === true ? 1 : - 1 } )
7770 }
7871 break
7972 case 'week' :
8073 case 'week-agenda' :
8174 case 'week-scheduler' :
82- relativeDays ( moved , mover , dayCount , props . weekdays )
75+ moved = relativeDays ( moved , mover , dayCount , props . weekdays )
8376 break
8477 case 'day' :
8578 case 'scheduler' :
8679 case 'agenda' :
87- relativeDays ( moved , mover , maxDays . value , props . weekdays )
80+ moved = relativeDays ( moved , mover , maxDays . value , props . weekdays )
8881 break
8982 case 'month-interval' :
9083 case 'month-agenda' :
9184 case 'month-scheduler' :
85+ // set to 1st or last day of the month
9286 moved . day = limit
93- mover ( moved )
87+ moved = mover ( moved )
9488 break
9589 case 'resource' :
96- relativeDays ( moved , mover , maxDays . value , props . weekdays )
90+ moved = relativeDays ( moved , mover , maxDays . value , props . weekdays )
9791 break
9892 }
9993 }
10094
101- updateWeekday ( moved )
102- updateFormatted ( moved )
103- updateDayOfYear ( moved )
104- updateRelative ( moved , times . now )
95+ moved = updateWeekday ( moved )
96+ moved = updateFormatted ( moved )
97+ moved = updateDayOfYear ( moved )
98+ moved = updateRelative ( moved , times . now )
10599
106100 emittedValue . value = moved . date
107101 emit ( 'moved' , moved )
108102 }
109103
110104 return {
111- move
105+ move,
112106 }
113107}
0 commit comments