Add a few more contact fields.

master
Tom Hacohen 7 years ago
parent 1524600e4b
commit 29ffb5a74b

@ -103,6 +103,9 @@ class ContactEdit extends React.Component {
phone: ValueType[];
email: ValueType[];
address: ValueType[];
org: string;
note: string;
title: string;
journalUid: string;
};
@ -122,6 +125,9 @@ class ContactEdit extends React.Component {
phone: [new ValueType()],
email: [new ValueType()],
address: [new ValueType()],
org: '',
note: '',
title: '',
journalUid: '',
};
@ -146,6 +152,15 @@ class ContactEdit extends React.Component {
this.state.email = propToValueType(contact.comp, 'email');
this.state.address = propToValueType(contact.comp, 'adr');
const propToStringType = (comp: ICAL.Component, propName: string) => {
const val = comp.getFirstPropertyValue(propName);
return val ? val : '';
};
this.state.org = propToStringType(contact.comp, 'org');
this.state.title = propToStringType(contact.comp, 'title');
this.state.note = propToStringType(contact.comp, 'note');
} else {
this.state.uid = uuid.v4();
}
@ -253,6 +268,14 @@ class ContactEdit extends React.Component {
setProperties('email', this.state.email);
setProperties('adr', this.state.address);
function setProperty(name: string, value: string) {
comp.updatePropertyWithValue(name, value);
}
setProperty('org', this.state.org);
setProperty('title', this.state.title);
setProperty('note', this.state.note);
this.props.onSave(contact, this.state.journalUid, this.props.contact);
}
@ -365,6 +388,31 @@ class ContactEdit extends React.Component {
/>
))}
<TextField
name="org"
hintText="Organization"
style={styles.fullWidth}
value={this.state.org}
onChange={this.handleInputChange}
/>
<TextField
name="title"
hintText="Title"
style={styles.fullWidth}
value={this.state.title}
onChange={this.handleInputChange}
/>
<TextField
name="note"
multiLine={true}
hintText="Note"
style={styles.fullWidth}
value={this.state.note}
onChange={this.handleInputChange}
/>
<div style={styles.submit}>
<RaisedButton
type="submit"

Loading…
Cancel
Save