Merge pull request #668 from metamaps/fix/hide-addTopic-message-on-double-click
show/hide add a topic instructions more consistently
This commit is contained in:
commit
5649798e4b
5 changed files with 31 additions and 15 deletions
|
@ -98,7 +98,6 @@ _Backbone.Map = Backbone.Model.extend({
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/maps/' + this.id + '/contains.json',
|
url: '/maps/' + this.id + '/contains.json',
|
||||||
success: start,
|
success: start,
|
||||||
error: errorFunc,
|
|
||||||
async: false
|
async: false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* global Metamaps, $ */
|
/* global Metamaps, $ */
|
||||||
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
import outdent from 'outdent'
|
||||||
|
|
||||||
import Active from './Active'
|
import Active from './Active'
|
||||||
import Filter from './Filter'
|
import Filter from './Filter'
|
||||||
|
@ -52,9 +53,8 @@ const Control = {
|
||||||
|
|
||||||
var n = Selected.Nodes.length
|
var n = Selected.Nodes.length
|
||||||
var e = Selected.Edges.length
|
var e = Selected.Edges.length
|
||||||
var ntext = n == 1 ? '1 topic' : n + ' topics'
|
var ntext = n === 1 ? '1 topic' : n + ' topics'
|
||||||
var etext = e == 1 ? '1 synapse' : e + ' synapses'
|
var etext = e === 1 ? '1 synapse' : e + ' synapses'
|
||||||
var text = 'You have ' + ntext + ' and ' + etext + ' selected. '
|
|
||||||
|
|
||||||
var authorized = Active.Map.authorizeToEdit(Active.Mapper)
|
var authorized = Active.Map.authorizeToEdit(Active.Mapper)
|
||||||
|
|
||||||
|
@ -63,11 +63,18 @@ const Control = {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var r = confirm(text + 'Are you sure you want to permanently delete them all? This will remove them from all maps they appear on.')
|
var r = confirm(outdent`
|
||||||
if (r == true) {
|
You have ${ntext} and ${etext} selected. Are you sure you want
|
||||||
|
to permanently delete them all? This will remove them from all
|
||||||
|
maps they appear on.`)
|
||||||
|
if (r) {
|
||||||
Control.deleteSelectedEdges()
|
Control.deleteSelectedEdges()
|
||||||
Control.deleteSelectedNodes()
|
Control.deleteSelectedNodes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Metamaps.Topics.length === 0) {
|
||||||
|
GlobalUI.showDiv('#instructions')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
deleteSelectedNodes: function () { // refers to deleting topics permanently
|
deleteSelectedNodes: function () { // refers to deleting topics permanently
|
||||||
if (!Active.Map) return
|
if (!Active.Map) return
|
||||||
|
@ -191,7 +198,7 @@ const Control = {
|
||||||
duration: 500
|
duration: 500
|
||||||
})
|
})
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (nodeid == Visualize.mGraph.root) { // && Visualize.type === "RGraph"
|
if (nodeid === Visualize.mGraph.root) { // && Visualize.type === "RGraph"
|
||||||
var newroot = _.find(graph.graph.nodes, function (n) { return n.id !== nodeid; })
|
var newroot = _.find(graph.graph.nodes, function (n) { return n.id !== nodeid; })
|
||||||
graph.root = newroot ? newroot.id : null
|
graph.root = newroot ? newroot.id : null
|
||||||
}
|
}
|
||||||
|
@ -231,7 +238,7 @@ const Control = {
|
||||||
color: Settings.colors.synapses.normal
|
color: Settings.colors.synapses.normal
|
||||||
})
|
})
|
||||||
|
|
||||||
if (Mouse.edgeHoveringOver == edge) {
|
if (Mouse.edgeHoveringOver === edge) {
|
||||||
edge.setDataset('current', {
|
edge.setDataset('current', {
|
||||||
showDesc: true,
|
showDesc: true,
|
||||||
lineWidth: 4
|
lineWidth: 4
|
||||||
|
@ -414,8 +421,8 @@ const Control = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var nString = nCount == 1 ? (nCount.toString() + ' topic and ') : (nCount.toString() + ' topics and ')
|
var nString = nCount === 1 ? (nCount.toString() + ' topic and ') : (nCount.toString() + ' topics and ')
|
||||||
var sString = sCount == 1 ? (sCount.toString() + ' synapse') : (sCount.toString() + ' synapses')
|
var sString = sCount === 1 ? (sCount.toString() + ' synapse') : (sCount.toString() + ' synapses')
|
||||||
|
|
||||||
var message = nString + sString + ' you created updated to ' + permission
|
var message = nString + sString + ' you created updated to ' + permission
|
||||||
GlobalUI.notifyUser(message)
|
GlobalUI.notifyUser(message)
|
||||||
|
@ -444,7 +451,7 @@ const Control = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var nString = nCount == 1 ? (nCount.toString() + ' topic') : (nCount.toString() + ' topics')
|
var nString = nCount === 1 ? (nCount.toString() + ' topic') : (nCount.toString() + ' topics')
|
||||||
|
|
||||||
var message = nString + ' you can edit updated to ' + metacode.get('name')
|
var message = nString + ' you can edit updated to ' + metacode.get('name')
|
||||||
GlobalUI.notifyUser(message)
|
GlobalUI.notifyUser(message)
|
||||||
|
|
|
@ -13,6 +13,7 @@ import GlobalUI from './GlobalUI'
|
||||||
* Dependencies:
|
* Dependencies:
|
||||||
* - Metamaps.Backbone
|
* - Metamaps.Backbone
|
||||||
* - Metamaps.Metacodes
|
* - Metamaps.Metacodes
|
||||||
|
* - Metamaps.Topics
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Create = {
|
const Create = {
|
||||||
|
@ -223,8 +224,10 @@ const Create = {
|
||||||
})
|
})
|
||||||
Create.newTopic.beingCreated = true
|
Create.newTopic.beingCreated = true
|
||||||
Create.newTopic.name = ''
|
Create.newTopic.name = ''
|
||||||
|
GlobalUI.hideDiv('#instructions')
|
||||||
},
|
},
|
||||||
hide: function (force) {
|
hide: function (force) {
|
||||||
|
if (Create.newTopic.beingCreated === false) return
|
||||||
if (force || !Create.newTopic.pinned) {
|
if (force || !Create.newTopic.pinned) {
|
||||||
$('#new_topic').fadeOut('fast')
|
$('#new_topic').fadeOut('fast')
|
||||||
Create.newTopic.beingCreated = false
|
Create.newTopic.beingCreated = false
|
||||||
|
@ -234,6 +237,9 @@ const Create = {
|
||||||
Create.newTopic.pinned = false
|
Create.newTopic.pinned = false
|
||||||
}
|
}
|
||||||
$('#topic_name').typeahead('val', '')
|
$('#topic_name').typeahead('val', '')
|
||||||
|
if (Metamaps.Topics.length === 0) {
|
||||||
|
GlobalUI.showDiv('#instructions')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
newSynapse: {
|
newSynapse: {
|
||||||
|
|
|
@ -148,11 +148,14 @@ const JIT = {
|
||||||
if (Metamaps.Mappings) Metamaps.Mappings.remove(mapping)
|
if (Metamaps.Mappings) Metamaps.Mappings.remove(mapping)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// set up addTopic instructions in case they delete all the topics
|
||||||
|
// i.e. if there are 0 topics at any time, it should have instructions again
|
||||||
|
$('#instructions div').hide()
|
||||||
|
if (Metamaps.Active.Map.authorizeToEdit(Active.Mapper)) {
|
||||||
|
$('#instructions div.addTopic').show()
|
||||||
|
}
|
||||||
|
|
||||||
if (self.vizData.length == 0) {
|
if (self.vizData.length == 0) {
|
||||||
$('#instructions div').hide()
|
|
||||||
if (Metamaps.Active.Map.authorizeToEdit(Active.Mapper)) {
|
|
||||||
$('#instructions div.addTopic').show()
|
|
||||||
}
|
|
||||||
GlobalUI.showDiv('#instructions')
|
GlobalUI.showDiv('#instructions')
|
||||||
Visualize.loadLater = true
|
Visualize.loadLater = true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"csv-parse": "1.1.7",
|
"csv-parse": "1.1.7",
|
||||||
"lodash": "4.16.1",
|
"lodash": "4.16.1",
|
||||||
"node-uuid": "1.4.7",
|
"node-uuid": "1.4.7",
|
||||||
|
"outdent": "0.2.1",
|
||||||
"react": "15.3.2",
|
"react": "15.3.2",
|
||||||
"react-dom": "15.3.2",
|
"react-dom": "15.3.2",
|
||||||
"socket.io": "0.9.12",
|
"socket.io": "0.9.12",
|
||||||
|
|
Loading…
Reference in a new issue