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[]; phone: ValueType[];
email: ValueType[]; email: ValueType[];
address: ValueType[]; address: ValueType[];
org: string;
note: string;
title: string;
journalUid: string; journalUid: string;
}; };
@ -122,6 +125,9 @@ class ContactEdit extends React.Component {
phone: [new ValueType()], phone: [new ValueType()],
email: [new ValueType()], email: [new ValueType()],
address: [new ValueType()], address: [new ValueType()],
org: '',
note: '',
title: '',
journalUid: '', journalUid: '',
}; };
@ -146,6 +152,15 @@ class ContactEdit extends React.Component {
this.state.email = propToValueType(contact.comp, 'email'); this.state.email = propToValueType(contact.comp, 'email');
this.state.address = propToValueType(contact.comp, 'adr'); 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 { } else {
this.state.uid = uuid.v4(); this.state.uid = uuid.v4();
} }
@ -253,6 +268,14 @@ class ContactEdit extends React.Component {
setProperties('email', this.state.email); setProperties('email', this.state.email);
setProperties('adr', this.state.address); 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); 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}> <div style={styles.submit}>
<RaisedButton <RaisedButton
type="submit" type="submit"

Loading…
Cancel
Save