mirror of
https://github.com/zadam/trilium.git
synced 2025-06-05 17:38:47 +02:00
cssClass is correctly filled for new note
This commit is contained in:
parent
bc38172792
commit
792039227f
@ -99,23 +99,37 @@ class Note extends Entity {
|
||||
return await repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]);
|
||||
}
|
||||
|
||||
/** @returns {Promise<Attribute[]>} all note's attributes, including inherited ones */
|
||||
async getAttributes() {
|
||||
/**
|
||||
* @param {string} [name] - attribute name to filter
|
||||
* @returns {Promise<Attribute[]>} all note's attributes, including inherited ones
|
||||
*/
|
||||
async getAttributes(name) {
|
||||
if (!this.__attributeCache) {
|
||||
await this.loadAttributesToCache();
|
||||
}
|
||||
|
||||
return this.__attributeCache;
|
||||
if (name) {
|
||||
return this.__attributeCache.filter(attr => attr.name === name);
|
||||
}
|
||||
else {
|
||||
return this.__attributeCache;
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {Promise<Attribute[]>} all note's labels (attributes with type label), including inherited ones */
|
||||
async getLabels() {
|
||||
return (await this.getAttributes()).filter(attr => attr.type === LABEL);
|
||||
/**
|
||||
* @param {string} [name] - label name to filter
|
||||
* @returns {Promise<Attribute[]>} all note's labels (attributes with type label), including inherited ones
|
||||
*/
|
||||
async getLabels(name) {
|
||||
return (await this.getAttributes(name)).filter(attr => attr.type === LABEL);
|
||||
}
|
||||
|
||||
/** @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), including inherited ones */
|
||||
async getRelations() {
|
||||
return (await this.getAttributes()).filter(attr => attr.type === RELATION);
|
||||
/**
|
||||
* @param {string} [name] - relation name to filter
|
||||
* @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), including inherited ones
|
||||
*/
|
||||
async getRelations(name) {
|
||||
return (await this.getAttributes(name)).filter(attr => attr.type === RELATION);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,6 +89,8 @@ async function setupProtectedSession() {
|
||||
$protectedSessionOnButton.addClass('active');
|
||||
$protectedSessionOffButton.removeClass('active');
|
||||
}
|
||||
|
||||
infoService.showMessage("Protected session has been started.");
|
||||
}
|
||||
|
||||
function ensureDialogIsClosed() {
|
||||
|
@ -26,6 +26,8 @@ async function createNote(req) {
|
||||
|
||||
const { note, branch } = await noteService.createNewNote(parentNoteId, newNote, req);
|
||||
|
||||
note.cssClass = (await note.getLabels("cssClass")).map(label => label.value).join(" ");
|
||||
|
||||
return {
|
||||
note,
|
||||
branch
|
||||
|
@ -81,6 +81,8 @@ async function createNewNote(parentNoteId, noteData) {
|
||||
position: attr.position,
|
||||
isInheritable: attr.isInheritable
|
||||
}).save();
|
||||
|
||||
note.invalidateAttributeCache();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user