Merge pull request #589 from metamaps/feature/topicview-remove-topics

enable removal of topics from topic view - fixes #467
This commit is contained in:
Devin Howard 2016-08-08 21:46:15 +08:00 committed by GitHub
commit 3b24165fd0
2 changed files with 18 additions and 14 deletions

View file

@ -111,6 +111,14 @@ Metamaps.Control = {
} }
}, },
removeSelectedNodes: function () { // refers to removing topics permanently from a map removeSelectedNodes: function () { // refers to removing topics permanently from a map
if (Metamaps.Active.Topic) {
// hideNode will handle synapses as well
_.each(Metamaps.Selected.Nodes, function(node) {
Metamaps.Control.hideNode(node.id)
Metamaps.Topics.remove(node.id)
})
return
}
if (!Metamaps.Active.Map) return if (!Metamaps.Active.Map) return
var l = Metamaps.Selected.Nodes.length, var l = Metamaps.Selected.Nodes.length,
@ -285,12 +293,13 @@ Metamaps.Control = {
} }
}, },
removeSelectedEdges: function () { removeSelectedEdges: function () {
// Topic view is handled by removeSelectedNodes
if (!Metamaps.Active.Map) return
var l = Metamaps.Selected.Edges.length, var l = Metamaps.Selected.Edges.length,
i, i,
edge edge
if (!Metamaps.Active.Map) return
var authorized = Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper) var authorized = Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper)
if (!authorized) { if (!authorized) {

View file

@ -1332,6 +1332,7 @@ Metamaps.JIT = {
if (Metamaps.Active.Map) menustring += '<li class="rc-hide"><div class="rc-icon"></div>Hide until refresh<div class="rc-keyboard">Ctrl+H</div></li>' if (Metamaps.Active.Map) menustring += '<li class="rc-hide"><div class="rc-icon"></div>Hide until refresh<div class="rc-keyboard">Ctrl+H</div></li>'
if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '<li class="rc-remove ' + disabled + '"><div class="rc-icon"></div>Remove from map<div class="rc-keyboard">Ctrl+M</div></li>' if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '<li class="rc-remove ' + disabled + '"><div class="rc-icon"></div>Remove from map<div class="rc-keyboard">Ctrl+M</div></li>'
if (Metamaps.Active.Topic) menustring += '<li class="rc-remove"><div class="rc-icon"></div>Remove from view<div class="rc-keyboard">Ctrl+M</div></li>'
if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '<li class="rc-delete ' + disabled + '"><div class="rc-icon"></div>Delete<div class="rc-keyboard">Ctrl+D</div></li>' if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '<li class="rc-delete ' + disabled + '"><div class="rc-icon"></div>Delete<div class="rc-keyboard">Ctrl+D</div></li>'
if (Metamaps.Active.Topic) { if (Metamaps.Active.Topic) {
@ -1416,7 +1417,7 @@ Metamaps.JIT = {
} }
// remove the selected things from the map // remove the selected things from the map
if (authorized) { if (Metamaps.Active.Topic || authorized) {
$('.rc-remove').click(function () { $('.rc-remove').click(function () {
$('.rightclickmenu').remove() $('.rightclickmenu').remove()
Metamaps.Control.removeSelectedEdges() Metamaps.Control.removeSelectedEdges()
@ -1459,11 +1460,11 @@ Metamaps.JIT = {
}) })
// fetch relatives // fetch relatives
var fetched = false var fetch_sent = false
$('.rc-siblings').hover(function () { $('.rc-siblings').hover(function () {
if (!fetched) { if (!fetch_sent) {
Metamaps.JIT.populateRightClickSiblings(node) Metamaps.JIT.populateRightClickSiblings(node)
fetched = true fetch_sent = true
} }
}) })
$('.rc-siblings .fetchAll').click(function () { $('.rc-siblings .fetchAll').click(function () {
@ -1476,13 +1477,6 @@ Metamaps.JIT = {
var self = Metamaps.JIT var self = Metamaps.JIT
// depending on how many topics are selected, do different things // depending on how many topics are selected, do different things
/*if (Metamaps.Selected.Nodes.length > 1) {
// we don't bother filling the submenu with
// specific numbers, because there are too many topics
// selected to find those numbers
$('#loadingSiblings').remove()
return
}*/
var topic = node.getData('topic') var topic = node.getData('topic')
@ -1513,7 +1507,7 @@ Metamaps.JIT = {
} }
$.ajax({ $.ajax({
type: 'Get', type: 'GET',
url: '/topics/' + topic.id + '/relative_numbers.json?network=' + topics_string, url: '/topics/' + topic.id + '/relative_numbers.json?network=' + topics_string,
success: successCallback, success: successCallback,
error: function () {} error: function () {}
@ -1586,6 +1580,7 @@ Metamaps.JIT = {
if (Metamaps.Active.Map) menustring += '<li class="rc-hide"><div class="rc-icon"></div>Hide until refresh<div class="rc-keyboard">Ctrl+H</div></li>' if (Metamaps.Active.Map) menustring += '<li class="rc-hide"><div class="rc-icon"></div>Hide until refresh<div class="rc-keyboard">Ctrl+H</div></li>'
if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '<li class="rc-remove ' + disabled + '"><div class="rc-icon"></div>Remove from map<div class="rc-keyboard">Ctrl+M</div></li>' if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '<li class="rc-remove ' + disabled + '"><div class="rc-icon"></div>Remove from map<div class="rc-keyboard">Ctrl+M</div></li>'
if (Metamaps.Active.Topic) menustring += '<li class="rc-remove"><div class="rc-icon"></div>Remove from view<div class="rc-keyboard">Ctrl+M</div></li>'
if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '<li class="rc-delete ' + disabled + '"><div class="rc-icon"></div>Delete<div class="rc-keyboard">Ctrl+D</div></li>' if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '<li class="rc-delete ' + disabled + '"><div class="rc-icon"></div>Delete<div class="rc-keyboard">Ctrl+D</div></li>'
if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '<li class="rc-spacer"></li>' if (Metamaps.Active.Map && Metamaps.Active.Mapper) menustring += '<li class="rc-spacer"></li>'