Merge JournalAddressbook and JournalCalendar.
parent
dd0b214702
commit
f74ec6f05a
@ -1,66 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import { Route, Switch, withRouter } from 'react-router';
|
||||
|
||||
import * as EteSync from '../api/EteSync';
|
||||
|
||||
import { routeResolver } from '../App';
|
||||
|
||||
import { History } from 'history';
|
||||
|
||||
import AddressBook from '../components/AddressBook';
|
||||
import Contact from '../components/Contact';
|
||||
|
||||
import { ContactType } from '../pim-types';
|
||||
|
||||
function objValues(obj: any) {
|
||||
return Object.keys(obj).map((x) => obj[x]);
|
||||
}
|
||||
|
||||
class JournalAddressBook extends React.PureComponent {
|
||||
props: {
|
||||
journal: EteSync.Journal,
|
||||
entries: {[key: string]: ContactType},
|
||||
history?: History,
|
||||
};
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.contactClicked = this.contactClicked.bind(this);
|
||||
}
|
||||
|
||||
contactClicked(contact: ContactType) {
|
||||
const uid = contact.uid;
|
||||
|
||||
this.props.history!.push(
|
||||
routeResolver.getRoute('journals._id.items._id', { journalUid: this.props.journal.uid, itemUid: uid }));
|
||||
}
|
||||
|
||||
render() {
|
||||
let items = this.props.entries;
|
||||
|
||||
return (
|
||||
<Switch>
|
||||
<Route
|
||||
path={routeResolver.getRoute('journals._id')}
|
||||
exact={true}
|
||||
render={() => (
|
||||
<AddressBook entries={objValues(items)} onItemClick={this.contactClicked} />
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routeResolver.getRoute('journals._id.items._id')}
|
||||
exact={true}
|
||||
render={({match}) => {
|
||||
|
||||
return (
|
||||
<Contact contact={items[match.params.itemUid]} />
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Switch>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withRouter(JournalAddressBook);
|
@ -1,67 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import { Route, Switch, withRouter } from 'react-router';
|
||||
|
||||
import { History } from 'history';
|
||||
|
||||
import { routeResolver } from '../App';
|
||||
|
||||
import { historyPersistor } from '../persist-state-history';
|
||||
|
||||
import Calendar from '../components/Calendar';
|
||||
import Event from '../components/Event';
|
||||
|
||||
import { EventType } from '../pim-types';
|
||||
|
||||
import * as EteSync from '../api/EteSync';
|
||||
|
||||
function objValues(obj: any) {
|
||||
return Object.keys(obj).map((x) => obj[x]);
|
||||
}
|
||||
|
||||
const PersistCalendar = historyPersistor('Calendar')(Calendar);
|
||||
|
||||
class JournalCalendar extends React.PureComponent {
|
||||
props: {
|
||||
journal: EteSync.Journal,
|
||||
entries: {[key: string]: EventType},
|
||||
history?: History,
|
||||
};
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.eventClicked = this.eventClicked.bind(this);
|
||||
}
|
||||
|
||||
eventClicked(event: EventType) {
|
||||
const uid = event.uid;
|
||||
|
||||
this.props.history!.push(
|
||||
routeResolver.getRoute('journals._id.items._id', { journalUid: this.props.journal.uid, itemUid: uid }));
|
||||
}
|
||||
|
||||
render() {
|
||||
let items = this.props.entries;
|
||||
|
||||
return (
|
||||
<Switch>
|
||||
<Route
|
||||
path={routeResolver.getRoute('journals._id')}
|
||||
exact={true}
|
||||
render={() => (
|
||||
<PersistCalendar entries={objValues(items)} onItemClick={this.eventClicked} />
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routeResolver.getRoute('journals._id.items._id')}
|
||||
exact={true}
|
||||
render={({match}) => (
|
||||
<Event event={items[match.params.itemUid]} />
|
||||
)}
|
||||
/>
|
||||
</Switch>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default withRouter(JournalCalendar);
|
@ -0,0 +1,63 @@
|
||||
import * as React from 'react';
|
||||
import { Route, Switch, withRouter } from 'react-router';
|
||||
|
||||
import * as EteSync from '../api/EteSync';
|
||||
|
||||
import { routeResolver } from '../App';
|
||||
|
||||
import { History } from 'history';
|
||||
|
||||
function objValues(obj: any) {
|
||||
return Object.keys(obj).map((x) => obj[x]);
|
||||
}
|
||||
|
||||
export function journalView(JournalList: any, JournalItem: any) {
|
||||
return withRouter(class extends React.PureComponent {
|
||||
props: {
|
||||
journal: EteSync.Journal,
|
||||
entries: {[key: string]: any},
|
||||
history?: History,
|
||||
};
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.itemClicked = this.itemClicked.bind(this);
|
||||
}
|
||||
|
||||
itemClicked(contact: any) {
|
||||
const uid = contact.uid;
|
||||
|
||||
this.props.history!.push(
|
||||
routeResolver.getRoute('journals._id.items._id', { journalUid: this.props.journal.uid, itemUid: uid }));
|
||||
}
|
||||
|
||||
render() {
|
||||
let items = this.props.entries;
|
||||
|
||||
return (
|
||||
<Switch>
|
||||
<Route
|
||||
path={routeResolver.getRoute('journals._id')}
|
||||
exact={true}
|
||||
render={() => (
|
||||
<JournalList entries={objValues(items)} onItemClick={this.itemClicked} />
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={routeResolver.getRoute('journals._id.items._id')}
|
||||
exact={true}
|
||||
render={({match}) => {
|
||||
|
||||
return (
|
||||
<JournalItem item={items[match.params.itemUid]} />
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Switch>
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default journalView;
|
Loading…
Reference in New Issue