From 45687c973bd174ac9f9ed221e8663f0b5414d7b4 Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Sun, 15 Jan 2017 12:09:10 -0500 Subject: [PATCH] [fixed] allow string names in `move()` --- src/utils/dates.js | 2 +- src/utils/move.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/utils/dates.js b/src/utils/dates.js index 02c996779..7701c2443 100644 --- a/src/utils/dates.js +++ b/src/utils/dates.js @@ -1,4 +1,4 @@ -/* eslint no-fallthrough: 0 */ +/* eslint no-fallthrough: off */ import dateMath from 'date-arithmetic'; import localizer from '../localizer'; diff --git a/src/utils/move.js b/src/utils/move.js index 9c559cad3..09bb13c6c 100644 --- a/src/utils/move.js +++ b/src/utils/move.js @@ -1,15 +1,20 @@ +import invariant from 'invariant'; import { navigate } from './constants'; +import VIEWS from '../Views'; export default function moveDate(action, date, View){ - switch (action){ + View = typeof view === 'string' ? VIEWS[View] : View; + + switch (action) { case navigate.TODAY: date = new Date() break; case navigate.DATE: break; default: + invariant(View && typeof View.navigate === 'function', + 'Calendar View components must implement a static `.navigate(date, action)` method.s') date = View.navigate(date, action) } - return date }