mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	add possibility to change clipper parent to a fixed note instead of day notes, fixes #854
This commit is contained in:
		| @@ -1,5 +1,6 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
|  | const attributeService = require("../../services/attributes"); | ||||||
| const noteService = require('../../services/notes'); | const noteService = require('../../services/notes'); | ||||||
| const dateNoteService = require('../../services/date_notes'); | const dateNoteService = require('../../services/date_notes'); | ||||||
| const dateUtils = require('../../services/date_utils'); | const dateUtils = require('../../services/date_utils'); | ||||||
| @@ -23,16 +24,26 @@ async function findClippingNote(todayNote, pageUrl) { | |||||||
|     return null; |     return null; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | async function getClipperInboxNote() { | ||||||
|  |     let clipperInbox = await attributeService.getNoteWithLabel('clipperInbox'); | ||||||
|  |  | ||||||
|  |     if (!clipperInbox) { | ||||||
|  |         clipperInbox = await dateNoteService.getDateNote(dateUtils.localNowDate()); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     return clipperInbox; | ||||||
|  | } | ||||||
|  |  | ||||||
| async function addClipping(req) { | async function addClipping(req) { | ||||||
|     const {title, content, pageUrl, images} = req.body; |     const {title, content, pageUrl, images} = req.body; | ||||||
|  |  | ||||||
|     const todayNote = await dateNoteService.getDateNote(dateUtils.localNowDate()); |     const clipperInbox = await getClipperInboxNote(); | ||||||
|  |  | ||||||
|     let clippingNote = await findClippingNote(todayNote, pageUrl); |     let clippingNote = await findClippingNote(clipperInbox, pageUrl); | ||||||
|  |  | ||||||
|     if (!clippingNote) { |     if (!clippingNote) { | ||||||
|         clippingNote = (await noteService.createNewNote({ |         clippingNote = (await noteService.createNewNote({ | ||||||
|             parentNoteId: todayNote.noteId, |             parentNoteId: clipperInbox.noteId, | ||||||
|             title: title, |             title: title, | ||||||
|             content: '', |             content: '', | ||||||
|             type: 'text' |             type: 'text' | ||||||
| @@ -54,10 +65,10 @@ async function addClipping(req) { | |||||||
| async function createNote(req) { | async function createNote(req) { | ||||||
|     const {title, content, pageUrl, images, clipType} = req.body; |     const {title, content, pageUrl, images, clipType} = req.body; | ||||||
|  |  | ||||||
|     const todayNote = await dateNoteService.getDateNote(dateUtils.localNowDate()); |     const clipperInbox = await getClipperInboxNote(); | ||||||
|  |  | ||||||
|     const {note} = await noteService.createNewNote({ |     const {note} = await noteService.createNewNote({ | ||||||
|         parentNoteId: todayNote.noteId, |         parentNoteId: clipperInbox.noteId, | ||||||
|         title, |         title, | ||||||
|         content, |         content, | ||||||
|         type: 'text' |         type: 'text' | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user