import { computed, makeObservable } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; import { dateRangeStrToDates, emptyFunction, returnTrue } from '../../../Utils'; import { Doc, DocListCast } from '../../../fields/Doc'; import { StrCast } from '../../../fields/Types'; import { CollectionStackingView } from './CollectionStackingView'; import { CollectionSubView } from './CollectionSubView'; @observer export class CollectionCalendarView extends CollectionSubView() { constructor(props: any) { super(props); makeObservable(this); } componentDidMount(): void {} componentWillUnmount(): void {} @computed get allCalendars() { return this.childDocs; // returns a list of docs (i.e. calendars) } removeCalendar = () => {}; addCalendar = (doc: Doc | Doc[], annotationKey?: string | undefined): boolean => { // bring up calendar modal with option to create a calendar return true; }; _stackRef = React.createRef(); panelHeight = () => { return this._props.PanelHeight() - 40; // this should be the height of the stacking view. For now, it's the hieight of the calendar view minus 40 to allow for a title }; // most recent calendar should come first sortByMostRecentDate = (calendarA: Doc, calendarB: Doc) => { const aDateRangeStr = StrCast(DocListCast(calendarA.data).lastElement()?.date_range); const bDateRangeStr = StrCast(DocListCast(calendarB.data).lastElement()?.date_range); const [aFromDate, aToDate] = dateRangeStrToDates(aDateRangeStr); const [bFromDate, bToDate] = dateRangeStrToDates(bDateRangeStr); if (aFromDate > bFromDate) { return -1; // a comes first } else if (aFromDate < bFromDate) { return 1; // b comes first } else { // start dates are the same if (aToDate > bToDate) { return -1; // a comes first } else if (aToDate < bToDate) { return 1; // b comes first } else { return 0; // same start and end dates } } }; screenToLocalTransform = () => this._props .ScreenToLocalTransform() .translate(Doc.NativeWidth(this.Document), 0) .scale(this._props.NativeDimScaling?.() || 1); get calendarsKey() { return this._props.fieldKey; } render() { return (
); } }