|
|
@ -30,6 +30,12 @@ const addressTypes = [
|
|
|
|
{type: 'Other'},
|
|
|
|
{type: 'Other'},
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const imppTypes = [
|
|
|
|
|
|
|
|
{type: 'Jabber'},
|
|
|
|
|
|
|
|
{type: 'Hangouts'},
|
|
|
|
|
|
|
|
{type: 'Other'},
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
const TypeSelector = (props: any) => {
|
|
|
|
const TypeSelector = (props: any) => {
|
|
|
|
const types = props.types as {type: string}[];
|
|
|
|
const types = props.types as {type: string}[];
|
|
|
|
|
|
|
|
|
|
|
@ -103,6 +109,7 @@ class ContactEdit extends React.Component {
|
|
|
|
phone: ValueType[];
|
|
|
|
phone: ValueType[];
|
|
|
|
email: ValueType[];
|
|
|
|
email: ValueType[];
|
|
|
|
address: ValueType[];
|
|
|
|
address: ValueType[];
|
|
|
|
|
|
|
|
impp: ValueType[];
|
|
|
|
org: string;
|
|
|
|
org: string;
|
|
|
|
note: string;
|
|
|
|
note: string;
|
|
|
|
title: string;
|
|
|
|
title: string;
|
|
|
@ -125,6 +132,7 @@ class ContactEdit extends React.Component {
|
|
|
|
phone: [new ValueType()],
|
|
|
|
phone: [new ValueType()],
|
|
|
|
email: [new ValueType()],
|
|
|
|
email: [new ValueType()],
|
|
|
|
address: [new ValueType()],
|
|
|
|
address: [new ValueType()],
|
|
|
|
|
|
|
|
impp: [new ValueType()],
|
|
|
|
org: '',
|
|
|
|
org: '',
|
|
|
|
note: '',
|
|
|
|
note: '',
|
|
|
|
title: '',
|
|
|
|
title: '',
|
|
|
@ -151,6 +159,7 @@ class ContactEdit extends React.Component {
|
|
|
|
this.state.phone = propToValueType(contact.comp, 'tel');
|
|
|
|
this.state.phone = propToValueType(contact.comp, 'tel');
|
|
|
|
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');
|
|
|
|
|
|
|
|
this.state.impp = propToValueType(contact.comp, 'impp');
|
|
|
|
|
|
|
|
|
|
|
|
const propToStringType = (comp: ICAL.Component, propName: string) => {
|
|
|
|
const propToStringType = (comp: ICAL.Component, propName: string) => {
|
|
|
|
const val = comp.getFirstPropertyValue(propName);
|
|
|
|
const val = comp.getFirstPropertyValue(propName);
|
|
|
@ -189,10 +198,11 @@ class ContactEdit extends React.Component {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
addValueType(name: string) {
|
|
|
|
addValueType(name: string, _type?: string) {
|
|
|
|
|
|
|
|
const type = _type ? _type : 'home';
|
|
|
|
this.setState((prevState, props) => {
|
|
|
|
this.setState((prevState, props) => {
|
|
|
|
let newArray = prevState[name].slice(0);
|
|
|
|
let newArray = prevState[name].slice(0);
|
|
|
|
newArray.push(new ValueType());
|
|
|
|
newArray.push(new ValueType(type));
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
...prevState,
|
|
|
|
...prevState,
|
|
|
|
[name]: newArray,
|
|
|
|
[name]: newArray,
|
|
|
@ -267,6 +277,9 @@ class ContactEdit extends React.Component {
|
|
|
|
setProperties('tel', this.state.phone);
|
|
|
|
setProperties('tel', this.state.phone);
|
|
|
|
setProperties('email', this.state.email);
|
|
|
|
setProperties('email', this.state.email);
|
|
|
|
setProperties('adr', this.state.address);
|
|
|
|
setProperties('adr', this.state.address);
|
|
|
|
|
|
|
|
setProperties('impp', this.state.impp.map((x) => (
|
|
|
|
|
|
|
|
{type: x.type, value: x.type + ':' + x.value}
|
|
|
|
|
|
|
|
)));
|
|
|
|
|
|
|
|
|
|
|
|
function setProperty(name: string, value: string) {
|
|
|
|
function setProperty(name: string, value: string) {
|
|
|
|
comp.updatePropertyWithValue(name, value);
|
|
|
|
comp.updatePropertyWithValue(name, value);
|
|
|
@ -365,6 +378,29 @@ class ContactEdit extends React.Component {
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
IMPP
|
|
|
|
|
|
|
|
<IconButton
|
|
|
|
|
|
|
|
onClick={() => this.addValueType('impp', 'jabber')}
|
|
|
|
|
|
|
|
tooltip="Add impp address"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<IconAdd />
|
|
|
|
|
|
|
|
</IconButton>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{this.state.impp.map((x, idx) => (
|
|
|
|
|
|
|
|
<ValueTypeComponent
|
|
|
|
|
|
|
|
key={idx}
|
|
|
|
|
|
|
|
name="impp"
|
|
|
|
|
|
|
|
hintText="IMPP"
|
|
|
|
|
|
|
|
types={imppTypes}
|
|
|
|
|
|
|
|
value={this.state.impp[idx]}
|
|
|
|
|
|
|
|
onClearRequest={(name: string) => this.removeValueType(name, idx)}
|
|
|
|
|
|
|
|
onChange={(name: string, type: string, value: string) => (
|
|
|
|
|
|
|
|
this.handleValueTypeChange(name, idx, {type, value})
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
Addresses
|
|
|
|
Addresses
|
|
|
|
<IconButton
|
|
|
|
<IconButton
|
|
|
@ -378,7 +414,7 @@ class ContactEdit extends React.Component {
|
|
|
|
<ValueTypeComponent
|
|
|
|
<ValueTypeComponent
|
|
|
|
key={idx}
|
|
|
|
key={idx}
|
|
|
|
name="address"
|
|
|
|
name="address"
|
|
|
|
hintText="Email"
|
|
|
|
hintText="Address"
|
|
|
|
types={addressTypes}
|
|
|
|
types={addressTypes}
|
|
|
|
value={this.state.address[idx]}
|
|
|
|
value={this.state.address[idx]}
|
|
|
|
onClearRequest={(name: string) => this.removeValueType(name, idx)}
|
|
|
|
onClearRequest={(name: string) => this.removeValueType(name, idx)}
|
|
|
|