Fix editing events of a journal other than the default.

master
Tom Hacohen 7 years ago
parent 6d4c9c01e0
commit da935c0836

@ -150,7 +150,9 @@ class ContactEdit extends React.Component {
this.state.uid = uuid.v4();
}
if (props.collections[0]) {
if (props.initialCollection) {
this.state.journalUid = props.initialCollection;
} else if (props.collections[0]) {
this.state.journalUid = props.collections[0].uid;
}
this.onSubmit = this.onSubmit.bind(this);
@ -162,9 +164,12 @@ class ContactEdit extends React.Component {
}
componentWillReceiveProps(nextProps: any) {
if (this.props.collections !== nextProps.collections) {
if (nextProps.collections[0]) {
this.setState({journalUid: nextProps.collections[0].uid});
if ((this.props.collections !== nextProps.collections) ||
(this.props.initialCollection !== nextProps.initialCollection)) {
if (nextProps.initialCollection) {
this.state.journalUid = nextProps.initialCollection;
} else if (nextProps.collections[0]) {
this.state.journalUid = nextProps.collections[0].uid;
}
}
}

@ -59,9 +59,12 @@ class EventEdit extends React.Component {
this.state.uid = uuid.v4();
}
if (this.props.collections[0]) {
if (props.initialCollection) {
this.state.journalUid = props.initialCollection;
} else if (props.collections[0]) {
this.state.journalUid = props.collections[0].uid;
}
this.onSubmit = this.onSubmit.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleInputChange = this.handleInputChange.bind(this);
@ -69,9 +72,12 @@ class EventEdit extends React.Component {
}
componentWillReceiveProps(nextProps: any) {
if (this.props.collections !== nextProps.collections) {
if (nextProps.collections[0]) {
this.setState({journalUid: nextProps.collections[0].uid});
if ((this.props.collections !== nextProps.collections) ||
(this.props.initialCollection !== nextProps.initialCollection)) {
if (nextProps.initialCollection) {
this.state.journalUid = nextProps.initialCollection;
} else if (nextProps.collections[0]) {
this.state.journalUid = nextProps.collections[0].uid;
}
}
}

@ -156,6 +156,7 @@ class Pim extends React.Component {
render={({match}) => (
<Container style={{maxWidth: 400}}>
<ContactEdit
initialCollection={(addressBookItems[match.params.contactUid] as any).journalUid}
contact={addressBookItems[match.params.contactUid]}
collections={collectionsAddressBook}
onSave={this.onContactSave}
@ -199,6 +200,7 @@ class Pim extends React.Component {
render={({match}) => (
<Container style={{maxWidth: 400}}>
<EventEdit
initialCollection={(calendarItems[match.params.eventUid] as any).journalUid}
event={calendarItems[match.params.eventUid]}
collections={collectionsCalendar}
onSave={this.onEventSave}

@ -12,6 +12,9 @@ export function syncEntriesToItemMap(collection: EteSync.CollectionInfo, entries
const uid = comp.uid;
// FIXME:Hack
(comp as any).journalUid = collection.uid;
if ((syncEntry.action === EteSync.SyncEntryAction.Add) ||
(syncEntry.action === EteSync.SyncEntryAction.Change)) {
items[uid] = comp;
@ -60,6 +63,9 @@ export function syncEntriesToCalendarItemMap(collection: EteSync.CollectionInfo,
const uid = comp.uid;
// FIXME:Hack
(comp as any).journalUid = collection.uid;
if ((syncEntry.action === EteSync.SyncEntryAction.Add) ||
(syncEntry.action === EteSync.SyncEntryAction.Change)) {
items[uid] = comp;

Loading…
Cancel
Save