Added basic popover for item addition in relation_graph

pull/3063/head
Sami Mokaddem 2018-03-19 14:07:51 +00:00
parent 0b0eddfcc0
commit 1209954f06
2 changed files with 39 additions and 1 deletions

View File

@ -1259,6 +1259,29 @@ function simplePopup(url) {
});
}
function choicePopup(legend, list) {
var popupHtml = '<div class="popover_choice">';
popupHtml += '<legend>Select Object Category</legend>';
popupHtml += '<div class="popover_choice_main" id ="popover_choice_main">';
popupHtml += '<table style="width:100%;" id="MainTable">';
popupHtml += '<tbody>';
for (var item of list) {
popupHtml += '<tr style="border-bottom:1px solid black;" class="templateChoiceButton">';
popupHtml += '<td role="button" tabindex="0" aria-label="All meta-categories" title="'+item.text+'" style="padding-left:10px;padding-right:10px; text-align:center;width:100%;" onClick="'+item.onclick+';">'+item.text+'</td>';
popupHtml += '</tr>';
}
popupHtml += '</tbody>';
popupHtml += '</table>';
popupHtml += '</div>';
popupHtml += '<div role="button" tabindex="0" aria-label="Cancel" title="Cancel" class="templateChoiceButton templateChoiceButtonLast" onClick="cancelPopoverForm();">Cancel</div>';
popupHtml += '</div>';
$("#popover_form").html(popupHtml);
openPopup("#popover_form");
//$("#gray_out").fadeIn();
}
function resizePopoverBody() {
var bodyheight = $(window).height();
bodyheight = 3 * bodyheight / 4 - 150;

View File

@ -51,7 +51,7 @@ var network_options = {
initiallyActive: true,
addEdge: add_reference,
editEdge: false,
addNode: false,
addNode: add_item,
deleteNode: false,
deleteEdge: remove_reference
},
@ -114,6 +114,8 @@ var network_options = {
edit: 'Edit',
del: 'Delete selected',
back: 'Back',
addNode: 'Add Object or Attribute',
addDescription: 'Click in an empty space to place a new node.',
addEdge: 'Add Reference',
edgeDescription: 'Click on an Object and drag the edge to another Object (or Attribute) to connect them.'
}
@ -208,6 +210,19 @@ function add_reference(edgeData, callback) {
});
}
function add_item(nodeData, callback) {
choicePopup("Add an element", [
{
text: "Add an object",
onclick: "getPopup('"+scope_id+"', 'objectTemplates', 'objectChoice');"
},
{
text: "Add an attribute",
onclick: "simplePopup('/attributes/add/"+scope_id+"');"
},
]);
}
function reset_graphs() {
nodes.clear();
edges.clear();