mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	date notes respect their parent's isProtected status, #1483
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| import utils from "./utils.js"; | import utils from "./utils.js"; | ||||||
| import dateNoteService from "./date_notes.js"; | import dateNoteService from "./date_notes.js"; | ||||||
| import hoistedNoteService from "./hoisted_note.js"; | import protectedSessionHolder from './protected_session_holder.js'; | ||||||
| import server from "./server.js"; | import server from "./server.js"; | ||||||
| import appContext from "./app_context.js"; | import appContext from "./app_context.js"; | ||||||
| import Component from "../widgets/component.js"; | import Component from "../widgets/component.js"; | ||||||
| @@ -69,7 +69,7 @@ export default class Entrypoints extends Component { | |||||||
|             title: 'new note', |             title: 'new note', | ||||||
|             content: '', |             content: '', | ||||||
|             type: 'text', |             type: 'text', | ||||||
|             isProtected: inboxNote.isProtected |             isProtected: inboxNote.isProtected && protectedSessionHolder.isProtectedSessionAvailable() | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         await ws.waitForMaxKnownEntityChangeId(); |         await ws.waitForMaxKnownEntityChangeId(); | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ const attributeService = require('./attributes'); | |||||||
| const dateUtils = require('./date_utils'); | const dateUtils = require('./date_utils'); | ||||||
| const repository = require('./repository'); | const repository = require('./repository'); | ||||||
| const sql = require('./sql'); | const sql = require('./sql'); | ||||||
|  | const protectedSessionService = require('./protected_session'); | ||||||
|  |  | ||||||
| const CALENDAR_ROOT_LABEL = 'calendarRoot'; | const CALENDAR_ROOT_LABEL = 'calendarRoot'; | ||||||
| const YEAR_LABEL = 'yearNote'; | const YEAR_LABEL = 'yearNote'; | ||||||
| @@ -14,14 +15,14 @@ const DATE_LABEL = 'dateNote'; | |||||||
| const DAYS = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; | const DAYS = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; | ||||||
| const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December']; | const MONTHS = ['January','February','March','April','May','June','July','August','September','October','November','December']; | ||||||
|  |  | ||||||
| function createNote(parentNoteId, noteTitle) { | function createNote(parentNote, noteTitle) { | ||||||
|     return (noteService.createNewNote({ |     return noteService.createNewNote({ | ||||||
|         parentNoteId: parentNoteId, |         parentNoteId: parentNote.noteId, | ||||||
|         title: noteTitle, |         title: noteTitle, | ||||||
|         content: '', |         content: '', | ||||||
|         isProtected: false, |         isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(), | ||||||
|         type: 'text' |         type: 'text' | ||||||
|     })).note; |     }).note; | ||||||
| } | } | ||||||
|  |  | ||||||
| function getNoteStartingWith(parentNoteId, startsWith) { | function getNoteStartingWith(parentNoteId, startsWith) { | ||||||
| @@ -70,7 +71,7 @@ function getYearNote(dateStr, rootNote) { | |||||||
|  |  | ||||||
|         if (!yearNote) { |         if (!yearNote) { | ||||||
|             sql.transactional(() => { |             sql.transactional(() => { | ||||||
|                 yearNote = createNote(rootNote.noteId, yearStr); |                 yearNote = createNote(rootNote, yearStr); | ||||||
|  |  | ||||||
|                 attributeService.createLabel(yearNote.noteId, YEAR_LABEL, yearStr); |                 attributeService.createLabel(yearNote.noteId, YEAR_LABEL, yearStr); | ||||||
|                 attributeService.createLabel(yearNote.noteId, 'sorted'); |                 attributeService.createLabel(yearNote.noteId, 'sorted'); | ||||||
| @@ -118,7 +119,7 @@ function getMonthNote(dateStr, rootNote) { | |||||||
|             const noteTitle = getMonthNoteTitle(rootNote, monthNumber, dateObj); |             const noteTitle = getMonthNoteTitle(rootNote, monthNumber, dateObj); | ||||||
|  |  | ||||||
|             sql.transactional(() => { |             sql.transactional(() => { | ||||||
|                 monthNote = createNote(yearNote.noteId, noteTitle); |                 monthNote = createNote(yearNote, noteTitle); | ||||||
|  |  | ||||||
|                 attributeService.createLabel(monthNote.noteId, MONTH_LABEL, monthStr); |                 attributeService.createLabel(monthNote.noteId, MONTH_LABEL, monthStr); | ||||||
|                 attributeService.createLabel(monthNote.noteId, 'sorted'); |                 attributeService.createLabel(monthNote.noteId, 'sorted'); | ||||||
| @@ -166,7 +167,7 @@ function getDateNote(dateStr) { | |||||||
|             const noteTitle = getDateNoteTitle(rootNote, dayNumber, dateObj); |             const noteTitle = getDateNoteTitle(rootNote, dayNumber, dateObj); | ||||||
|  |  | ||||||
|             sql.transactional(() => { |             sql.transactional(() => { | ||||||
|                 dateNote = createNote(monthNote.noteId, noteTitle); |                 dateNote = createNote(monthNote, noteTitle); | ||||||
|  |  | ||||||
|                 attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr.substr(0, 10)); |                 attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr.substr(0, 10)); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -121,7 +121,7 @@ function exportToZip(taskContext, branch, format, res) { | |||||||
|             type: note.type, |             type: note.type, | ||||||
|             mime: note.mime, |             mime: note.mime, | ||||||
|             // we don't export utcDateCreated and utcDateModified of any entity since that would be a bit misleading |             // we don't export utcDateCreated and utcDateModified of any entity since that would be a bit misleading | ||||||
|             attributes: (note.getOwnedAttributes()).map(attribute => ({ |             attributes: note.getOwnedAttributes().map(attribute => ({ | ||||||
|                     type: attribute.type, |                     type: attribute.type, | ||||||
|                     name: attribute.name, |                     name: attribute.name, | ||||||
|                     value: attribute.value, |                     value: attribute.value, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user