diff --git a/db/demo.tar b/db/demo.tar
index 11a8c9f6e..778d82a1c 100644
Binary files a/db/demo.tar and b/db/demo.tar differ
diff --git a/db/migrations/0119__rename_mirror_to_inverse.sql b/db/migrations/0119__rename_mirror_to_inverse.sql
new file mode 100644
index 000000000..203b18959
--- /dev/null
+++ b/db/migrations/0119__rename_mirror_to_inverse.sql
@@ -0,0 +1 @@
+UPDATE attributes SET value = replace(value, 'mirrorRelation', 'inverseRelation') WHERE type = 'relation-definition';
\ No newline at end of file
diff --git a/src/public/javascripts/dialogs/attributes.js b/src/public/javascripts/dialogs/attributes.js
index efb335103..4ec89f861 100644
--- a/src/public/javascripts/dialogs/attributes.js
+++ b/src/public/javascripts/dialogs/attributes.js
@@ -72,7 +72,7 @@ function AttributesModel() {
attr.relationDefinition = (attr.type === 'relation-definition' && attr.value) ? attr.value : {
multiplicityType: "singlevalue",
- mirrorRelation: "",
+ inverseRelation: "",
isPromoted: true
};
@@ -191,7 +191,7 @@ function AttributesModel() {
},
relationDefinition: {
multiplicityType: "singlevalue",
- mirrorRelation: "",
+ inverseRelation: "",
isPromoted: true
}
}));
diff --git a/src/public/javascripts/services/note_detail_relation_map.js b/src/public/javascripts/services/note_detail_relation_map.js
index a90a744ea..400c10cd2 100644
--- a/src/public/javascripts/services/note_detail_relation_map.js
+++ b/src/public/javascripts/services/note_detail_relation_map.js
@@ -50,7 +50,7 @@ const biDirectionalOverlays = [
} ]
];
-const mirrorOverlays = [
+const inverseRelationsOverlays = [
[ "Arrow", {
location: 1,
id: "arrow",
@@ -134,12 +134,12 @@ async function loadNotesAndRelations() {
for (const relation of data.relations) {
const match = relations.find(rel =>
- rel.name === data.mirrorRelations[relation.name]
+ rel.name === data.inverseRelations[relation.name]
&& ((rel.sourceNoteId === relation.sourceNoteId && rel.targetNoteId === relation.targetNoteId)
|| (rel.sourceNoteId === relation.targetNoteId && rel.targetNoteId === relation.sourceNoteId)));
if (match) {
- match.type = relation.type = relation.name === data.mirrorRelations[relation.name] ? 'biDirectional' : 'mirror';
+ match.type = relation.type = relation.name === data.inverseRelations[relation.name] ? 'biDirectional' : 'inverse';
relation.render = false; // don't render second relation
} else {
relation.type = 'uniDirectional';
@@ -173,9 +173,9 @@ async function loadNotesAndRelations() {
connection.id = relation.attributeId;
- if (relation.type === 'mirror') {
+ if (relation.type === 'inverse') {
connection.getOverlay("label-source").setLabel(relation.name);
- connection.getOverlay("label-target").setLabel(data.mirrorRelations[relation.name]);
+ connection.getOverlay("label-target").setLabel(data.inverseRelations[relation.name]);
}
else {
connection.getOverlay("label").setLabel(relation.name);
@@ -290,7 +290,7 @@ function initJsPlumbInstance () {
jsPlumbInstance.registerConnectionType("biDirectional", { anchor:"Continuous", connector:"StateMachine", overlays: biDirectionalOverlays });
- jsPlumbInstance.registerConnectionType("mirror", { anchor:"Continuous", connector:"StateMachine", overlays: mirrorOverlays });
+ jsPlumbInstance.registerConnectionType("inverse", { anchor:"Continuous", connector:"StateMachine", overlays: inverseRelationsOverlays });
jsPlumbInstance.registerConnectionType("link", { anchor:"Continuous", connector:"StateMachine", overlays: linkOverlays });
diff --git a/src/routes/api/notes.js b/src/routes/api/notes.js
index 225a7d261..326ab86be 100644
--- a/src/routes/api/notes.js
+++ b/src/routes/api/notes.js
@@ -117,8 +117,8 @@ async function getRelationMap(req) {
// noteId => title
noteTitles: {},
relations: [],
- // relation name => mirror relation name
- mirrorRelations: {},
+ // relation name => inverse relation name
+ inverseRelations: {},
links: []
};
@@ -143,8 +143,8 @@ async function getRelationMap(req) {
}; }));
for (const relationDefinition of await note.getRelationDefinitions()) {
- if (relationDefinition.value.mirrorRelation) {
- resp.mirrorRelations[relationDefinition.name] = relationDefinition.value.mirrorRelation;
+ if (relationDefinition.value.inverseRelation) {
+ resp.inverseRelations[relationDefinition.name] = relationDefinition.value.inverseRelation;
}
}
}
diff --git a/src/services/app_info.js b/src/services/app_info.js
index 677a75d57..a39c27300 100644
--- a/src/services/app_info.js
+++ b/src/services/app_info.js
@@ -3,7 +3,7 @@
const build = require('./build');
const packageJson = require('../../package');
-const APP_DB_VERSION = 118;
+const APP_DB_VERSION = 119;
const SYNC_VERSION = 2;
module.exports = {
diff --git a/src/services/handlers.js b/src/services/handlers.js
index 0bf156ce4..4c7857493 100644
--- a/src/services/handlers.js
+++ b/src/services/handlers.js
@@ -59,7 +59,7 @@ eventService.subscribe(eventService.CHILD_NOTE_CREATED, async ({ parentNote, chi
await runAttachedRelations(parentNote, 'runOnChildNoteCreation', childNote);
});
-async function processMirrorRelations(entityName, entity, handler) {
+async function processInverseRelations(entityName, entity, handler) {
if (entityName === 'attributes' && entity.type === 'relation') {
const note = await entity.getNote();
const attributes = (await note.getAttributes(entity.name)).filter(relation => relation.type === 'relation-definition');
@@ -67,7 +67,7 @@ async function processMirrorRelations(entityName, entity, handler) {
for (const attribute of attributes) {
const definition = attribute.value;
- if (definition.mirrorRelation && definition.mirrorRelation.trim()) {
+ if (definition.inverseRelation && definition.inverseRelation.trim()) {
const targetNote = await entity.getTargetNote();
await handler(definition, note, targetNote);
@@ -77,17 +77,17 @@ async function processMirrorRelations(entityName, entity, handler) {
}
eventService.subscribe(eventService.ENTITY_CHANGED, async ({ entityName, entity }) => {
- await processMirrorRelations(entityName, entity, async (definition, note, targetNote) => {
- // we need to make sure that also target's mirror attribute exists and if note, then create it
- // mirror attribute has to target our note as well
- const hasMirrorAttribute = (await targetNote.getRelations(definition.mirrorRelation))
+ await processInverseRelations(entityName, entity, async (definition, note, targetNote) => {
+ // we need to make sure that also target's inverse attribute exists and if note, then create it
+ // inverse attribute has to target our note as well
+ const hasInverseAttribute = (await targetNote.getRelations(definition.inverseRelation))
.some(attr => attr.value === note.noteId);
- if (!hasMirrorAttribute) {
+ if (!hasInverseAttribute) {
await new Attribute({
noteId: targetNote.noteId,
type: 'relation',
- name: definition.mirrorRelation,
+ name: definition.inverseRelation,
value: note.noteId,
isInheritable: entity.isInheritable
}).save();
@@ -98,9 +98,9 @@ eventService.subscribe(eventService.ENTITY_CHANGED, async ({ entityName, entity
});
eventService.subscribe(eventService.ENTITY_DELETED, async ({ entityName, entity }) => {
- await processMirrorRelations(entityName, entity, async (definition, note, targetNote) => {
- // if one mirror attribute is deleted then the other should be deleted as well
- const relations = await targetNote.getRelations(definition.mirrorRelation);
+ await processInverseRelations(entityName, entity, async (definition, note, targetNote) => {
+ // if one inverse attribute is deleted then the other should be deleted as well
+ const relations = await targetNote.getRelations(definition.inverseRelation);
let deletedSomething = false;
for (const relation of relations) {
diff --git a/src/views/dialogs/attributes.ejs b/src/views/dialogs/attributes.ejs
index 3f30c9d32..4040a189a 100644
--- a/src/views/dialogs/attributes.ejs
+++ b/src/views/dialogs/attributes.ejs
@@ -72,9 +72,9 @@