child: prefix now copies attributes on new note creation

This commit is contained in:
azivner
2018-08-21 13:49:45 +02:00
parent 171877ce08
commit 71e687ad8e
3 changed files with 16 additions and 1 deletions

View File

@@ -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