Unify the names of the props of ContactEdit and EventEdit.

master
Tom Hacohen 7 years ago
parent 40af8a49d7
commit 7bd3051416

@ -169,7 +169,7 @@ class Pim extends React.PureComponent {
<Container style={{maxWidth: 400}}> <Container style={{maxWidth: 400}}>
<ContactEdit <ContactEdit
initialCollection={(addressBookItems[match.params.itemUid] as any).journalUid} initialCollection={(addressBookItems[match.params.itemUid] as any).journalUid}
contact={addressBookItems[match.params.itemUid]} item={addressBookItems[match.params.itemUid]}
collections={collectionsAddressBook} collections={collectionsAddressBook}
onSave={this.onContactSave} onSave={this.onContactSave}
/> />
@ -238,7 +238,7 @@ class Pim extends React.PureComponent {
<Container style={{maxWidth: 400}}> <Container style={{maxWidth: 400}}>
<EventEdit <EventEdit
initialCollection={(calendarItems[match.params.itemUid] as any).journalUid} initialCollection={(calendarItems[match.params.itemUid] as any).journalUid}
event={calendarItems[match.params.itemUid]} item={calendarItems[match.params.itemUid]}
collections={collectionsCalendar} collections={collectionsCalendar}
onSave={this.onEventSave} onSave={this.onEventSave}
/> />

@ -120,7 +120,7 @@ class ContactEdit extends React.PureComponent {
props: { props: {
collections: Array<EteSync.CollectionInfo>, collections: Array<EteSync.CollectionInfo>,
initialCollection?: string, initialCollection?: string,
contact?: ContactType, item?: ContactType,
onSave: (contact: ContactType, journalUid: string, originalContact?: ContactType) => void; onSave: (contact: ContactType, journalUid: string, originalContact?: ContactType) => void;
}; };
@ -140,8 +140,8 @@ class ContactEdit extends React.PureComponent {
journalUid: '', journalUid: '',
}; };
if (this.props.contact !== undefined) { if (this.props.item !== undefined) {
const contact = this.props.contact; const contact = this.props.item;
this.state.uid = contact.uid; this.state.uid = contact.uid;
this.state.fn = contact.fn ? contact.fn : ''; this.state.fn = contact.fn ? contact.fn : '';
@ -248,8 +248,8 @@ class ContactEdit extends React.PureComponent {
onSubmit(e: React.FormEvent<any>) { onSubmit(e: React.FormEvent<any>) {
e.preventDefault(); e.preventDefault();
let contact = (this.props.contact) ? let contact = (this.props.item) ?
this.props.contact.clone() this.props.item.clone()
: :
new ContactType(new ICAL.Component(['vcard', [], []])) new ContactType(new ICAL.Component(['vcard', [], []]))
; ;
@ -293,7 +293,7 @@ class ContactEdit extends React.PureComponent {
setProperty('title', this.state.title); setProperty('title', this.state.title);
setProperty('note', this.state.note); setProperty('note', this.state.note);
this.props.onSave(contact, this.state.journalUid, this.props.contact); this.props.onSave(contact, this.state.journalUid, this.props.item);
} }
render() { render() {
@ -313,14 +313,14 @@ class ContactEdit extends React.PureComponent {
return ( return (
<React.Fragment> <React.Fragment>
<h2> <h2>
{this.props.contact ? 'Edit Contact' : 'New Contact'} {this.props.item ? 'Edit Contact' : 'New Contact'}
</h2> </h2>
<form style={styles.form} onSubmit={this.onSubmit}> <form style={styles.form} onSubmit={this.onSubmit}>
<SelectField <SelectField
style={styles.fullWidth} style={styles.fullWidth}
value={this.state.journalUid} value={this.state.journalUid}
floatingLabelText="Saving to" floatingLabelText="Saving to"
disabled={this.props.contact !== undefined} disabled={this.props.item !== undefined}
onChange={(contact: object, key: number, payload: any) => this.handleChange('journalUid', payload)} onChange={(contact: object, key: number, payload: any) => this.handleChange('journalUid', payload)}
> >
{this.props.collections.map((x) => ( {this.props.collections.map((x) => (

@ -31,7 +31,7 @@ class EventEdit extends React.PureComponent {
props: { props: {
collections: Array<EteSync.CollectionInfo>, collections: Array<EteSync.CollectionInfo>,
initialCollection?: string, initialCollection?: string,
event?: EventType, item?: EventType,
onSave: (event: EventType, journalUid: string, originalEvent?: EventType) => void; onSave: (event: EventType, journalUid: string, originalEvent?: EventType) => void;
}; };
@ -48,8 +48,8 @@ class EventEdit extends React.PureComponent {
journalUid: '', journalUid: '',
}; };
if (this.props.event !== undefined) { if (this.props.item !== undefined) {
const event = this.props.event; const event = this.props.item;
const allDay = event.startDate.isDate; const allDay = event.startDate.isDate;
let endDate = event.endDate.clone(); let endDate = event.endDate.clone();
@ -128,8 +128,8 @@ class EventEdit extends React.PureComponent {
endDate.adjust(1, 0, 0, 0); endDate.adjust(1, 0, 0, 0);
} }
let event = (this.props.event) ? let event = (this.props.item) ?
this.props.event.clone() this.props.item.clone()
: :
new EventType() new EventType()
; ;
@ -142,7 +142,7 @@ class EventEdit extends React.PureComponent {
event.component.updatePropertyWithValue('last-modified', ICAL.Time.now()); event.component.updatePropertyWithValue('last-modified', ICAL.Time.now());
this.props.onSave(event, this.state.journalUid, this.props.event); this.props.onSave(event, this.state.journalUid, this.props.item);
} }
render() { render() {
@ -162,7 +162,7 @@ class EventEdit extends React.PureComponent {
return ( return (
<React.Fragment> <React.Fragment>
<h2> <h2>
{this.props.event ? 'Edit Event' : 'New Event'} {this.props.item ? 'Edit Event' : 'New Event'}
</h2> </h2>
{this.state.error && ( {this.state.error && (
<div>ERROR! {this.state.error}</div> <div>ERROR! {this.state.error}</div>
@ -180,7 +180,7 @@ class EventEdit extends React.PureComponent {
style={styles.fullWidth} style={styles.fullWidth}
value={this.state.journalUid} value={this.state.journalUid}
floatingLabelText="Saving to" floatingLabelText="Saving to"
disabled={this.props.event !== undefined} disabled={this.props.item !== undefined}
onChange={(event: object, key: number, payload: any) => this.handleChange('journalUid', payload)} onChange={(event: object, key: number, payload: any) => this.handleChange('journalUid', payload)}
> >
{this.props.collections.map((x) => ( {this.props.collections.map((x) => (

Loading…
Cancel
Save