|
|
@ -3,35 +3,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
import * as React from 'react';
|
|
|
|
import IconButton from '@material-ui/core/IconButton';
|
|
|
|
import IconButton from '@material-ui/core/IconButton';
|
|
|
|
import Tab from '@material-ui/core/Tab';
|
|
|
|
|
|
|
|
import Tabs from '@material-ui/core/Tabs';
|
|
|
|
|
|
|
|
import { Theme, withTheme } from '@material-ui/core/styles';
|
|
|
|
|
|
|
|
import IconEdit from '@material-ui/icons/Edit';
|
|
|
|
import IconEdit from '@material-ui/icons/Edit';
|
|
|
|
import IconMembers from '@material-ui/icons/People';
|
|
|
|
import IconMembers from '@material-ui/icons/People';
|
|
|
|
import IconImport from '@material-ui/icons/ImportExport';
|
|
|
|
import IconImport from '@material-ui/icons/ImportExport';
|
|
|
|
|
|
|
|
|
|
|
|
import SearchableAddressBook from '../components/SearchableAddressBook';
|
|
|
|
|
|
|
|
import Contact from '../components/Contact';
|
|
|
|
|
|
|
|
import Calendar from '../components/Calendar';
|
|
|
|
|
|
|
|
import Event from '../components/Event';
|
|
|
|
|
|
|
|
import Task from '../components/Tasks/Task';
|
|
|
|
|
|
|
|
import TaskList from '../components/Tasks/TaskList';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import AppBarOverride from '../widgets/AppBarOverride';
|
|
|
|
import AppBarOverride from '../widgets/AppBarOverride';
|
|
|
|
import Container from '../widgets/Container';
|
|
|
|
import Container from '../widgets/Container';
|
|
|
|
|
|
|
|
|
|
|
|
import JournalEntries from '../components/JournalEntries';
|
|
|
|
import JournalEntries from '../components/JournalEntries';
|
|
|
|
import journalView from './journalView';
|
|
|
|
|
|
|
|
import ImportDialog from './ImportDialog';
|
|
|
|
import ImportDialog from './ImportDialog';
|
|
|
|
|
|
|
|
|
|
|
|
import { syncEntriesToItemMap, syncEntriesToEventItemMap, syncEntriesToTaskItemMap } from '../journal-processors';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { SyncInfo, SyncInfoJournal } from '../SyncGate';
|
|
|
|
import { SyncInfo, SyncInfoJournal } from '../SyncGate';
|
|
|
|
|
|
|
|
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
|
|
|
|
|
|
|
import { routeResolver } from '../App';
|
|
|
|
import { routeResolver } from '../App';
|
|
|
|
import { historyPersistor } from '../persist-state-history';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { CredentialsData, UserInfoData } from '../store';
|
|
|
|
import { CredentialsData, UserInfoData } from '../store';
|
|
|
|
|
|
|
|
|
|
|
@ -43,22 +30,13 @@ interface PropsType {
|
|
|
|
isOwner: boolean;
|
|
|
|
isOwner: boolean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
interface PropsTypeInner extends PropsType {
|
|
|
|
class Journal extends React.Component<PropsType> {
|
|
|
|
theme: Theme;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const JournalAddressBook = journalView(SearchableAddressBook, Contact);
|
|
|
|
|
|
|
|
const PersistCalendar = historyPersistor('Calendar')(Calendar);
|
|
|
|
|
|
|
|
const JournalCalendar = journalView(PersistCalendar, Event);
|
|
|
|
|
|
|
|
const JournalTaskList = journalView(TaskList, Task);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Journal extends React.Component<PropsTypeInner> {
|
|
|
|
|
|
|
|
public state: {
|
|
|
|
public state: {
|
|
|
|
tab: number;
|
|
|
|
tab: number;
|
|
|
|
importDialogOpen: boolean;
|
|
|
|
importDialogOpen: boolean;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
constructor(props: PropsTypeInner) {
|
|
|
|
constructor(props: PropsType) {
|
|
|
|
super(props);
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
|
|
|
|
this.importDialogToggle = this.importDialogToggle.bind(this);
|
|
|
|
this.importDialogToggle = this.importDialogToggle.bind(this);
|
|
|
@ -69,43 +47,12 @@ class Journal extends React.Component<PropsTypeInner> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
public render() {
|
|
|
|
const { theme, isOwner, syncJournal } = this.props;
|
|
|
|
const { isOwner, syncJournal } = this.props;
|
|
|
|
let currentTab = this.state.tab;
|
|
|
|
|
|
|
|
let journalOnly = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const journal = syncJournal.journal;
|
|
|
|
const journal = syncJournal.journal;
|
|
|
|
const collectionInfo = syncJournal.collection;
|
|
|
|
const collectionInfo = syncJournal.collection;
|
|
|
|
const syncEntries = syncJournal.entries;
|
|
|
|
const syncEntries = syncJournal.entries;
|
|
|
|
|
|
|
|
|
|
|
|
let itemsTitle: string;
|
|
|
|
|
|
|
|
let itemsView: JSX.Element;
|
|
|
|
|
|
|
|
if (collectionInfo.type === 'CALENDAR') {
|
|
|
|
|
|
|
|
itemsView = (
|
|
|
|
|
|
|
|
<JournalCalendar
|
|
|
|
|
|
|
|
journal={journal}
|
|
|
|
|
|
|
|
entries={syncEntriesToEventItemMap(collectionInfo, syncEntries)}
|
|
|
|
|
|
|
|
/>);
|
|
|
|
|
|
|
|
itemsTitle = 'Events';
|
|
|
|
|
|
|
|
} else if (collectionInfo.type === 'ADDRESS_BOOK') {
|
|
|
|
|
|
|
|
itemsView =
|
|
|
|
|
|
|
|
<JournalAddressBook journal={journal} entries={syncEntriesToItemMap(collectionInfo, syncEntries)} />;
|
|
|
|
|
|
|
|
itemsTitle = 'Contacts';
|
|
|
|
|
|
|
|
} else if (collectionInfo.type === 'TASKS') {
|
|
|
|
|
|
|
|
itemsView = (
|
|
|
|
|
|
|
|
<JournalTaskList
|
|
|
|
|
|
|
|
journal={journal}
|
|
|
|
|
|
|
|
syncInfo={this.props.syncInfo}
|
|
|
|
|
|
|
|
entries={syncEntriesToTaskItemMap(collectionInfo, syncEntries)}
|
|
|
|
|
|
|
|
/>);
|
|
|
|
|
|
|
|
itemsTitle = 'Tasks';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
itemsView = <div>Preview is not supported for this journal type</div>;
|
|
|
|
|
|
|
|
itemsTitle = 'Items';
|
|
|
|
|
|
|
|
journalOnly = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentTab = journalOnly ? 1 : currentTab;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<React.Fragment>
|
|
|
|
<React.Fragment>
|
|
|
|
<AppBarOverride title={collectionInfo.displayName}>
|
|
|
|
<AppBarOverride title={collectionInfo.displayName}>
|
|
|
@ -134,25 +81,9 @@ class Journal extends React.Component<PropsTypeInner> {
|
|
|
|
<IconImport />
|
|
|
|
<IconImport />
|
|
|
|
</IconButton>
|
|
|
|
</IconButton>
|
|
|
|
</AppBarOverride>
|
|
|
|
</AppBarOverride>
|
|
|
|
<Tabs
|
|
|
|
<Container>
|
|
|
|
variant="fullWidth"
|
|
|
|
<JournalEntries journal={journal} entries={syncEntries} />
|
|
|
|
style={{ backgroundColor: theme.palette.primary.main }}
|
|
|
|
</Container>
|
|
|
|
value={currentTab}
|
|
|
|
|
|
|
|
onChange={(_event, tab) => this.setState({ tab })}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<Tab label={itemsTitle} disabled={journalOnly} />
|
|
|
|
|
|
|
|
<Tab label="Journal Entries" />
|
|
|
|
|
|
|
|
</Tabs>
|
|
|
|
|
|
|
|
{currentTab === 0 &&
|
|
|
|
|
|
|
|
<Container>
|
|
|
|
|
|
|
|
{itemsView}
|
|
|
|
|
|
|
|
</Container>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
{currentTab === 1 &&
|
|
|
|
|
|
|
|
<Container>
|
|
|
|
|
|
|
|
<JournalEntries journal={journal} entries={syncEntries} />
|
|
|
|
|
|
|
|
</Container>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ImportDialog
|
|
|
|
<ImportDialog
|
|
|
|
etesync={this.props.etesync}
|
|
|
|
etesync={this.props.etesync}
|
|
|
@ -170,4 +101,4 @@ class Journal extends React.Component<PropsTypeInner> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default withTheme(Journal);
|
|
|
|
export default Journal;
|
|
|
|