renamed notefull to notecomplement

This commit is contained in:
zadam
2020-02-01 11:15:58 +01:00
parent eeedb91ef7
commit f6f7836b8e
19 changed files with 49 additions and 51 deletions

View File

@@ -1,7 +1,9 @@
import utils from '../services/utils.js';
export default class Component {
/** @param {AppContext} appContext */
constructor(appContext) {
this.componentId = `component-${this.constructor.name}`;
this.componentId = `comp-${this.constructor.name}-` + utils.randomString(10);
this.appContext = appContext;
/** @type Component[] */
this.children = [];

View File

@@ -37,18 +37,17 @@ export default class NoteDetailWidget extends TabAwareWidget {
this.typeWidgetPromises = {};
this.spacedUpdate = new SpacedUpdate(async () => {
const {noteFull, note} = this.tabContext;
const {noteComplement, note} = this.tabContext;
const {noteId} = note;
// FIXME hack
const dto = note.dto;
dto.content = noteFull.content = this.getTypeWidget().getContent();
dto.content = noteComplement.content = this.getTypeWidget().getContent();
const resp = await server.put('notes/' + noteId, dto, this.componentId);
// FIXME: minor - does not propagate to other tab contexts with this note though
noteFull.dateModified = resp.dateModified;
noteFull.utcDateModified = resp.utcDateModified;
noteComplement.dateModified = resp.dateModified;
noteComplement.utcDateModified = resp.utcDateModified;
this.trigger('noteChangesSaved', {noteId})
});
@@ -161,7 +160,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
let type = note.type;
if (type === 'text' && !disableAutoBook
&& utils.isHtmlEmpty(this.tabContext.noteFull.content)
&& utils.isHtmlEmpty(this.tabContext.noteComplement.content)
&& note.hasChildren()) {
type = 'book';
@@ -223,9 +222,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
async entitiesReloadedListener({loadResults}) {
if (loadResults.isNoteContentReloaded(this.noteId, this.componentId)) {
this.tabContext.noteFull = await noteDetailService.loadNoteFull(this.noteId);
console.log("Reloaded", this.tabContext.noteFull);
this.tabContext.noteComplement = await noteDetailService.loadNoteComplement(this.noteId);
this.refreshWithNote(this.note, this.notePath);
}

View File

@@ -49,16 +49,16 @@ class NoteInfoWidget extends StandardWidget {
const $type = this.$body.find(".note-info-type");
const $mime = this.$body.find(".note-info-mime");
const {noteFull} = this.tabContext;
const {noteComplement} = this.tabContext;
$noteId.text(note.noteId);
$dateCreated
.text(noteFull.dateCreated)
.attr("title", noteFull.dateCreated);
.text(noteComplement.dateCreated)
.attr("title", noteComplement.dateCreated);
$dateModified
.text(noteFull.dateModified)
.attr("title", noteFull.dateCreated);
.text(noteComplement.dateModified)
.attr("title", noteComplement.dateCreated);
$type.text(note.type);

View File

@@ -75,7 +75,7 @@ export default class CodeTypeWidget extends TypeWidget {
this.spacedUpdate.allowUpdateWithoutChange(() => {
// CodeMirror breaks pretty badly on null so even though it shouldn't happen (guarded by consistency check)
// we provide fallback
this.codeEditor.setValue(this.tabContext.noteFull.content || "");
this.codeEditor.setValue(this.tabContext.noteComplement.content || "");
const info = CodeMirror.findModeByMIME(note.mime);

View File

@@ -128,9 +128,9 @@ export default class FileTypeWidget extends TypeWidget {
this.$fileSize.text(note.contentLength + " bytes");
this.$fileType.text(note.mime);
if (this.tabContext.noteFull.content) {
if (this.tabContext.noteComplement.content) {
this.$previewContent.show();
this.$previewContent.text(this.tabContext.noteFull.content);
this.$previewContent.text(this.tabContext.noteComplement.content);
}
else {
this.$previewContent.empty().hide();

View File

@@ -132,7 +132,7 @@ class NoteDetailImage extends TypeWidget {
this.$fileSize.text(note.contentLength + " bytes");
this.$fileType.text(note.mime);
const imageHash = this.tabContext.noteFull.utcDateModified.replace(" ", "_");
const imageHash = this.tabContext.noteComplement.utcDateModified.replace(" ", "_");
this.$imageView.prop("src", `api/images/${note.noteId}/${note.title}?${imageHash}`);
}

View File

@@ -254,9 +254,9 @@ export default class RelationMapTypeWidget extends TypeWidget {
}
};
if (this.tabContext.noteFull.content) {
if (this.tabContext.noteComplement.content) {
try {
this.mapData = JSON.parse(this.tabContext.noteFull.content);
this.mapData = JSON.parse(this.tabContext.noteComplement.content);
} catch (e) {
console.log("Could not parse content: ", e);
}

View File

@@ -45,7 +45,7 @@ export default class SearchTypeWidget extends TypeWidget {
this.$component.show();
try {
const json = JSON.parse(this.tabContext.noteFull.content);
const json = JSON.parse(this.tabContext.noteComplement.content);
this.$searchString.val(json.searchString);
}

View File

@@ -140,7 +140,7 @@ export default class TextTypeWidget extends TypeWidget {
this.textEditor.isReadOnly = await note.hasLabel('readOnly');
this.spacedUpdate.allowUpdateWithoutChange(() => {
this.textEditor.setData(this.tabContext.noteFull.content);
this.textEditor.setData(this.tabContext.noteComplement.content);
});
}