From 29ffb5a74bc4ca7960e1555b00e3220d87242451 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 13 Dec 2017 15:01:58 +0000 Subject: [PATCH] Add a few more contact fields. --- src/ContactEdit.tsx | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) 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 { /> ))} + + + + + +