From 63c5625b34d42f33270067c27047d597fd9b46ce Mon Sep 17 00:00:00 2001 From: bobzel Date: Sun, 17 Dec 2023 21:47:22 -0500 Subject: tweaked some things with CalendarView --- .../views/collections/CollectionCalendarView.tsx | 101 +++++++++------------ src/client/views/collections/CollectionSubView.tsx | 2 +- 2 files changed, 45 insertions(+), 58 deletions(-) (limited to 'src/client/views') diff --git a/src/client/views/collections/CollectionCalendarView.tsx b/src/client/views/collections/CollectionCalendarView.tsx index f28154486..ad880b815 100644 --- a/src/client/views/collections/CollectionCalendarView.tsx +++ b/src/client/views/collections/CollectionCalendarView.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { CollectionSubView } from "./CollectionSubView"; +import { CollectionSubView } from './CollectionSubView'; import { observer } from 'mobx-react'; import { computed, makeObservable, observable } from 'mobx'; import { Doc, DocListCast, Opt } from '../../../fields/Doc'; @@ -15,43 +15,36 @@ import { StyleProp } from '../StyleProvider'; import { CollectionFreeFormDocumentView } from '../nodes/CollectionFreeFormDocumentView'; @observer -export class CollectionCalendarView extends CollectionSubView(){ - - constructor(props: any){ +export class CollectionCalendarView extends CollectionSubView() { + constructor(props: any) { super(props); makeObservable(this); } - componentDidMount(): void { - - } + componentDidMount(): void {} - componentWillUnmount(): void { - - } + componentWillUnmount(): void {} - @computed get allCalendars(){ + @computed get allCalendars() { return this.childDocs; // returns a list of docs (i.e. calendars) } - removeCalendar = () => { - - } + removeCalendar = () => {}; addCalendar = (doc: Doc | Doc[], annotationKey?: string | undefined): boolean => { - // bring up calendar modal with option to create a calendar + // bring up calendar modal with option to create a calendar return true; - } + }; _stackRef = React.createRef(); panelHeight = () => { return 0; // TODO: change - } + }; panelWidth = () => { return 0; // TODO: change - } + }; // most recent calendar should come first sortByMostRecentDate = (calendarA: Doc, calendarB: Doc) => { @@ -60,12 +53,13 @@ export class CollectionCalendarView extends CollectionSubView(){ const [aFromDate, aToDate] = dateRangeStrToDates(aDateRangeStr); const [bFromDate, bToDate] = dateRangeStrToDates(bDateRangeStr); - - if (aFromDate > bFromDate) { + + if (aFromDate > bFromDate) { return -1; // a comes first } else if (aFromDate < bFromDate) { return 1; // b comes first - } else { // start dates are the same + } else { + // start dates are the same if (aToDate > bToDate) { return -1; // a comes first } else if (aToDate < bToDate) { @@ -74,11 +68,7 @@ export class CollectionCalendarView extends CollectionSubView(){ return 0; // same start and end dates } } - - - } - - + }; screenToLocalTransform = () => this._props @@ -90,38 +80,35 @@ export class CollectionCalendarView extends CollectionSubView(){ return this._props.fieldKey + '_calendars'; } - render(){ + render() { return (
- +
- - ) + ); } -} \ No newline at end of file +} diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx index 0131af6f2..b56973dc6 100644 --- a/src/client/views/collections/CollectionSubView.tsx +++ b/src/client/views/collections/CollectionSubView.tsx @@ -212,7 +212,7 @@ export function CollectionSubView(moreProps?: X) { addDocument = (doc: Doc | Doc[], annotationKey?: string) => this._props.addDocument?.(doc, annotationKey) || false; removeDocument = (doc: Doc | Doc[], annotationKey?: string) => this._props.removeDocument?.(doc, annotationKey) || false; - moveDocument = (doc: Doc | Doc[], targetCollection: Doc | undefined, addDocument: (doc: Doc | Doc[], annotationKey?: string) => boolean, annotationKey?: string) => this._props.moveDocument?.(doc, targetCollection, addDocument); + moveDocument = (doc: Doc | Doc[], targetCollection: Doc | undefined, addDocument: (doc: Doc | Doc[], annotationKey?: string) => boolean, annotationKey?: string) => this._props.moveDocument?.(doc, targetCollection, addDocument) || false; protected onInternalDrop(e: Event, de: DragManager.DropEvent): boolean { const docDragData = de.complete.docDragData; -- cgit v1.2.3-70-g09d2