Skip to content

Commit

Permalink
defaultAllDay
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Apr 13, 2020
1 parent 3a4f09c commit 7c14428
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion packages/__tests__/manual/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
slotMinutes: 15,
defaultEventMinutes: 45,

//allDayDefault: false,
//defaultAllDay: false,

/*
titleFormat: {
Expand Down
4 changes: 2 additions & 2 deletions packages/__tests__/manual/sources_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
endParam
cacheParam
ignoreTimezone
allDayDefault
defaultAllDay
editable
eventColor
eventTextColor
Expand All @@ -28,7 +28,7 @@
endParam
cacheParam
ignoreTimezone
allDayDefault
defaultAllDay
className
editable
color
Expand Down
8 changes: 4 additions & 4 deletions packages/__tests__/src/datelib/rrule.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ describe('rrule plugin', function() {
expect(events[0].allDay).toBe(true)
})

it('inherits allDayDefault from source', function() {
it('inherits defaultAllDay from source', function() {
initCalendar({
allDayDefault: false,
defaultAllDay: false,
events: [
{
rrule: {
Expand All @@ -181,10 +181,10 @@ describe('rrule plugin', function() {
expect(events[0].allDay).toBe(false)
})

it('inherits allDayDefault from source setting', function() {
it('inherits defaultAllDay from source setting', function() {
initCalendar({
eventSources: [ {
allDayDefault: false,
defaultAllDay: false,
events: [
{
rrule: {
Expand Down
24 changes: 12 additions & 12 deletions packages/__tests__/src/legacy/allDayDefault.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

describe('allDayDefault', function() {
describe('defaultAllDay', function() { // TODO: rename file
describe('when undefined', function() {

it('guesses false if T in ISO8601 start date', function() {
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('allDayDefault', function() {

it('has an effect when an event\'s allDay is not specified', function() {
initCalendar({
allDayDefault: false,
defaultAllDay: false,
events: [
{
id: '1',
Expand All @@ -105,7 +105,7 @@ describe('allDayDefault', function() {

it('has no effect when an event\'s allDay is specified', function() {
initCalendar({
allDayDefault: false,
defaultAllDay: false,
events: [
{
id: '1',
Expand All @@ -122,13 +122,13 @@ describe('allDayDefault', function() {

})

describe('source.allDayDefault', function() {
describe('source.defaultAllDay', function() {

it('has an effect when an event\'s allDay is not specified', function() {
initCalendar({
eventSources: [
{
allDayDefault: false,
defaultAllDay: false,
events: [
{
id: '1',
Expand All @@ -142,12 +142,12 @@ describe('source.allDayDefault', function() {
expect(eventObj.allDay).toEqual(false)
})

it('a true value can override the global allDayDefault', function() {
it('a true value can override the global defaultAllDay', function() {
initCalendar({
allDayDefault: false,
defaultAllDay: false,
eventSources: [
{
allDayDefault: true,
defaultAllDay: true,
events: [
{
id: '1',
Expand All @@ -161,12 +161,12 @@ describe('source.allDayDefault', function() {
expect(eventObj.allDay).toEqual(true)
})

it('a false value can override the global allDayDefault', function() {
it('a false value can override the global defaultAllDay', function() {
initCalendar({
allDayDefault: true,
defaultAllDay: true,
eventSources: [
{
allDayDefault: false,
defaultAllDay: false,
events: [
{
id: '1',
Expand All @@ -184,7 +184,7 @@ describe('source.allDayDefault', function() {
initCalendar({
eventSources: [
{
allDayDefault: true,
defaultAllDay: true,
events: [
{
id: '1',
Expand Down
2 changes: 1 addition & 1 deletion packages/__tests__/src/legacy/event-obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('event object creation', function() {
NOTE: Where possible, if there is a specific option that affects event object creation
behavior, write your tests in the individual file for that option, instead of here.
Examples of this:
allDayDefault (tests allDay guessing behavior too)
defaultAllDay (tests allDay guessing behavior too)
eventDataTransform
forceEventDuration
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const globalDefaults = {

timeZone: 'local', // TODO: throw error if given falsy value?

// allDayDefault: undefined,
// defaultAllDay: undefined,

// locale
locales: [],
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/structs/event-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type EventSourceErrorResponseHandler = (error: EventSourceError) => void

export interface ExtendedEventSourceInput {
id?: string | number // only accept number?
allDayDefault?: boolean
defaultAllDay?: boolean
eventDataTransform?: EventInputTransformer

// array or function (TODO: move this to array-event-source/func-event-source?)
Expand Down Expand Up @@ -73,7 +73,7 @@ export interface EventSource {
isFetching: boolean
latestFetchId: string
fetchRange: DateRange | null
allDayDefault: boolean | null
defaultAllDay: boolean | null
eventDataTransform: EventInputTransformer
ui: EventUi
success: EventSourceSuccessResponseHandler | null
Expand Down Expand Up @@ -101,7 +101,7 @@ export interface EventSourceDef {

const SIMPLE_SOURCE_PROPS = {
id: String,
allDayDefault: Boolean,
defaultAllDay: Boolean,
eventDataTransform: Function,
success: Function,
failure: Function
Expand Down
18 changes: 9 additions & 9 deletions packages/core/src/structs/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ export const DATE_PROPS = {


export function parseEvent(raw: EventInput, sourceId: string, calendar: Calendar, allowOpenRange?: boolean): EventTuple | null {
let allDayDefault = computeIsAllDayDefault(sourceId, calendar)
let defaultAllDay = computeIsdefaultAllDay(sourceId, calendar)
let leftovers0 = {}
let recurringRes = parseRecurring(
raw, // raw, but with single-event stuff stripped out
allDayDefault,
defaultAllDay,
calendar.dateEnv,
calendar.pluginSystem.hooks.recurringTypes,
leftovers0 // will populate with non-recurring props
Expand All @@ -101,7 +101,7 @@ export function parseEvent(raw: EventInput, sourceId: string, calendar: Calendar

} else {
let leftovers1 = {}
let singleRes = parseSingle(raw, allDayDefault, calendar, leftovers1, allowOpenRange)
let singleRes = parseSingle(raw, defaultAllDay, calendar, leftovers1, allowOpenRange)

if (singleRes) {
let def = parseEventDef(leftovers1, sourceId, singleRes.allDay, singleRes.hasEnd, calendar)
Expand Down Expand Up @@ -164,7 +164,7 @@ export function createEventInstance(
}


function parseSingle(raw: EventInput, allDayDefault: boolean | null, calendar: Calendar, leftovers?, allowOpenRange?: boolean) {
function parseSingle(raw: EventInput, defaultAllDay: boolean | null, calendar: Calendar, leftovers?, allowOpenRange?: boolean) {
let props = pluckDateProps(raw, leftovers)
let allDay = props.allDay
let startMeta
Expand All @@ -186,8 +186,8 @@ function parseSingle(raw: EventInput, allDayDefault: boolean | null, calendar: C
}

if (allDay == null) {
if (allDayDefault != null) {
allDay = allDayDefault
if (defaultAllDay != null) {
allDay = defaultAllDay
} else {
// fall back to the date props LAST
allDay = (!startMeta || startMeta.isTimeUnspecified) &&
Expand Down Expand Up @@ -258,16 +258,16 @@ function pluckNonDateProps(raw: EventInput, calendar: Calendar, leftovers?) {
}


function computeIsAllDayDefault(sourceId: string, calendar: Calendar): boolean | null {
function computeIsdefaultAllDay(sourceId: string, calendar: Calendar): boolean | null {
let res = null

if (sourceId) {
let source = calendar.state.eventSources[sourceId]
res = source.allDayDefault
res = source.defaultAllDay
}

if (res == null) {
res = calendar.opt('allDayDefault')
res = calendar.opt('defaultAllDay')
}

return res
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/structs/recurring-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface RecurringType {

export function parseRecurring(
eventInput: EventInput,
allDayDefault: boolean | null,
defaultAllDay: boolean | null,
dateEnv: DateEnv,
recurringTypes: RecurringType[],
leftovers: any
Expand All @@ -37,7 +37,7 @@ export function parseRecurring(
let allDay = localLeftovers.allDay
delete localLeftovers.allDay // remove from leftovers
if (allDay == null) {
allDay = allDayDefault
allDay = defaultAllDay
if (allDay == null) {
allDay = parsed.allDayGuess
if (allDay == null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/input-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export interface OptionsInputBase {
eventColor?: string
events?: EventSourceInput
eventSources?: EventSourceInput[]
allDayDefault?: boolean
defaultAllDay?: boolean
startParam?: string
endParam?: string
lazyFetching?: boolean
Expand Down

0 comments on commit 7c14428

Please sign in to comment.