mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	cssClass is correctly filled for new note
This commit is contained in:
		| @@ -99,23 +99,37 @@ class Note extends Entity { | |||||||
|         return await repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]); |         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) { |         if (!this.__attributeCache) { | ||||||
|             await this.loadAttributesToCache(); |             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() { |      * @param {string} [name] - label name to filter | ||||||
|         return (await this.getAttributes()).filter(attr => attr.type === LABEL); |      * @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() { |      * @param {string} [name] - relation name to filter | ||||||
|         return (await this.getAttributes()).filter(attr => attr.type === RELATION); |      * @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'); |         $protectedSessionOnButton.addClass('active'); | ||||||
|         $protectedSessionOffButton.removeClass('active'); |         $protectedSessionOffButton.removeClass('active'); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     infoService.showMessage("Protected session has been started."); | ||||||
| } | } | ||||||
|  |  | ||||||
| function ensureDialogIsClosed() { | function ensureDialogIsClosed() { | ||||||
|   | |||||||
| @@ -26,6 +26,8 @@ async function createNote(req) { | |||||||
|  |  | ||||||
|     const { note, branch } = await noteService.createNewNote(parentNoteId, newNote, req); |     const { note, branch } = await noteService.createNewNote(parentNoteId, newNote, req); | ||||||
|  |  | ||||||
|  |     note.cssClass = (await note.getLabels("cssClass")).map(label => label.value).join(" "); | ||||||
|  |  | ||||||
|     return { |     return { | ||||||
|         note, |         note, | ||||||
|         branch |         branch | ||||||
|   | |||||||
| @@ -81,6 +81,8 @@ async function createNewNote(parentNoteId, noteData) { | |||||||
|                position: attr.position, |                position: attr.position, | ||||||
|                isInheritable: attr.isInheritable |                isInheritable: attr.isInheritable | ||||||
|             }).save(); |             }).save(); | ||||||
|  |  | ||||||
|  |             note.invalidateAttributeCache(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user