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

6
package-lock.json generated
View file

@ -7268,9 +7268,9 @@
"integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k="
},
"open": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/open/-/open-7.0.1.tgz",
"integrity": "sha512-/fVm742AZt6bZ3NpbmBzGpZksDiGbo+xz8RylegKSAnTCgT5u5tvJe0cre3QxICphqHhJHc0OFtFyvU7rNx8+Q==",
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/open/-/open-7.0.2.tgz",
"integrity": "sha512-70E/pFTPr7nZ9nLDPNTcj3IVqnNvKuP4VsBmoKV9YGTnChe0mlS3C4qM7qKarhZ8rGaHKLfo+vBTHXDp6ZSyLQ==",
"requires": {
"is-docker": "^2.0.0",
"is-wsl": "^2.1.1"

View file

@ -54,7 +54,7 @@
"mime-types": "2.1.26",
"multer": "1.4.2",
"node-abi": "2.13.0",
"open": "7.0.1",
"open": "7.0.2",
"pngjs": "3.4.0",
"portscanner": "2.2.0",
"rand-token": "0.4.0",

View file

@ -16,11 +16,11 @@ export function showDialog() {
$dialog.modal();
const {note, noteFull} = appContext.getActiveTabContext();
const {note, noteComplement} = appContext.getActiveTabContext();
$noteId.text(note.noteId);
$dateCreated.text(noteFull.dateCreated);
$dateModified.text(noteFull.dateModified);
$dateCreated.text(noteComplement.dateCreated);
$dateModified.text(noteComplement.dateModified);
$type.text(note.type);
$mime.text(note.mime);
}

View file

@ -1,10 +1,11 @@
import NoteShort from './note_short.js';
/**
* Represents full note, specifically including note's content.
* Complements the NoteShort with the main note content and other extra attributes
*/
class NoteFull {
class NoteComplement {
constructor(row) {
/** @param {string} */
this.noteId = row.noteId;
/** @param {string} */
this.content = row.content;
@ -22,4 +23,4 @@ class NoteFull {
}
}
export default NoteFull;
export default NoteComplement;

View file

@ -171,7 +171,7 @@ class AppContext {
return activeContext ? activeContext.notePath : null;
}
/** @return {NoteFull} */
/** @return {NoteShort} */
getActiveTabNote() {
const activeContext = this.getActiveTabContext();
return activeContext ? activeContext.note : null;

View file

@ -289,7 +289,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
/**
* @method
* @returns {NoteFull} active note (loaded into right pane)
* @returns {NoteShort} active note (loaded into right pane)
*/
this.getActiveTabNote = appContext.getActiveTabNote;

View file

@ -1,7 +1,7 @@
import server from './server.js';
import ws from "./ws.js";
import treeCache from "./tree_cache.js";
import NoteFull from "../entities/note_full.js";
import NoteComplement from "../entities/note_full.js";
import appContext from "./app_context.js";
function getActiveEditor() {
@ -15,10 +15,10 @@ function getActiveEditor() {
}
}
async function loadNoteFull(noteId) {
async function loadNoteComplement(noteId) {
const row = await server.get('notes/' + noteId);
return new NoteFull(row);
return new NoteComplement(row);
}
function focusOnTitle() {
@ -45,7 +45,7 @@ $(window).on('beforeunload', () => {
});
export default {
loadNoteFull,
loadNoteComplement,
focusOnTitle,
focusAndSelectTitle,
getActiveEditor,

View file

@ -44,9 +44,9 @@ async function mouseEnterHandler() {
const noteId = treeService.getNoteIdFromNotePath(notePath);
const note = await treeCache.getNote(noteId);
const noteFull = await noteDetailService.loadNoteFull(noteId);
const noteComplement = await noteDetailService.loadNoteComplement(noteId);
const html = await renderTooltip(note, noteFull);
const html = await renderTooltip(note, noteComplement);
// we need to check if we're still hovering over the element
// since the operation to get tooltip content was async, it is possible that
@ -71,7 +71,7 @@ function mouseLeaveHandler() {
$(this).tooltip('dispose');
}
async function renderTooltip(note, noteFull) {
async function renderTooltip(note, noteComplement) {
const attributes = await note.getAttributes();
let content = '';
@ -117,11 +117,11 @@ async function renderTooltip(note, noteFull) {
if (note.type === 'text') {
// surround with <div> for a case when note's content is pure text (e.g. "[protected]") which
// then fails the jquery non-empty text test
content += '<div>' + noteFull.content + '</div>';
content += '<div>' + noteComplement.content + '</div>';
}
else if (note.type === 'code') {
content += $("<pre>")
.text(noteFull.content)
.text(noteComplement.content)
.prop('outerHTML');
}
else if (note.type === 'image') {

View file

@ -51,8 +51,8 @@ class TabContext extends Component {
/** @property {NoteShort} */
this.note = await treeCache.getNote(noteId);
/** @property {NoteFull} */
this.noteFull = await noteDetailService.loadNoteFull(noteId);
/** @property {NoteComplement} */
this.noteComplement = await noteDetailService.loadNoteComplement(noteId);
//this.cleanup(); // esp. on windows autocomplete is not getting closed automatically

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);
});
}

View file

@ -1,5 +1,3 @@
import * as syncService from "../services/sync.js";
const setupRoute = require('./setup');
const loginRoute = require('./login');
const indexRoute = require('./index');
@ -46,7 +44,7 @@ const auth = require('../services/auth');
const cls = require('../services/cls');
const sql = require('../services/sql');
const protectedSessionService = require('../services/protected_session');
const syncTableService = require('../services/sync_table');
const syncService = require('../services/sync');
const csurf = require('csurf');
const csrfMiddleware = csurf({