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

@ -0,0 +1 @@
UPDATE attributes SET name = 'template' WHERE name = 'inheritAttributes';

View File

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

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