parent
b52523e7be
commit
658f102a4e
2 changed files with 18 additions and 10 deletions
|
@ -194,6 +194,7 @@ const Create = {
|
||||||
|
|
||||||
// tell the autocomplete to submit the form with the topic you clicked on if you pick from the autocomplete
|
// tell the autocomplete to submit the form with the topic you clicked on if you pick from the autocomplete
|
||||||
$('#topic_name').bind('typeahead:select', function (event, datum, dataset) {
|
$('#topic_name').bind('typeahead:select', function (event, datum, dataset) {
|
||||||
|
Create.newTopic.beingCreated = false
|
||||||
if (datum.rtype === 'topic') {
|
if (datum.rtype === 'topic') {
|
||||||
Topic.getTopicFromAutocomplete(datum.id)
|
Topic.getTopicFromAutocomplete(datum.id)
|
||||||
} else if (datum.rtype === 'map') {
|
} else if (datum.rtype === 'map') {
|
||||||
|
@ -235,19 +236,20 @@ const Create = {
|
||||||
GlobalUI.hideDiv('#instructions')
|
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
|
|
||||||
}
|
}
|
||||||
if (force) {
|
if (force) {
|
||||||
$('.pinCarousel').removeClass('isPinned')
|
$('.pinCarousel').removeClass('isPinned')
|
||||||
Create.newTopic.pinned = false
|
Create.newTopic.pinned = false
|
||||||
}
|
}
|
||||||
$('#topic_name').typeahead('val', '')
|
|
||||||
if (Metamaps.Topics.length === 0) {
|
if (Metamaps.Topics.length === 0) {
|
||||||
GlobalUI.showDiv('#instructions')
|
GlobalUI.showDiv('#instructions')
|
||||||
}
|
}
|
||||||
|
Create.newTopic.beingCreated = false
|
||||||
|
},
|
||||||
|
reset: function () {
|
||||||
|
$('#topic_name').typeahead('val', '')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
newSynapse: {
|
newSynapse: {
|
||||||
|
|
|
@ -330,16 +330,21 @@ const Topic = {
|
||||||
Metamaps.Mappings.add(mapping)
|
Metamaps.Mappings.add(mapping)
|
||||||
|
|
||||||
// these can't happen until the value is retrieved, which happens in the line above
|
// these can't happen until the value is retrieved, which happens in the line above
|
||||||
Create.newTopic.hide()
|
if (!Create.newTopic.pinned) Create.newTopic.hide()
|
||||||
|
Create.newTopic.reset()
|
||||||
|
|
||||||
self.renderTopic(mapping, topic, true, true) // this function also includes the creation of the topic in the database
|
self.renderTopic(mapping, topic, true, true) // this function also includes the creation of the topic in the database
|
||||||
},
|
},
|
||||||
getTopicFromAutocomplete: function (id) {
|
getTopicFromAutocomplete: function (id) {
|
||||||
var self = Topic
|
var self = Topic
|
||||||
|
|
||||||
|
// hide the 'double-click to add a topic' message
|
||||||
|
GlobalUI.hideDiv('#instructions')
|
||||||
|
|
||||||
$(document).trigger(Map.events.editedByActiveMapper)
|
$(document).trigger(Map.events.editedByActiveMapper)
|
||||||
|
|
||||||
Create.newTopic.hide()
|
if (!Create.newTopic.pinned) Create.newTopic.hide()
|
||||||
|
Create.newTopic.reset()
|
||||||
|
|
||||||
self.get(id, (topic) => {
|
self.get(id, (topic) => {
|
||||||
if (Create.newTopic.pinned) {
|
if (Create.newTopic.pinned) {
|
||||||
|
@ -354,18 +359,16 @@ const Topic = {
|
||||||
Metamaps.Mappings.add(mapping)
|
Metamaps.Mappings.add(mapping)
|
||||||
|
|
||||||
self.renderTopic(mapping, topic, true, true)
|
self.renderTopic(mapping, topic, true, true)
|
||||||
|
// this blocked the enterKeyHandler from creating a new topic as well
|
||||||
|
if (Create.newTopic.pinned) Create.newTopic.beingCreated = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getMapFromAutocomplete: function (data) {
|
getMapFromAutocomplete: function (data) {
|
||||||
var self = Metamaps.Topic
|
var self = Metamaps.Topic
|
||||||
|
|
||||||
// hide the 'double-click to add a topic' message
|
|
||||||
Metamaps.GlobalUI.hideDiv('#instructions')
|
|
||||||
|
|
||||||
$(document).trigger(Metamaps.Map.events.editedByActiveMapper)
|
$(document).trigger(Metamaps.Map.events.editedByActiveMapper)
|
||||||
|
|
||||||
var metacode = Metamaps.Metacodes.findWhere({ name: 'Metamap' })
|
var metacode = Metamaps.Metacodes.findWhere({ name: 'Metamap' })
|
||||||
|
|
||||||
var topic = new Metamaps.Backbone.Topic({
|
var topic = new Metamaps.Backbone.Topic({
|
||||||
name: data.name,
|
name: data.name,
|
||||||
metacode_id: metacode.id,
|
metacode_id: metacode.id,
|
||||||
|
@ -383,9 +386,12 @@ const Topic = {
|
||||||
Metamaps.Mappings.add(mapping)
|
Metamaps.Mappings.add(mapping)
|
||||||
|
|
||||||
// these can't happen until the value is retrieved, which happens in the line above
|
// these can't happen until the value is retrieved, which happens in the line above
|
||||||
Metamaps.Create.newTopic.hide()
|
if (!Create.newTopic.pinned) Create.newTopic.hide()
|
||||||
|
Create.newTopic.reset()
|
||||||
|
|
||||||
self.renderTopic(mapping, topic, true, true) // this function also includes the creation of the topic in the database
|
self.renderTopic(mapping, topic, true, true) // this function also includes the creation of the topic in the database
|
||||||
|
// this blocked the enterKeyHandler from creating a new topic as well
|
||||||
|
if (Create.newTopic.pinned) Create.newTopic.beingCreated = true
|
||||||
},
|
},
|
||||||
getTopicFromSearch: function (event, id) {
|
getTopicFromSearch: function (event, id) {
|
||||||
var self = Topic
|
var self = Topic
|
||||||
|
|
Loading…
Reference in a new issue