cleanup/fixes of label/relation definition usages in the old style

This commit is contained in:
zadam
2020-09-08 20:42:50 +02:00
parent 80f269d844
commit 8b4cf474bd
5 changed files with 9 additions and 49 deletions

View File

@@ -30,14 +30,6 @@ class Attribute extends Entity {
super(row);
this.isInheritable = !!this.isInheritable;
if (this.isDefinition()) {
try {
this.value = JSON.parse(this.value);
}
catch (e) {
}
}
}
/**
@@ -66,7 +58,7 @@ class Attribute extends Entity {
* @return {boolean}
*/
isDefinition() {
return this.type === 'label-definition' || this.type === 'relation-definition';
return this.type === 'label' && (this.name.startsWith('label:') || this.name.startsWith('relation:'));
}
beforeSaving() {

View File

@@ -9,9 +9,7 @@ const dateUtils = require('../services/date_utils');
const entityChangesService = require('../services/entity_changes.js');
const LABEL = 'label';
const LABEL_DEFINITION = 'label-definition';
const RELATION = 'relation';
const RELATION_DEFINITION = 'relation-definition';
/**
* This represents a Note which is a central object in the Trilium Notes project.
@@ -302,14 +300,6 @@ class Note extends Entity {
return this.getOwnedAttributes(LABEL, name);
}
/**
* @param {string} [name] - label name to filter
* @returns {Attribute[]} all note's label definitions, including inherited ones
*/
getLabelDefinitions(name) {
return this.getAttributes(LABEL_DEFINITION, name);
}
/**
* @param {string} [name] - relation name to filter
* @returns {Attribute[]} all note's relations (attributes with type relation), including inherited ones
@@ -341,14 +331,6 @@ class Note extends Entity {
return targets;
}
/**
* @param {string} [name] - relation name to filter
* @returns {Attribute[]} all note's relation definitions including inherited ones
*/
getRelationDefinitions(name) {
return this.getAttributes(RELATION_DEFINITION, name);
}
/**
* Clear note's attributes cache to force fresh reload for next attribute request.
* Cache is note instance scoped.