mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	allow showing inherited attributes in the sidebar as well
This commit is contained in:
		
							parent
							
								
									c0c36d10e5
								
							
						
					
					
						commit
						7bee93bb73
					
				| @ -32,31 +32,57 @@ class AttributesWidget { | |||||||
|         const ownedAttributes = attributes.filter(attr => attr.noteId === this.ctx.note.noteId); |         const ownedAttributes = attributes.filter(attr => attr.noteId === this.ctx.note.noteId); | ||||||
| 
 | 
 | ||||||
|         if (ownedAttributes.length === 0) { |         if (ownedAttributes.length === 0) { | ||||||
|             $body.text("No attributes yet..."); |             $body.text("No own attributes yet..."); | ||||||
|             return; |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (ownedAttributes.length > 0) { |         await this.renderAttributes(ownedAttributes, $body); | ||||||
|             for (const attribute of ownedAttributes) { | 
 | ||||||
|                 if (attribute.type === 'label') { |         const inheritedAttributes = attributes.filter(attr => attr.noteId !== this.ctx.note.noteId); | ||||||
|                     $body.append(utils.formatLabel(attribute) + " "); | 
 | ||||||
|                 } |         if (inheritedAttributes.length > 0) { | ||||||
|                 else if (attribute.type === 'relation') { |             const $inheritedAttrs = $("<span>").append($("<strong>").text("Inherited: ")); | ||||||
|                     if (attribute.value) { |             const $showInheritedAttributes = $("<a>") | ||||||
|                         $body.append('@' + attribute.name + "="); |                 .attr("href", "javascript:") | ||||||
|                         $body.append(await linkService.createNoteLink(attribute.value)); |                 .text("+show inherited") | ||||||
|                         $body.append(" "); |                 .click(() => { | ||||||
|                     } |                     $showInheritedAttributes.hide(); | ||||||
|                     else { |                     $inheritedAttrs.show(); | ||||||
|                         messagingService.logError(`Relation ${attribute.attributeId} has empty target`); |                 }); | ||||||
|                     } | 
 | ||||||
|                 } |             const $hideInheritedAttributes = $("<a>") | ||||||
|                 else if (attribute.type === 'label-definition' || attribute.type === 'relation-definition') { |                 .attr("href", "javascript:") | ||||||
|                     $body.append(attribute.name + " definition "); |                 .text("-hide inherited") | ||||||
|                 } |                 .click(() => { | ||||||
|                 else { |                     $showInheritedAttributes.show(); | ||||||
|                     messagingService.logError("Unknown attr type: " + attribute.type); |                     $inheritedAttrs.hide(); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             $body.append($showInheritedAttributes); | ||||||
|  |             $body.append($inheritedAttrs); | ||||||
|  | 
 | ||||||
|  |             await this.renderAttributes(inheritedAttributes, $inheritedAttrs); | ||||||
|  | 
 | ||||||
|  |             $inheritedAttrs.append($hideInheritedAttributes); | ||||||
|  |             $inheritedAttrs.hide(); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     async renderAttributes(attributes, $container) { | ||||||
|  |         for (const attribute of attributes) { | ||||||
|  |             if (attribute.type === 'label') { | ||||||
|  |                 $container.append(utils.formatLabel(attribute) + " "); | ||||||
|  |             } else if (attribute.type === 'relation') { | ||||||
|  |                 if (attribute.value) { | ||||||
|  |                     $container.append('@' + attribute.name + "="); | ||||||
|  |                     $container.append(await linkService.createNoteLink(attribute.value)); | ||||||
|  |                     $container.append(" "); | ||||||
|  |                 } else { | ||||||
|  |                     messagingService.logError(`Relation ${attribute.attributeId} has empty target`); | ||||||
|                 } |                 } | ||||||
|  |             } else if (attribute.type === 'label-definition' || attribute.type === 'relation-definition') { | ||||||
|  |                 $container.append(attribute.name + " definition "); | ||||||
|  |             } else { | ||||||
|  |                 messagingService.logError("Unknown attr type: " + attribute.type); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam