enable removal of topics from topic view - fixes #467

This commit is contained in:
Devin Howard 2016-08-07 15:34:30 +08:00
parent 52cbd57367
commit 5510cb2e99
3 changed files with 20 additions and 14 deletions

View file

@ -111,6 +111,14 @@ Metamaps.Control = {
}
},
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
var l = Metamaps.Selected.Nodes.length,
@ -285,12 +293,13 @@ Metamaps.Control = {
}
},
removeSelectedEdges: function () {
// Topic view is handled by removeSelectedNodes
if (!Metamaps.Active.Map) return
var l = Metamaps.Selected.Edges.length,
i,
edge
if (!Metamaps.Active.Map) return
var authorized = Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper)
if (!authorized) {

View file

@ -1313,6 +1313,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 && 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.Topic) {
@ -1397,7 +1398,7 @@ Metamaps.JIT = {
}
// remove the selected things from the map
if (authorized) {
if (Metamaps.Active.Topic || authorized) {
$('.rc-remove').click(function () {
$('.rightclickmenu').remove()
Metamaps.Control.removeSelectedEdges()
@ -1440,11 +1441,11 @@ Metamaps.JIT = {
})
// fetch relatives
var fetched = false
var fetch_sent = false
$('.rc-siblings').hover(function () {
if (!fetched) {
if (!fetch_sent) {
Metamaps.JIT.populateRightClickSiblings(node)
fetched = true
fetch_sent = true
}
})
$('.rc-siblings .fetchAll').click(function () {
@ -1457,13 +1458,6 @@ Metamaps.JIT = {
var self = Metamaps.JIT
// 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')
@ -1494,7 +1488,7 @@ Metamaps.JIT = {
}
$.ajax({
type: 'Get',
type: 'GET',
url: '/topics/' + topic.id + '/relative_numbers.json?network=' + topics_string,
success: successCallback,
error: function () {}
@ -1567,6 +1561,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 && 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-spacer"></li>'

View file

@ -673,6 +673,8 @@ Metamaps.Map.InfoBox = {
return string
},
updateNumbers: function () {
if (!Metamaps.Active.Map) return
var self = Metamaps.Map.InfoBox
var mapper = Metamaps.Active.Mapper
var relevantPeople = Metamaps.Active.Map.get('permission') === 'commons' ? Metamaps.Mappers : Metamaps.Collaborators