diff --git a/src/ContactEdit.tsx b/src/ContactEdit.tsx index 3a4ecc2..6e44dbb 100644 --- a/src/ContactEdit.tsx +++ b/src/ContactEdit.tsx @@ -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 { /> ))} + + + + + +