diff --git a/src/public/app/services/context_menu.js b/src/public/app/services/context_menu.js
index 5789b0819..fde332b0e 100644
--- a/src/public/app/services/context_menu.js
+++ b/src/public/app/services/context_menu.js
@@ -7,10 +7,10 @@ class ContextMenu {
$(document).on('click', () => this.hide());
}
-
+
async show(options) {
this.options = options;
-
+
this.$widget.empty();
this.addItems(this.$widget, options.items);
@@ -27,7 +27,7 @@ class ContextMenu {
// in such case we'll position it above click coordinates so it will fit into client
const clientHeight = document.documentElement.clientHeight;
const contextMenuHeight = this.$widget.outerHeight() + 30;
- let top;
+ let top, left;
if (this.options.y + contextMenuHeight > clientHeight) {
top = clientHeight - contextMenuHeight - 10;
@@ -35,10 +35,17 @@ class ContextMenu {
top = this.options.y - 10;
}
+ if (this.options.orientation === 'left') {
+ left = this.options.x - this.$widget.outerWidth() + 20;
+ }
+ else {
+ left = this.options.x - 20;
+ }
+
this.$widget.css({
display: "block",
top: top,
- left: this.options.x - 20
+ left: left
}).addClass("show");
}
@@ -113,4 +120,4 @@ class ContextMenu {
const contextMenu = new ContextMenu();
-export default contextMenu;
\ No newline at end of file
+export default contextMenu;
diff --git a/src/public/app/widgets/attribute_detail.js b/src/public/app/widgets/attribute_detail.js
index 7167ac660..cf190f76e 100644
--- a/src/public/app/widgets/attribute_detail.js
+++ b/src/public/app/widgets/attribute_detail.js
@@ -6,7 +6,7 @@ import BasicWidget from "./basic_widget.js";
import noteAutocompleteService from "../services/note_autocomplete.js";
const TPL = `
-
+
`;
diff --git a/src/public/app/widgets/note_attributes.js b/src/public/app/widgets/note_attributes.js
index b0311cdfb..f08849cd4 100644
--- a/src/public/app/widgets/note_attributes.js
+++ b/src/public/app/widgets/note_attributes.js
@@ -326,12 +326,13 @@ export default class NoteAttributesWidget extends TabAwareWidget {
contextMenuService.show({
x: e.pageX,
y: e.pageY,
+ orientation: 'left',
items: [
{title: "Add new label", command: "addNewLabel", uiIcon: "hash"},
{title: "Add new relation", command: "addNewRelation", uiIcon: "transfer"},
{title: "----"},
- {title: "Add new label definition", command: "addNewRelation", uiIcon: "empty"},
- {title: "Add new relation definition", command: "addNewRelation", uiIcon: "empty"},
+ {title: "Add new label definition", command: "addNewLabelDefinition", uiIcon: "empty"},
+ {title: "Add new relation definition", command: "addNewRelationDefinition", uiIcon: "empty"},
],
selectMenuItemHandler: async ({command}) => {
const attrs = this.parseAttributes();
@@ -340,20 +341,43 @@ export default class NoteAttributesWidget extends TabAwareWidget {
return;
}
+ let type, name;
+
if (command === 'addNewLabel') {
- attrs.push({
- type: 'label',
- name: 'fillName',
- value: '',
- isInheritable: false
- });
+ type = 'label';
+ name = 'fillName';
+ }
+ else if (command === 'addNewRelation') {
+ type = 'relation';
+ name = 'fillName';
+ }
+ else if (command === 'addNewLabelDefinition') {
+ type = 'label';
+ name = 'label:fillName';
+ }
+ else if (command === 'addNewRelationDefinition') {
+ type = 'label';
+ name = 'relation:fillName';
+ }
+ else {
+ return;
+ }
- await this.renderOwnedAttributes(attrs);
+ attrs.push({
+ type,
+ name,
+ value: '',
+ isInheritable: false
+ });
- this.$editor.scrollTop(this.$editor[0].scrollHeight);
+ await this.renderOwnedAttributes(attrs);
- const rect = this.$editor[0].getBoundingClientRect();
+ this.$editor.scrollTop(this.$editor[0].scrollHeight);
+ const rect = this.$editor[0].getBoundingClientRect();
+
+ setTimeout(() => {
+ // showing a little bit later because there's a conflict with outside click closing the attr detail
this.attributeDetailWidget.showAttributeDetail({
allAttributes: attrs,
attribute: attrs[attrs.length - 1],
@@ -361,7 +385,7 @@ export default class NoteAttributesWidget extends TabAwareWidget {
x: (rect.left + rect.right) / 2,
y: rect.bottom
});
- }
+ }, 100);
}
});
});