Add a cancel button when editing contacts and events.

Fixes #2.
master
Tom Hacohen 7 years ago
parent 73ab88d3d2
commit 84a0bf2a8e

@ -102,6 +102,7 @@ const CollectionRoutes = withRouter(
componentView: any, componentView: any,
items: {[key: string]: any}, items: {[key: string]: any},
onItemSave: (item: Object, journalUid: string, originalContact?: Object) => void; onItemSave: (item: Object, journalUid: string, originalContact?: Object) => void;
onItemCancel: () => void;
}; };
render() { render() {
@ -130,6 +131,7 @@ const CollectionRoutes = withRouter(
item={props.items[match.params.itemUid]} item={props.items[match.params.itemUid]}
collections={props.collections} collections={props.collections}
onSave={props.onItemSave} onSave={props.onItemSave}
onCancel={props.onItemCancel}
/> />
</Container> </Container>
)} )}
@ -197,6 +199,7 @@ class Pim extends React.PureComponent {
super(props); super(props);
this.onEventSave = this.onEventSave.bind(this); this.onEventSave = this.onEventSave.bind(this);
this.onContactSave = this.onContactSave.bind(this); this.onContactSave = this.onContactSave.bind(this);
this.onCancel = this.onCancel.bind(this);
} }
onEventSave(event: EventType, journalUid: string, originalEvent?: EventType) { onEventSave(event: EventType, journalUid: string, originalEvent?: EventType) {
@ -233,6 +236,10 @@ class Pim extends React.PureComponent {
}); });
} }
onCancel() {
this.props.history.goBack();
}
render() { render() {
const { collectionsAddressBook, collectionsCalendar, addressBookItems, calendarItems } = itemsSelector(this.props); const { collectionsAddressBook, collectionsCalendar, addressBookItems, calendarItems } = itemsSelector(this.props);
@ -260,6 +267,7 @@ class Pim extends React.PureComponent {
componentEdit={ContactEdit} componentEdit={ContactEdit}
componentView={Contact} componentView={Contact}
onItemSave={this.onContactSave} onItemSave={this.onContactSave}
onItemCancel={this.onCancel}
/> />
)} )}
/> />
@ -274,6 +282,7 @@ class Pim extends React.PureComponent {
componentEdit={EventEdit} componentEdit={EventEdit}
componentView={Event} componentView={Event}
onItemSave={this.onEventSave} onItemSave={this.onEventSave}
onItemCancel={this.onCancel}
/> />
)} )}
/> />

@ -122,6 +122,7 @@ class ContactEdit extends React.PureComponent {
initialCollection?: string, initialCollection?: string,
item?: ContactType, item?: ContactType,
onSave: (contact: ContactType, journalUid: string, originalContact?: ContactType) => void; onSave: (contact: ContactType, journalUid: string, originalContact?: ContactType) => void;
onCancel: () => void;
}; };
constructor(props: any) { constructor(props: any) {
@ -306,6 +307,7 @@ class ContactEdit extends React.PureComponent {
}, },
submit: { submit: {
marginTop: 40, marginTop: 40,
marginBottom: 20,
textAlign: 'right', textAlign: 'right',
}, },
}; };
@ -454,10 +456,16 @@ class ContactEdit extends React.PureComponent {
/> />
<div style={styles.submit}> <div style={styles.submit}>
<RaisedButton
label="Cancel"
onClick={this.props.onCancel}
/>
<RaisedButton <RaisedButton
type="submit" type="submit"
label="Save" label="Save"
secondary={true} secondary={true}
style={{marginLeft: 15}}
/> />
</div> </div>

@ -33,6 +33,7 @@ class EventEdit extends React.PureComponent {
initialCollection?: string, initialCollection?: string,
item?: EventType, item?: EventType,
onSave: (event: EventType, journalUid: string, originalEvent?: EventType) => void; onSave: (event: EventType, journalUid: string, originalEvent?: EventType) => void;
onCancel: () => void;
}; };
constructor(props: any) { constructor(props: any) {
@ -155,6 +156,7 @@ class EventEdit extends React.PureComponent {
}, },
submit: { submit: {
marginTop: 40, marginTop: 40,
marginBottom: 20,
textAlign: 'right', textAlign: 'right',
}, },
}; };
@ -229,10 +231,16 @@ class EventEdit extends React.PureComponent {
/> />
<div style={styles.submit}> <div style={styles.submit}>
<RaisedButton
label="Cancel"
onClick={this.props.onCancel}
/>
<RaisedButton <RaisedButton
type="submit" type="submit"
label="Save" label="Save"
secondary={true} secondary={true}
style={{marginLeft: 15}}
/> />
</div> </div>

Loading…
Cancel
Save