onKeyDown(event, key),
style: styles.input,
}}
onChange={momentObject => {
this.setState({ editedValue: momentObject });
}}
/>
);
editCompHandler = () => {
this.saveProperty();
};
editCompIcon = 'fa-save';
} else {
controlComp = (
{
this.setState({ editedValue: event.target.value });
}}
onKeyDown={event => onKeyDown(event)}
style={styles.input}
/>
);
}
} else {
let displayedValue = value;
if (key === 'location') {
try {
const dms = formatcoords(value);
displayedValue = dms.format('DD MM ss X', { latLonSeparator: ', ', decimalPlaces: 2 });
} catch (error) {
displayedValue = '';
}
}
if (['source_url', 'location'].indexOf(key) >= 0) {
let url = '';
if (key === 'source_url') url = value;
if (key === 'location') {
const ll = this.latLongFromLocation(value);
url = Note.geoLocationUrlFromLatLong(ll.latitude, ll.longitude);
}
const urlStyle = Object.assign({}, theme.urlStyle, { maxWidth: '180px', overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis' });
controlComp = (
bridge().openExternal(url)} style={urlStyle}>
{displayedValue}
);
} else if (key === 'revisionsLink') {
controlComp = (
{_('Previous versions of this note')}
);
} else {
controlComp = {displayedValue}
;
}
if (['id', 'revisionsLink', 'markup_language'].indexOf(key) < 0) {
editCompHandler = () => {
this.editPropertyButtonClick(key, value);
};
editCompIcon = 'fa-edit';
}
}
if (editCompHandler) {
editComp = (
);
}
return (
{labelComp}
{controlComp}
{editComp}
);
}
formatLabel(key) {
if (this.keyToLabel_[key]) return this.keyToLabel_[key];
return key;
}
formatValue(key, note) {
if (key === 'location') {
if (!Number(note.latitude) && !Number(note.longitude)) return null;
const dms = formatcoords(Number(note.latitude), Number(note.longitude));
return dms.format('DDMMss', { decimalPlaces: 0 });
}
if (['user_updated_time', 'user_created_time', 'todo_completed'].indexOf(key) >= 0) {
return time.formatMsToLocal(note[key]);
}
return note[key];
}
render() {
const theme = themeStyle(this.props.theme);
const formNote = this.state.formNote;
const noteComps = [];
if (formNote) {
for (const key in formNote) {
if (!formNote.hasOwnProperty(key)) continue;
const comp = this.createNoteField(key, formNote[key]);
noteComps.push(comp);
}
}
return (
{_('Note properties')}
{noteComps}
);
}
}
module.exports = NotePropertiesDialog;