mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-27 09:39:00 +01:00 
			
		
		
		
	fix relations in attributes
This commit is contained in:
		
							parent
							
								
									a55d3530e9
								
							
						
					
					
						commit
						49989695ff
					
				| @ -1,6 +1,8 @@ | |||||||
| import noteDetailService from '../services/note_detail.js'; | import noteDetailService from '../services/note_detail.js'; | ||||||
| import server from '../services/server.js'; | import server from '../services/server.js'; | ||||||
| import infoService from "../services/info.js"; | import infoService from "../services/info.js"; | ||||||
|  | import treeUtils from "../services/tree_utils.js"; | ||||||
|  | import linkService from "../services/link.js"; | ||||||
| 
 | 
 | ||||||
| const $dialog = $("#attributes-dialog"); | const $dialog = $("#attributes-dialog"); | ||||||
| const $saveAttributesButton = $("#save-attributes-button"); | const $saveAttributesButton = $("#save-attributes-button"); | ||||||
| @ -53,10 +55,10 @@ function AttributesModel() { | |||||||
|         }); |         }); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     function prepareAttributes(attributes) { |     async function showAttributes(attributes) { | ||||||
|         for (const attr of attributes) { |         for (const attr of attributes) { | ||||||
|             attr.labelValue = attr.type === 'label' ? attr.value : ''; |             attr.labelValue = attr.type === 'label' ? attr.value : ''; | ||||||
|             attr.relationValue = attr.type === 'relation' ? attr.value : ''; |             attr.relationValue = attr.type === 'relation' ? (await treeUtils.getNoteTitle(attr.value) + " (" + attr.value + ")") : ''; | ||||||
|             attr.labelDefinition = (attr.type === 'label-definition' && attr.value) ? attr.value : { |             attr.labelDefinition = (attr.type === 'label-definition' && attr.value) ? attr.value : { | ||||||
|                 labelType: "text", |                 labelType: "text", | ||||||
|                 multiplicityType: "singlevalue", |                 multiplicityType: "singlevalue", | ||||||
| @ -80,7 +82,7 @@ function AttributesModel() { | |||||||
| 
 | 
 | ||||||
|         const attributes = await server.get('notes/' + noteId + '/attributes'); |         const attributes = await server.get('notes/' + noteId + '/attributes'); | ||||||
| 
 | 
 | ||||||
|         prepareAttributes(attributes); |         await showAttributes(attributes); | ||||||
| 
 | 
 | ||||||
|         // attribute might not be rendered immediatelly so could not focus
 |         // attribute might not be rendered immediatelly so could not focus
 | ||||||
|         setTimeout(() => $(".attribute-name:last").focus(), 100); |         setTimeout(() => $(".attribute-name:last").focus(), 100); | ||||||
| @ -139,7 +141,7 @@ function AttributesModel() { | |||||||
|                 attr.value = attr.labelValue; |                 attr.value = attr.labelValue; | ||||||
|             } |             } | ||||||
|             else if (attr.type === 'relation') { |             else if (attr.type === 'relation') { | ||||||
|                 attr.value = attr.relationValue; |                 attr.value = treeUtils.getNoteIdFromNotePath(linkService.getNotePathFromLabel(attr.relationValue)); | ||||||
|             } |             } | ||||||
|             else if (attr.type === 'label-definition') { |             else if (attr.type === 'label-definition') { | ||||||
|                 attr.value = attr.labelDefinition; |                 attr.value = attr.labelDefinition; | ||||||
| @ -156,7 +158,7 @@ function AttributesModel() { | |||||||
| 
 | 
 | ||||||
|         const attributes = await server.put('notes/' + noteId + '/attributes', attributesToSave); |         const attributes = await server.put('notes/' + noteId + '/attributes', attributesToSave); | ||||||
| 
 | 
 | ||||||
|         prepareAttributes(attributes); |         await showAttributes(attributes); | ||||||
| 
 | 
 | ||||||
|         infoService.showMessage("Attributes have been saved."); |         infoService.showMessage("Attributes have been saved."); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ import utils from "./utils.js"; | |||||||
| import Branch from "../entities/branch.js"; | import Branch from "../entities/branch.js"; | ||||||
| import NoteShort from "../entities/note_short.js"; | import NoteShort from "../entities/note_short.js"; | ||||||
| import infoService from "./info.js"; | import infoService from "./info.js"; | ||||||
|  | import messagingService from "./messaging.js"; | ||||||
| import server from "./server.js"; | import server from "./server.js"; | ||||||
| 
 | 
 | ||||||
| class TreeCache { | class TreeCache { | ||||||
| @ -48,7 +49,9 @@ class TreeCache { | |||||||
| 
 | 
 | ||||||
|         return noteIds.map(noteId => { |         return noteIds.map(noteId => { | ||||||
|             if (!this.notes[noteId]) { |             if (!this.notes[noteId]) { | ||||||
|                 throw new Error(`Can't find note ${noteId}`); |                 messagingService.logError(`Can't find note ${noteId}`); | ||||||
|  | 
 | ||||||
|  |                 return `[unknown ${noteId}]`; | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 return this.notes[noteId]; |                 return this.notes[noteId]; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 azivner
						azivner