From 71e687ad8e1f95205cb21e8cf198b74ec05f7f9e Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 21 Aug 2018 13:49:45 +0200 Subject: [PATCH] child: prefix now copies attributes on new note creation --- db/migrations/0112__rename_inheritAttributes.sql | 1 + src/services/app_info.js | 2 +- src/services/notes.js | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 db/migrations/0112__rename_inheritAttributes.sql diff --git a/db/migrations/0112__rename_inheritAttributes.sql b/db/migrations/0112__rename_inheritAttributes.sql new file mode 100644 index 000000000..5cb85978a --- /dev/null +++ b/db/migrations/0112__rename_inheritAttributes.sql @@ -0,0 +1 @@ +UPDATE attributes SET name = 'template' WHERE name = 'inheritAttributes'; \ No newline at end of file diff --git a/src/services/app_info.js b/src/services/app_info.js index 22383c70a..0e61c9b98 100644 --- a/src/services/app_info.js +++ b/src/services/app_info.js @@ -3,7 +3,7 @@ const build = require('./build'); const packageJson = require('../../package'); -const APP_DB_VERSION = 111; +const APP_DB_VERSION = 112; const SYNC_VERSION = 1; module.exports = { diff --git a/src/services/notes.js b/src/services/notes.js index 50f16cefe..32a55d18e 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -9,6 +9,7 @@ const Note = require('../entities/note'); const NoteImage = require('../entities/note_image'); const NoteRevision = require('../entities/note_revision'); const Branch = require('../entities/branch'); +const Attribute = require('../entities/attribute'); async function getNewNotePosition(parentNoteId, noteData) { let newNotePos = 0; @@ -70,6 +71,19 @@ async function createNewNote(parentNoteId, noteData) { await triggerNoteTitleChanged(note); await triggerChildNoteCreated(note, parentNote); + for (const attr of await parentNote.getAttributes()) { + if (attr.name.startsWith("child:")) { + await new Attribute({ + noteId: note.noteId, + type: attr.type, + name: attr.name.substr(6), + value: attr.value, + position: attr.position, + isInheritable: attr.isInheritable + }).save(); + } + } + return { note, branch