import { Constants } from './Constants' ; import { Day } from './Day' ; import { DaySpan , DaySpanBounds } from './DaySpan' ; import { Event } from './Event' ; import { Identifier , IdentifierInput } from './Identifier' ; import { Schedule } from './Schedule' ; typeparam typeparam export class CalendarEvent < T , M > { /**
     * The relatively unique identifier of this event. It is generated based on
     * the index of the schedule in the calendar and the time of day listed in the
     * schedule. This number will no longer be unique if the schedule has more
     * than [[Constants.MAX_EVENTS_PER_DAY]] occurrences in a single day
     * (based on number of times in [[Schedule.times]]).
     */ public id : number ; /**
     * The event with the schedule.
     */ public event : Event < T , M > ; /**
     * Any metadata specified for this event instance in the schedule.
     */ public meta : M ; /**
     * The day this event occurs on.
     */ public day : Day ; see public time : DaySpan ; see public fullDay : boolean ; /**
     * Whether this event is the first day of an occurrence. A calendar can
     * generate multiple [[CalendarEvent]] instances over each day it covers if
     * [[Calendar.repeatCovers]] is true. These instances have matching
     * [[CalendarEvent.id]] values.
     */ public starting : boolean ; /**
     * Whether this event is the last day of an occurrence. A calendar can
     * generate multiple [[CalendarEvent]] instances over each day it covers if
     * [[Calendar.repeatCovers]] is true. These instances have matching
     * [[CalendarEvent.id]] values.
     */ public ending : boolean ; /**
     * Whether this event instance was marked as cancelled in the schedule.
     */ public cancelled : boolean ; /**
     * The row this event is on in a visual calendar. An event can span multiple
     * days and it is desirable to have the occurrence on each day to line up.
     * This is only set when [[Calendar.updateRows]] is true or manually set.
     * This value makes sense for visual calendars for all day events or when the
     * visual calendar is not positioning events based on their time span.
     */ public row : number = 0 ; /**
     * The column this event is on in a visual calendar. An event can have its
     * time overlap with another event displaying one of the events in another
     * column. This is only set when [[Calendar.updateColumns]] is true or
     * manually set. This value makes sense for visual calendars that are
     * displaying event occurrences at specific times positioned accordingly.
     */ public col : number = 0 ; param id param event param time param actualDay public constructor ( id , event , time , actualDay ) { this . id = id ; this . event = event ; this . time = time ; this . day = actualDay ; this . fullDay = event . schedule . isFullDay ( ) ; this . meta = event . schedule . getMeta ( time . start ) ; this . cancelled = event . schedule . isCancelled ( time . start ) ; this . starting = time . isPoint || time . start . sameDay ( actualDay ) ; this . ending = time . isPoint || time . end . relative ( - 1 ) . sameDay ( actualDay ) ; } /**
     * The id of the schedule uniqe within the calendar which generated this event.
     */ public get scheduleId ( ) : number { return Math . floor ( this . id / Constants . MAX_EVENTS_PER_DAY ) ; } /**
     * The start timestamp of the event.
     */ public get start ( ) : Day { return this . time . start ; } /**
     * The end timestamp of the event.
     */ public get end ( ) : Day { return this . time . end ; } /**
     * The schedule which generated this event.
     */ public get schedule ( ) : Schedule < M > { return this . event . schedule ; } /**
     * The related event data.
     */ public get data ( ) : T { return this . event . data ; } /**
     * An [[IdentifierInput]] for the start of this event.
     */ public get identifier ( ) : IdentifierInput { return this . identifierType . get ( this . start ) ; } /**
     * The [[Identifier]] for this event. Either [[Identifier.Day]] or
     * [[Identifier.Time]].
     */ public get identifierType ( ) : Identifier { return this . schedule . identifierType ; } /**
     * Returns a delta value between 0 and 1 which represents where the
     * [[CalendarEvent.start]] is relative to [[CalendarEvent.day]]. The delta
     * value would be less than 0 if the start of the event is before
     * [[CalendarEvent.day]].
     */ public get startDelta ( ) : number { return this . time . startDelta ( this . day ) ; } /**
     * Returns a delta value between 0 and 1 which represents where the
     * [[CalendarEvent.end]] is relative to [[CalendarEvent.day]]. The delta value
     * would be greater than 1 if the end of the event is after
     * [[CalendarEvent.day]].
     */ public get endDelta ( ) : number { return this . time . endDelta ( this . day ) ; } param dayHeight param dayWidth param columnOffset param clip param offsetX param offsetY returns public getTimeBounds ( dayHeight = 1 , dayWidth = 1 , columnOffset = 0.1 , clip = true , offsetX = 0 , offsetY = 0 ) { return this . time . getBounds ( this . day , dayHeight , dayWidth , this . col * columnOffset , clip , offsetX , offsetY ) ; } param cancelled public cancel ( cancelled = true ) { this . schedule . setCancelled ( this . start , cancelled ) ; this . cancelled = cancelled ; return this ; } param excluded public exclude ( excluded = true ) { this . schedule . setExcluded ( this . start , excluded ) ; return this ; } param toTime returns public move ( toTime ) { return this . schedule . move ( toTime , this . start ) ; } }