mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 11:39:01 +01:00 
			
		
		
		
	server-ts: Port share/shaca/sbranch
This commit is contained in:
		
							parent
							
								
									e1d74cd2f5
								
							
						
					
					
						commit
						0865e90cae
					
				| @ -1,22 +1,27 @@ | ||||
| "use strict"; | ||||
| 
 | ||||
| const AbstractShacaEntity = require('./abstract_shaca_entity'); | ||||
| import AbstractShacaEntity = require('./abstract_shaca_entity'); | ||||
| import SNote = require('./snote'); | ||||
| 
 | ||||
| type BranchRow = [ string, string, string, string, string, boolean ]; | ||||
| 
 | ||||
| class SBranch extends AbstractShacaEntity { | ||||
|     constructor([branchId, noteId, parentNoteId, prefix, isExpanded]) { | ||||
| 
 | ||||
|     private branchId: string; | ||||
|     private noteId: string; | ||||
|     private parentNoteId: string; | ||||
|     private prefix: string; | ||||
|     private isExpanded: boolean; | ||||
|     isHidden: boolean; | ||||
| 
 | ||||
|     constructor([branchId, noteId, parentNoteId, prefix, isExpanded]: BranchRow) { | ||||
|         super(); | ||||
| 
 | ||||
|         /** @param {string} */ | ||||
|         this.branchId = branchId; | ||||
|         /** @param {string} */ | ||||
|         this.noteId = noteId; | ||||
|         /** @param {string} */ | ||||
|         this.parentNoteId = parentNoteId; | ||||
|         /** @param {string} */ | ||||
|         this.prefix = prefix; | ||||
|         /** @param {boolean} */ | ||||
|         this.isExpanded = !!isExpanded; | ||||
|         /** @param {boolean} */ | ||||
|         this.isHidden = false; | ||||
| 
 | ||||
|         const childNote = this.childNote; | ||||
| @ -38,25 +43,21 @@ class SBranch extends AbstractShacaEntity { | ||||
|         this.shaca.childParentToBranch[`${this.noteId}-${this.parentNoteId}`] = this; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {SNote} */ | ||||
|     get childNote() { | ||||
|     get childNote(): SNote { | ||||
|         return this.shaca.notes[this.noteId]; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {SNote} */ | ||||
|     getNote() { | ||||
|         return this.childNote; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {SNote} */ | ||||
|     get parentNote() { | ||||
|     get parentNote(): SNote { | ||||
|         return this.shaca.notes[this.parentNoteId]; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {SNote} */ | ||||
|     getParentNote() { | ||||
|         return this.parentNote; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| module.exports = SBranch; | ||||
| export = SBranch; | ||||
| @ -7,6 +7,7 @@ import escape = require('escape-html'); | ||||
| import { Blob } from '../../../services/blob-interface'; | ||||
| import SAttachment = require('./sattachment'); | ||||
| import SAttribute = require('./sattribute'); | ||||
| import SBranch = require('./sbranch'); | ||||
| 
 | ||||
| const LABEL = 'label'; | ||||
| const RELATION = 'relation'; | ||||
| @ -24,9 +25,9 @@ class SNote extends AbstractShacaEntity { | ||||
|     private blobId: string; | ||||
|     private utcDateModified: string; | ||||
|     private isProtected: boolean; | ||||
|     private parentBranches: any[];    // fixme: set right data type once SBranch is ported.
 | ||||
|     private parents: SNote[]; | ||||
|     private children: SNote[]; | ||||
|     parentBranches: SBranch[]; | ||||
|     parents: SNote[]; | ||||
|     children: SNote[]; | ||||
|     private ownedAttributes: SAttribute[]; | ||||
|     private __attributeCache: SAttribute[] | null; | ||||
|     private __inheritableAttributeCache: SAttribute[] | null; | ||||
| @ -58,18 +59,15 @@ class SNote extends AbstractShacaEntity { | ||||
|         this.shaca.notes[this.noteId] = this; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {SBranch[]} */ | ||||
|     getParentBranches() { | ||||
|         return this.parentBranches; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {SBranch[]} */ | ||||
|     getBranches() { | ||||
|         return this.parentBranches; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {SBranch[]} */ | ||||
|     getChildBranches() { | ||||
|     getChildBranches(): SBranch[] { | ||||
|         return this.children.map(childNote => this.shaca.getBranchFromChildAndParent(childNote.noteId, this.noteId)); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -4,7 +4,7 @@ const sql = require('../sql'); | ||||
| const shaca = require('./shaca.js'); | ||||
| const log = require('../../services/log'); | ||||
| const SNote = require('./entities/snote'); | ||||
| const SBranch = require('./entities/sbranch.js'); | ||||
| const SBranch = require('./entities/sbranch'); | ||||
| const SAttribute = require('./entities/sattribute'); | ||||
| const SAttachment = require('./entities/sattachment'); | ||||
| const shareRoot = require('../share_root'); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran