fix overwriting / deleting auto links, closes #1406

This commit is contained in:
zadam 2020-11-11 23:15:48 +01:00
parent d5a9abd911
commit 99f01b9ccf
2 changed files with 8 additions and 2 deletions

View File

@ -34,6 +34,10 @@ class Attribute extends Entity {
this.isInheritable = !!this.isInheritable; this.isInheritable = !!this.isInheritable;
} }
isAutoLink() {
return this.type === 'relation' && ['internalLink', 'imageLink', 'relationMapLink', 'includeNoteLink'].includes(this.name);
}
/** /**
* @returns {Note|null} * @returns {Note|null}
*/ */

View File

@ -147,8 +147,10 @@ function updateNoteAttributes(req) {
// all the remaining existing attributes are not defined anymore and should be deleted // all the remaining existing attributes are not defined anymore and should be deleted
for (const toDeleteAttr of existingAttrs) { for (const toDeleteAttr of existingAttrs) {
toDeleteAttr.isDeleted = true; if (!toDeleteAttr.isAutoLink()) {
toDeleteAttr.save(); toDeleteAttr.isDeleted = true;
toDeleteAttr.save();
}
} }
} }