mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	it's now possible to mark relation as inheritable (previously this was hardcoded for specific relation names)
This commit is contained in:
		| @@ -0,0 +1 @@ | ||||
| ALTER TABLE relations ADD isInheritable int DEFAULT 0 NULL; | ||||
| @@ -140,6 +140,7 @@ CREATE TABLE relations | ||||
|     sourceNoteId       TEXT not null, | ||||
|     name         TEXT not null, | ||||
|     targetNoteId        TEXT not null, | ||||
|     isInheritable int DEFAULT 0 NULL, | ||||
|     position     INT  default 0 not null, | ||||
|     dateCreated  TEXT not null, | ||||
|     dateModified TEXT not null, | ||||
|   | ||||
| @@ -8,7 +8,7 @@ const sql = require('../services/sql'); | ||||
| class Relation extends Entity { | ||||
|     static get tableName() { return "relations"; } | ||||
|     static get primaryKeyName() { return "relationId"; } | ||||
|     static get hashedProperties() { return ["relationId", "sourceNoteId", "name", "targetNoteId", "dateModified", "dateCreated"]; } | ||||
|     static get hashedProperties() { return ["relationId", "sourceNoteId", "name", "targetNoteId", "isInheritable", "dateModified", "dateCreated"]; } | ||||
|  | ||||
|     async getSourceNote() { | ||||
|         return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.sourceNoteId]); | ||||
| @@ -25,6 +25,10 @@ class Relation extends Entity { | ||||
|             this.position = 1 + await sql.getValue(`SELECT COALESCE(MAX(position), 0) FROM relations WHERE sourceNoteId = ?`, [this.sourceNoteId]); | ||||
|         } | ||||
|  | ||||
|         if (!this.isInheritable) { | ||||
|             this.isInheritable = false; | ||||
|         } | ||||
|  | ||||
|         if (!this.isDeleted) { | ||||
|             this.isDeleted = false; | ||||
|         } | ||||
|   | ||||
| @@ -123,6 +123,7 @@ function RelationsModel() { | ||||
|                 relationId: '', | ||||
|                 name: '', | ||||
|                 targetNoteId: '', | ||||
|                 isInheritable: 0, | ||||
|                 isDeleted: 0, | ||||
|                 position: 0 | ||||
|             })); | ||||
| @@ -176,7 +177,7 @@ async function showDialog() { | ||||
|  | ||||
|     $dialog.dialog({ | ||||
|         modal: true, | ||||
|         width: 800, | ||||
|         width: 900, | ||||
|         height: 500 | ||||
|     }); | ||||
| } | ||||
|   | ||||
| @@ -33,6 +33,7 @@ async function updateNoteRelations(req) { | ||||
|  | ||||
|         relationEntity.name = relation.name; | ||||
|         relationEntity.targetNoteId = relation.targetNoteId; | ||||
|         relationEntity.isInheritable = relation.isInheritable; | ||||
|         relationEntity.position = relation.position; | ||||
|         relationEntity.isDeleted = relation.isDeleted; | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| const build = require('./build'); | ||||
| const packageJson = require('../../package'); | ||||
|  | ||||
| const APP_DB_VERSION = 106; | ||||
| const APP_DB_VERSION = 107; | ||||
| const SYNC_VERSION = 1; | ||||
|  | ||||
| module.exports = { | ||||
|   | ||||
| @@ -46,7 +46,8 @@ async function getEffectiveRelations(noteId) { | ||||
|             JOIN notes ON notes.noteId = branches.parentNoteId | ||||
|             WHERE notes.isDeleted = 0 AND branches.isDeleted = 0 | ||||
|         ) | ||||
|         SELECT relations.* FROM relations JOIN tree ON relations.sourceNoteId = tree.noteId WHERE relations.isDeleted = 0 AND relations.name IN ('runOnNoteView')`, [noteId]); | ||||
|         SELECT relations.* FROM relations JOIN tree ON relations.sourceNoteId = tree.noteId  | ||||
|         WHERE relations.isDeleted = 0 AND (relations.isInheritable = 1 OR relations.sourceNoteId = ?)`, [noteId, noteId]); | ||||
| } | ||||
|  | ||||
| module.exports = { | ||||
|   | ||||
| @@ -40,7 +40,7 @@ async function updateEntity(sync, entity, sourceId) { | ||||
|         await updateApiToken(entity, sourceId); | ||||
|     } | ||||
|     else { | ||||
|         throw new Error(`Unrecognized entity type ${sync}`); | ||||
|         throw new Error(`Unrecognized entity type ${entityName}`); | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -612,6 +612,7 @@ | ||||
|               <th>ID</th> | ||||
|               <th>Relation name</th> | ||||
|               <th>Target note</th> | ||||
|               <th>Inheritable</th> | ||||
|               <th></th> | ||||
|             </tr> | ||||
|             </thead> | ||||
| @@ -639,6 +640,9 @@ | ||||
|                   <span class="input-group-addon relations-show-recent-notes" title="Show recent notes" style="background: url('/images/icons/clock-16.png') no-repeat center; cursor: pointer;"></span> | ||||
|                 </div> | ||||
|               </td> | ||||
|               <td title="Inheritable relations are automatically inherited to the child notes"> | ||||
|                 <input type="checkbox" value="1" data-bind="checked: isInheritable" /> | ||||
|               </td> | ||||
|               <td title="Delete" style="padding: 13px; cursor: pointer;"> | ||||
|                 <span class="glyphicon glyphicon-trash" data-bind="click: $parent.deleteRelation"></span> | ||||
|               </td> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user