diff --git a/src/entities/attribute.js b/src/entities/attribute.js index c12f39a20..a40964b9f 100644 --- a/src/entities/attribute.js +++ b/src/entities/attribute.js @@ -40,10 +40,20 @@ class Attribute extends Entity { } } + /** + * @returns {Promise} + */ async getNote() { - return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); + if (!this.__note) { + this.__note = await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.noteId]); + } + + return this.__note; } + /** + * @returns {Promise} + */ async getTargetNote() { if (this.type !== 'relation') { throw new Error(`Attribute ${this.attributeId} is not relation`); @@ -53,9 +63,16 @@ class Attribute extends Entity { return null; } - return await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.value]); + if (!this.__targetNote) { + this.__targetNote = await repository.getEntity("SELECT * FROM notes WHERE noteId = ?", [this.value]); + } + + return this.__targetNote; } + /** + * @return {boolean} + */ isDefinition() { return this.type === 'label-definition' || this.type === 'relation-definition'; } diff --git a/src/public/javascripts/dialogs/attributes.js b/src/public/javascripts/dialogs/attributes.js index 6d04b0a3b..c01b2ea81 100644 --- a/src/public/javascripts/dialogs/attributes.js +++ b/src/public/javascripts/dialogs/attributes.js @@ -71,6 +71,7 @@ function AttributesModel() { attr.relationDefinition = (attr.type === 'relation-definition' && attr.value) ? attr.value : { multiplicityType: "singlevalue", + mirrorRelation: "", isPromoted: true }; @@ -189,6 +190,7 @@ function AttributesModel() { }, relationDefinition: { multiplicityType: "singlevalue", + mirrorRelation: "", isPromoted: true } })); diff --git a/src/public/javascripts/services/attributes.js b/src/public/javascripts/services/attributes.js index 785fae1cb..d1ba1cc04 100644 --- a/src/public/javascripts/services/attributes.js +++ b/src/public/javascripts/services/attributes.js @@ -60,7 +60,7 @@ async function showAttributes() { const $inputCell = $("").append($("
").addClass("input-group").append($input)); const $actionCell = $(""); - const $multiplicityCell = $(""); + const $multiplicityCell = $("").addClass("multiplicity"); $tr .append($labelCell) @@ -148,9 +148,14 @@ async function showAttributes() { // ideally we'd use link instead of button which would allow tooltip preview, but // we can't guarantee updating the link in the a element const $openButton = $("