From 30249a353ea74cb055a646cf1a5811ed96d309b1 Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 19 Nov 2018 12:07:33 +0100 Subject: [PATCH] renamed "mirror" relation to "inverse" relation --- db/demo.tar | Bin 497152 -> 497152 bytes .../0119__rename_mirror_to_inverse.sql | 1 + src/public/javascripts/dialogs/attributes.js | 4 ++-- .../services/note_detail_relation_map.js | 12 +++++----- src/routes/api/notes.js | 8 +++---- src/services/app_info.js | 2 +- src/services/handlers.js | 22 +++++++++--------- src/views/dialogs/attributes.ejs | 4 ++-- 8 files changed, 27 insertions(+), 26 deletions(-) create mode 100644 db/migrations/0119__rename_mirror_to_inverse.sql diff --git a/db/demo.tar b/db/demo.tar index 11a8c9f6e1e2b83c2593e5eadefd8942c50fdeb0..778d82a1cc2e038c549bd8425a445fc1490d4d67 100644 GIT binary patch delta 7545 zcmZu$Ym8OZ6?UCr&ZROA10qvlprgn`3f%M9=Ntl|u}Z2~W2^x~#0sN;LKL4R7Au{i zvDK1G@mfx58XHSOjS_6U3A@1`HrANhCZ?6zplM9iR+EMpsiro@#IC*1UXPjd$NXRx z>-DW~JUIdU{MU@FE_praTM4OzQ_jjLyGBZSl9&}xL zdnvuN@HGgv>1NP1>yz%y$S4}AapsOcY9*eWZff4Vsu-M@(p zmWFv5ir(Q!vogzsmR)8_mg@|BdWQtghO?nUcSWx8o@g4+ft_fuz3P+V53>`0huL3R znL-jc>=HP_379-5f>~%9>uGMR%%nyN^u`kCUVLmjrH;KNZT_6XvQUlXb&iuxT2+Pg zj+gz0WQYm(oP{r9N0k#QlH5pzUSz6ddFcoiD()@5%oZ_k!o$L5KQvwu@>O{vx%ry^ zL3o=K+$W)~e^NN-mC*AIg)?@!#A2XZoVuRSGC5}#48A2bN0yLfrx1viWt5lo$us)Zta7|I3&VUdKS%YPy zcyg%CRABxVIvF%+SDXzB*pk_O7#4zsLFmL(lB6ia;d#nolDmcvi7tf8pk6xy-z2ph zOTxqHofTl)^FeruO)ve_=w2kcS>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_;5iy>40y7 zFNOS!g1wAO$->LpBmeqR6QNT2iYP5&)jQnc!PK~lp92ZyE#+er{{Pm+aWee z*{)A0!x{ce75k%P73aFz;ZFEiUl+HkTYl|yb$W_VjlmYn74s)yZ=C09ig-`|s!ZbB zBRS+Ca{Ke&Lf)StKl~|;fl*;7Wd}`uU-EbB7 z?+W;+pEqF(?`y+}Dz-}Xe^|9cLQ}~_bCyp{GIham*T!R*^pCaOl%aHwb}C>*pTV!} z&S)@-_*5<{Vs#qwDL#*?jiU;9hhy8!2D1&XE2^}58p?3WTO=Xf&#EzC{)Yga&gN5- z6{_o3_v9AZoulk#8IMp41IjMGDaqtp&~Q~b*x;&6{W4xNbwL9kt^M8qvU2RLaQ=Xq z+M{r!@dn_=i`!&|8`2)|nStgZ9yho{;?sdzgcCDh{ul zVpq|3rMJ6E?BX6J^{?vYDs4DYPsCLtUagSMbACgzaILaj$TY4UUaK9}k9yZSzm`q} zE7~{rUP)aVA8%#I`EM*|XEM~;U`nEfhm_}Czm^?hF<52(ChmC~`p>6wQc{r>|mm;NjO 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 @@