import AgendaStore, { IItem, Item, Day } from './models/AgendaStore'; import moment, { Moment } from 'moment'; import UIStore, { UIState } from './models/UIStore'; import { ItemUIState } from './models/ItemModel'; import { IAgendaJSON } from './models/AgendaModel'; import { Cancelable } from 'lodash'; import { IDayJSON, IDay } from './models/DayModel'; export declare class AgendaViewModel { agendaStore: AgendaStore; uiStore: UIStore; handleDataChange: ((() => void) & Cancelable) | undefined; /** * The AgendaViewModel is the central API for interacting with the react-event-agenda component. * The UI reacts to all changes made using the ViewModel's methods. * * @param {IAgendaJSON} data - initial Data * @param {(data: IAgendaJSON) => void} handleDataChange - this function gets called whenever the user changes the agenda, it is debounced. * * @example const agendaViewModel = new AgendaViewModel(initialData, data => saveToDB(data)); */ constructor(data: IAgendaJSON, handleDataChange?: (data: IAgendaJSON) => void); /** * Sets the given JSON data for the agenda. * * @param {IAgendaJSON} data */ setData(data: IAgendaJSON): void; /** * Gets the current agenda data. * * @return {IAgendaJSON} the current agenda data */ getData(): IAgendaJSON; private pruneItemUIState; /** * Gets the UIState. The UIState shows which kind of action the user is currently performing. * * @return {UIState} the current agenda data */ getUIState(): UIState; /** * Updates the UIState. * * @param {UIState} newState */ updateUIState(newState: UIState): void; /** * Gets the agenda's store. In general you should not access the store directly. * Use the Viewmodels methods instead. * * @return {AgendaStore} the agenda's store */ getAgendaStore(): AgendaStore; /** * The intervalPXHeight is the height in px of one interval. * An interval is the number of minutes the items snap to in th UI. * * @return {number} */ getIntervalPxHeight(): number; /** * The number of minutes which are one interval. * The items are snapping to the intervals in the UI. * * @return {number} */ getIntervalInMin(): number; /** * The number of intervals which one segment contains. * * @return {number} */ getSegmentFactor(): number; /** * The number of intervals which one segment contains. * * @return {IDay[]} */ getDays(filter?: { uiHidden?: boolean; }): IDay[]; /** * * @param id - the ID of the day to delete */ deleteDay(id: string): void; /** * * @param day - the day to add. */ addDay(day: IDayJSON): void; /** * Gets the day which holds the track with the given ID. * Returns undefined if no day has been found. * * @param trackId * @return {IDay | undefined} */ getDayForTrack(trackId: string): IDay | undefined; /** * * @param id */ getDayForItem(id: string): IDay | undefined; /** * Hides or reveals the given day. Used for pagination. * * @param id * @param value */ setDayUiHidden(id: string, value: boolean): void; getItem(id: string): IItem | undefined; getItems(filter?: { uiState?: ItemUIState; }, itemIds?: Array): IItem[]; /** * Gets the timelines startTime which is the earliest start time from all days. * If dateToSet given moves its day there. * * @param dateToSet - the day to move the start time to * @return {Moment | undefined} */ getTimeLineStartTime(dateToSet?: Moment): moment.Moment | undefined; /** * Gets the timelines startTime which is the latest end time from all days. * If dateToSet given moves its day there. * * @param dateToSet - the day to move the end time to * @return {Moment | undefined} */ getTimeLineEndTime(dateToSet?: Moment): moment.Moment | undefined; /** * Gets the width which is available to display tracks. * * @return {Moment | undefined} */ getTotalTracksWidth(): number; /** * Sets the width which is available to display tracks. * Is called whenever the viewport width is changing * * @param value */ setTotalTracksWidth(value: number): void; /** * @return {number} the width of a single track currently displayed. */ getTrackWidth(): number; /** * * @param value - the new width of a single track currently displayed. */ setTrackWidth(value: number): void; /** * Saves the itemId in the selectHistory stack. * Needed for selecting multiple items using shift. * * @param itemId */ pushToSelectHistory(itemId: string): void; /** * Deletes the given ItemID from the selectHistory Stack. * Needed for selecting multiple items using shift. * @param itemId */ deleteFromSelectHistory(itemId: string): void; /** * Deletes all Item IDs from the selectHistoryStack. * Needed for selecting multiple items using shift. */ clearSelectHistory(): void; /** * Selects all items between the last selected Item and the given Item and the given Item. * * @param itemId */ selectItemsWithShift(itemId: string): void; /** * Deletes the item with the given Id. * * @param id * @param suppressPushToHistory - suppress adding new state to history stack for Undo/Redo */ deleteItem(id: string, suppressPushToHistory?: boolean): void; /** * Adds the item to the given Track and sorts all items on the track afterwards. * * @param item - the items data * @param trackId - the track to put the items on * @param suppressPushToHistory - suppress adding new state to history stack for Undo/Redo */ addItem(item: IItem, trackId: string, suppressPushToHistory?: boolean): void; /** * Partially updates the Item's Properties. * * @param id * @param newProps * @param suppressPushToHistory - suppress adding new state to history stack for Undo/Redo */ updateItem(id: string, newProps: { title?: string; speaker?: string; description?: string; }, suppressPushToHistory?: boolean): void; /** * Updates the item ItemUIState. * The ItemUIState shows how the user is currently interacting with a specific Item. * * @param id * @param newUIState */ updateItemUIState(id: string, newUIState: ItemUIState | undefined): void; /** * Moves the given Items by the given amount of time. * Does not handle collisions. * * @param items * @param milSecToMove */ moveItemsForced(items: Array, milSecToMove: number): void; /** * Finds the first overlapping time ranges of one item with the given items. * * @param items * @param item * @param exceptItemIds - items with which collisions should be ignored */ private findFirstCollidingIndex; /** * Get the sum of all durations of the items. * * @param items * @returns the total duration */ private getTotalDuration; /** * Check if the item is directly between two others on the same track. * * @param item * @private itemIdsToIgnore */ private itemIsBetweenTwoOthers; /** * Inserts an Item at the given position. Moves colliding items accordingly. * Does not adds the given item on a track or saves it. Only moves the other items accordingly. * * @param item * @param items * @param overlappingItemIndex - the first colliding index * @param notToMoveIds */ private insertItemAfter; /** * Inserts an Item at the given position. Moves colliding items accordingly. * Does not adds the given item on a track or saves it. Only moves the other items accordingly. * * @param item * @param items * @param overlappingItemIndex - the first colliding index * @param notToMoveIds */ private insertItemBefore; private checkMoveItemsParameters; /** * Tries to move the given Items to the given start time at the given Track. * Avoids collisions with other items. * Therefore the given start time does not have to be the new one. * * @param trackId - the track's id to move to * @param clickedId - the item's id which the user grabbed of all the itemsIds * @param newStart - the new start time where the items should be moved to * @param itemIds - the items to move */ moveItems(trackId: string, clickedId: string, newStart: Moment, itemIds: Array): void; /** * Unselects all items. */ unselectAll(): void; /** * * @param keepItemUIState - if the itemUIState (e.g. which items are selected) should be used from the history * @param suppressDataChangeHandling - if the change should not be handled (e.g. not save to a database), handle data change will not be called */ undo(keepItemUIState?: boolean, suppressDataChangeHandling?: boolean): void; /** * @return if there is a state to undo to */ canUndo(): boolean; /** * * @param keepItemUIState - if the itemUIState (e.g. which items are selected) should be used from the history * @param suppressDataChangeHandling - if the change should not be handled (e.g. not save to a database), handle data change will not be called */ redo(keepItemUIState?: boolean, suppressDataChangeHandling?: boolean): void; /** * @return if there is a state to redo to */ canRedo(): boolean; /** * adds the current state to the undo/redo history stack * @param suppressDataChangeHandling - if the change should not be handled (e.g. not save to a database), handle data change will not be called */ pushToHistory(suppressDataChangeHandling?: boolean): void; /** * overwrites the current entry with out adding a new one to the undo/redo history stack. */ overWriteCurrentHistoryEntry(): void; /** * Tries to change the item's start time. * If the newStartTime is before the end time of the previous item no changes are applied. * * @param itemId * @param newStartTime */ adjustItemStartTime(itemId: string, newStartTime: Moment): void; /** * Tries to change the item's end time. * If the new end time is after the start time of the next item all next items on the track * are moved to avoid collisions. * * @param itemId * @param newStartTime */ adjustItemEndTime(itemId: string, newEndTime: Moment): void; /** * Checks if there are days left to paginate to. */ canPaginateRight(): boolean; /** * Paginates the days to the right. */ paginateRight(): void; /** * Checks if there are days left to paginate to. */ canPaginateLeft(): boolean; /** * Paginates the days to the left. */ paginateLeft(): void; getDaysToReveal(numberToReveal: number): Day[]; getNumberOfDisplayableTracks(): number; applyTotalTrackWidthToTrackVisibility(): void; /** * Moves all days and their track's items for the given number of days. * * @param numberOfDays - the number of days to move, may be negative. */ addDaysToAllDates(numberOfDays: number): void; }