1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Strip down metadata being displayed in UI

This commit is contained in:
Laurent Cozic 2017-10-24 21:35:02 +01:00
parent fed256753c
commit 528f1b0430
2 changed files with 29 additions and 1 deletions

View File

@ -27,7 +27,7 @@ class NoteMetadataWidget extends TextWidget {
if (!this.note_ && this.noteId_) { if (!this.note_ && this.noteId_) {
this.note_ = await Note.load(this.noteId_); this.note_ = await Note.load(this.noteId_);
this.text = this.note_ ? await Note.serializeAllProps(this.note_) : ''; this.text = this.note_ ? await Note.minimalSerializeForDisplay(this.note_) : '';
} }
} }

View File

@ -41,6 +41,34 @@ class Note extends BaseItem {
return super.serialize(note, 'note', fieldNames); return super.serialize(note, 'note', fieldNames);
} }
static minimalSerializeForDisplay(note) {
let n = Object.assign({}, note);
let fieldNames = this.fieldNames();
if (!n.is_conflict) lodash.pull(fieldNames, 'is_conflict');
if (!Number(n.latitude)) lodash.pull(fieldNames, 'latitude');
if (!Number(n.longitude)) lodash.pull(fieldNames, 'longitude');
if (!Number(n.altitude)) lodash.pull(fieldNames, 'altitude');
if (!n.author) lodash.pull(fieldNames, 'author');
if (!n.source_url) lodash.pull(fieldNames, 'source_url');
if (!n.is_todo) {
lodash.pull(fieldNames, 'is_todo');
lodash.pull(fieldNames, 'todo_due');
lodash.pull(fieldNames, 'todo_completed');
}
if (!n.application_data) lodash.pull(fieldNames, 'application_data');
lodash.pull(fieldNames, 'type_');
lodash.pull(fieldNames, 'title');
lodash.pull(fieldNames, 'body');
lodash.pull(fieldNames, 'created_time');
lodash.pull(fieldNames, 'updated_time');
lodash.pull(fieldNames, 'order');
return super.serialize(n, 'note', fieldNames);
}
static defaultTitle(note) { static defaultTitle(note) {
if (note.title && note.title.length) return note.title; if (note.title && note.title.length) return note.title;