Improve contact properties conversion.

master
Tom Hacohen 7 years ago
parent 5f2d499cc1
commit b3420bbc24

@ -32,18 +32,18 @@ class Contact extends React.Component {
function getAllType( function getAllType(
propName: string, propName: string,
props: any, props: any,
valueToHref?: (value: string) => string, valueToHref?: (value: string, type: string) => string,
primaryTransform?: (value: string) => string, primaryTransform?: (value: string, type: string) => string,
secondaryTransform?: (value: string) => string) { secondaryTransform?: (value: string, type: string) => string) {
return contact.comp.getAllProperties(propName).map((prop, idx) => { return contact.comp.getAllProperties(propName).map((prop, idx) => {
const json = prop.toJSON(); const type = prop.toJSON()[1].type;
const values = prop.getValues().map((val) => ( const values = prop.getValues().map((val) => (
<ListItem <ListItem
key={idx} key={idx}
href={valueToHref ? valueToHref(val) : undefined} href={valueToHref ? valueToHref(val, type) : undefined}
primaryText={primaryTransform ? primaryTransform(val) : val} primaryText={primaryTransform ? primaryTransform(val, type) : val}
secondaryText={json[1].type} secondaryText={secondaryTransform ? secondaryTransform(val, type) : type}
{...props} {...props}
/> />
)); ));
@ -75,6 +75,7 @@ class Contact extends React.Component {
}, },
(x) => x, (x) => x,
(x) => (x.substring(x.indexOf(':') + 1)), (x) => (x.substring(x.indexOf(':') + 1)),
(x) => (x.substring(0, x.indexOf(':'))),
)); ));
lists.push(getAllType( lists.push(getAllType(
@ -91,6 +92,7 @@ class Contact extends React.Component {
}, },
undefined, undefined,
((x) => moment(x).format('dddd, LL')), ((x) => moment(x).format('dddd, LL')),
() => 'Birthday',
)); ));
const skips = ['tel', 'email', 'impp', 'adr', 'bday', 'prodid', 'uid', 'fn', 'n', 'version', 'photo']; const skips = ['tel', 'email', 'impp', 'adr', 'bday', 'prodid', 'uid', 'fn', 'n', 'version', 'photo'];

Loading…
Cancel
Save