ability to change the permissions of multiple through the right click menu implemented
This commit is contained in:
parent
a36d1c8aec
commit
4fc60c13e7
3 changed files with 108 additions and 3 deletions
BIN
app/assets/images/MMCCicon_edit_permission_black.png
Normal file
BIN
app/assets/images/MMCCicon_edit_permission_black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 620 B |
|
@ -52,6 +52,14 @@ function selectEdgeOnRightClickHandler(adj, e) {
|
|||
if (userid != null) menustring += '<li class="rc-delete">Delete</li>';
|
||||
if (mapid && userid != null) menustring += '<li class="rc-remove">Remove from Map</li>';
|
||||
menustring += '<li class="rc-hide">Hide until refresh</li>';
|
||||
if (userid) {
|
||||
var options = '<ul><li class="changeP toCommons">commons</li> \
|
||||
<li class="changeP toPublic">public</li> \
|
||||
<li class="changeP toPrivate">private</li> \
|
||||
</ul>';
|
||||
|
||||
menustring += '<li class="rc-permission">Change permissions' + options + '</li>';
|
||||
}
|
||||
|
||||
menustring += '</ul>';
|
||||
rightclickmenu.innerHTML = menustring;
|
||||
|
@ -97,6 +105,13 @@ function selectEdgeOnRightClickHandler(adj, e) {
|
|||
hideSelectedNodes();
|
||||
});
|
||||
|
||||
// change the permission of all the selected nodes and synapses that you were the originator of
|
||||
$('.rc-permission li').click(function() {
|
||||
$('.rightclickmenu').remove();
|
||||
// $(this).text() will be 'commons' 'public' or 'private'
|
||||
updateSelectedPermissions( $(this).text() );
|
||||
});
|
||||
|
||||
} //selectEdgeOnRightClickHandler
|
||||
|
||||
|
||||
|
@ -236,6 +251,14 @@ function selectNodeOnClickHandler(node, e) {
|
|||
|
||||
if (!mapid) menustring += '<li class="rc-center">Center This Topic</li>';
|
||||
menustring += '<li class="rc-popout">Open In New Tab</li>';
|
||||
if (userid) {
|
||||
var options = '<ul><li class="changeP toCommons">commons</li> \
|
||||
<li class="changeP toPublic">public</li> \
|
||||
<li class="changeP toPrivate">private</li> \
|
||||
</ul>';
|
||||
|
||||
menustring += '<li class="rc-permission">Change permissions' + options + '</li>';
|
||||
}
|
||||
|
||||
menustring += '</ul>';
|
||||
rightclickmenu.innerHTML = menustring;
|
||||
|
@ -294,6 +317,13 @@ function selectNodeOnClickHandler(node, e) {
|
|||
win.focus();
|
||||
});
|
||||
|
||||
// change the permission of all the selected nodes and synapses that you were the originator of
|
||||
$('.rc-permission li').click(function() {
|
||||
$('.rightclickmenu').remove();
|
||||
// $(this).text() will be 'commons' 'public' or 'private'
|
||||
updateSelectedPermissions( $(this).text() );
|
||||
});
|
||||
|
||||
} //selectNodeOnRightClickHandler
|
||||
|
||||
function canvasDoubleClickHandler(canvasLoc,e) {
|
||||
|
@ -533,3 +563,45 @@ function touchPanZoomHandler(eventInfo, e) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
function updateSelectedPermissions(permission) {
|
||||
|
||||
|
||||
if ( $('.notice.metamaps').length == 0 ) {
|
||||
$('body').prepend('<div class="notice metamaps" />');
|
||||
}
|
||||
$('.notice.metamaps').hide().html('Working...').fadeIn('fast');
|
||||
|
||||
// variables to keep track of how many nodes and synapses you had the ability to change the permission of
|
||||
var nCount = 0, sCount = 0;
|
||||
|
||||
// change the permission of the selected synapses, if logged in user is the original creator
|
||||
var l = MetamapsModel.selectedEdges.length;
|
||||
for (var i = l-1; i >= 0; i -= 1) {
|
||||
var edge = MetamapsModel.selectedEdges[i];
|
||||
|
||||
if (edge.getData('userid') == userid) {
|
||||
updateSynapsePermission(edge,permission);
|
||||
sCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// change the permission of the selected topics, if logged in user is the original creator
|
||||
var l = MetamapsModel.selectedNodes.length;
|
||||
for (var i = l-1; i >= 0; i -= 1) {
|
||||
var node = MetamapsModel.selectedNodes[i];
|
||||
|
||||
if (node.getData('userid') == userid) {
|
||||
updateTopicPermission(node,permission);
|
||||
nCount++;
|
||||
}
|
||||
}
|
||||
|
||||
var nString = nCount == 1 ? (nCount.toString() + ' topic and ') : (nCount.toString() + ' topics and ');
|
||||
var sString = sCount == 1 ? (sCount.toString() + ' synapse') : (sCount.toString() + ' synapses');
|
||||
|
||||
$('.notice.metamaps').html(nString + sString + ' you created updated to ' + permission)
|
||||
setTimeout( function() {
|
||||
$('.notice.metamaps').fadeOut('fast');
|
||||
}, 8000);
|
||||
}
|
||||
|
|
|
@ -1291,13 +1291,13 @@ left: 13px;
|
|||
color: black;
|
||||
}
|
||||
|
||||
.rightclickmenu > ul {
|
||||
.rightclickmenu ul {
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.rightclickmenu ul li {
|
||||
list-style: none;
|
||||
padding: 3px 45px 3px 30px;
|
||||
padding: 3px 10px 3px 30px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 17px;
|
||||
line-height: 17px;
|
||||
|
@ -1305,8 +1305,14 @@ background-repeat: no-repeat;
|
|||
background-size: 20px 20px;
|
||||
background-position: 5px 2px;
|
||||
}
|
||||
.rightclickmenu ul li:nth-child(odd){
|
||||
background-color: #FFF;
|
||||
}
|
||||
.rightclickmenu ul li:nth-child(even){
|
||||
background-color: #EEE;
|
||||
}
|
||||
.rightclickmenu ul li:hover {
|
||||
background-color: #e4e4e4;
|
||||
background-color: #BBB;
|
||||
background-position: 7px 2px;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
@ -1322,6 +1328,33 @@ background-position: 5px 2px;
|
|||
.rightclickmenu .rc-popout {
|
||||
background-image: url(MMCCicon_pop-out_black.png);
|
||||
}
|
||||
.rightclickmenu .rc-permission {
|
||||
background-image: url(MMCCicon_edit_permission_black.png);
|
||||
position:relative;
|
||||
}
|
||||
|
||||
.rightclickmenu .rc-permission ul {
|
||||
display:none;
|
||||
background:white;
|
||||
top: 0;
|
||||
left:100%;
|
||||
position:absolute;
|
||||
border-bottom-left-radius: 2px;
|
||||
border-bottom-right-radius: 2px;
|
||||
border-top-right-radius: 2px;
|
||||
}
|
||||
.rightclickmenu .rc-permission:hover ul {
|
||||
display:block;
|
||||
}
|
||||
.rightclickmenu .rc-permission .toCommons {
|
||||
background-image: url(MMCCicon_commons.png);
|
||||
}
|
||||
.rightclickmenu .rc-permission .toPublic {
|
||||
background-image: url(MMCCicon_public.png);
|
||||
}
|
||||
.rightclickmenu .rc-permission .toPrivate {
|
||||
background-image: url(MMCCicon_private.png);
|
||||
}
|
||||
|
||||
.rightclickmenu p {
|
||||
padding:7px;
|
||||
|
|
Loading…
Reference in a new issue