synapse autocomplete working
This commit is contained in:
parent
8749ba8bbe
commit
fdcee3ae40
41 changed files with 436 additions and 279 deletions
BIN
app/assets/images/MMCCicon_realtime_blue.png
Normal file
BIN
app/assets/images/MMCCicon_realtime_blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
BIN
app/assets/images/images/ui-icons_222222_256x240.png
Normal file
BIN
app/assets/images/images/ui-icons_222222_256x240.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
|
@ -53,12 +53,7 @@ function nodeDoubleClickHandler(node, e) {
|
|||
openNodeShowcard(node);
|
||||
}
|
||||
|
||||
function enterKeyHandler() {
|
||||
|
||||
// if the metacode spinner is open, create topic when enter is pressed
|
||||
if ( $('.new_topic').css('display') != 'none' ) {
|
||||
$('.new_topic').submit();
|
||||
}
|
||||
function enterKeyHandler(event) {
|
||||
|
||||
//var selectedNodesCopy = MetamapsModel.selectedNodes.slice(0);
|
||||
//var len = selectedNodesCopy.length;
|
||||
|
|
|
@ -155,6 +155,9 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
|
|||
$('.sidebarSearchField').typeahead([
|
||||
{
|
||||
name: 'topics',
|
||||
dupChecker: function (datum1,datum2) {
|
||||
return false;
|
||||
},
|
||||
template: $('.topicTemplate').html(),
|
||||
remote: {
|
||||
url: '/search/topics?term=%QUERY',
|
||||
|
@ -169,6 +172,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
|
|||
if (dataset.length == 0) {
|
||||
dataset.push({
|
||||
value: "No results",
|
||||
label: "No results",
|
||||
typeImageURL: "/assets/wildcard.png",
|
||||
rtype: "noresult"
|
||||
});
|
||||
|
@ -181,6 +185,9 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
|
|||
},
|
||||
{
|
||||
name: 'maps',
|
||||
dupChecker: function (datum1,datum2) {
|
||||
return false;
|
||||
},
|
||||
template: $('.mapTemplate').html(),
|
||||
remote: {
|
||||
url: '/search/maps?term=%QUERY',
|
||||
|
@ -195,6 +202,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
|
|||
if (dataset.length == 0) {
|
||||
dataset.push({
|
||||
value: "No results",
|
||||
label: "No results",
|
||||
rtype: "noresult"
|
||||
});
|
||||
}
|
||||
|
@ -206,6 +214,9 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
|
|||
},
|
||||
{
|
||||
name: 'mappers',
|
||||
dupChecker: function (datum1,datum2) {
|
||||
return false;
|
||||
},
|
||||
template: $('.mapperTemplate').html(),
|
||||
remote: {
|
||||
url: '/search/mappers?term=%QUERY',
|
||||
|
@ -213,6 +224,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
|
|||
if (dataset.length == 0) {
|
||||
dataset.push({
|
||||
value: "No results",
|
||||
label: "No results",
|
||||
rtype: "noresult"
|
||||
});
|
||||
}
|
||||
|
@ -353,32 +365,82 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
|
|||
bindAccountHover();
|
||||
|
||||
// disable right click events on the new topic and new synapse input fields
|
||||
$('#new_topic, #new_synapse').bind('contextmenu', function(e){
|
||||
return false;
|
||||
});
|
||||
//$('#new_topic, #new_synapse').bind('contextmenu', function(e){
|
||||
// return false;
|
||||
//});
|
||||
|
||||
// initialize the autocomplete results for the metacode spinner
|
||||
$('#topic_name').typeahead([
|
||||
{
|
||||
name: 'topic_autocomplete',
|
||||
template: '<img class="autocompleteSection topicType" width="22" height="22" src="{{typeImageURL}}" alt="{{type}}" title="{{type}}"/><p class="autocompleteSection topicTitle">{{value}}</p><div class="autocompleteSection topicPermission {{permission}}"></div><div class="autocompleteSection topicOriginatorIcon hoverForTip"><span class="tip topicOriginator">{{originator}}</span></div><div class="clearfloat"></div>',
|
||||
dupChecker: function (datum1,datum2) {
|
||||
return false;
|
||||
},
|
||||
template: '<img class="autocompleteSection topicType" width="22" height="22" src="{{typeImageURL}}" alt="{{type}}" title="{{type}}"/><p class="autocompleteSection topicTitle">{{label}}</p><div class="autocompleteSection topicPermission {{permission}}"></div><div class="autocompleteSection topicOriginatorIcon hoverForTip"><span class="tip topicOriginator">{{originator}}</span></div><div class="clearfloat"></div>',
|
||||
remote: {
|
||||
url: '/topics/autocomplete_topic?term=%QUERY'
|
||||
},
|
||||
engine: Hogan
|
||||
}
|
||||
]);
|
||||
$('#topic_name').bind('typeahead:autocompleted', function (event, datum, dataset) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
});
|
||||
// tell the autocomplete to submit the form with the topic you clicked on if you pick from the autocomplete
|
||||
$('#topic_name').bind('typeahead:selected', function (event, datum, dataset) {
|
||||
$('#topic_grabTopic').val(datum.id);
|
||||
$('.new_topic').submit();
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
});
|
||||
// bind keyboard handlers
|
||||
$('#topic_name').bind('keyup', function(e) {
|
||||
switch(e.which) {
|
||||
case 13:
|
||||
$('.new_topic').submit();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
});
|
||||
|
||||
// initialize the autocomplete results for the metacode spinner
|
||||
$('#synapse_desc').typeahead([
|
||||
{
|
||||
name: 'synapse_autocomplete',
|
||||
template: "{{label}}",
|
||||
remote: {
|
||||
url: '/search/synapses?term=%QUERY'
|
||||
},
|
||||
engine: Hogan
|
||||
},
|
||||
{
|
||||
name: 'existing_synapses',
|
||||
limit: 50,
|
||||
template: $('.synapseTemplate').html(),
|
||||
remote: {
|
||||
url: '/search/synapses',
|
||||
replace: function () {
|
||||
var q = '/search/synapses?topic1id=' + $('#synapse_topic1id').val() + '&topic2id=' + $('#synapse_topic2id').val();
|
||||
return q;
|
||||
}
|
||||
},
|
||||
engine: Hogan,
|
||||
header: "<h3>Existing Synapses</h3>"
|
||||
},
|
||||
]);
|
||||
// tell the autocomplete to submit the form with the topic you clicked on if you pick from the autocomplete
|
||||
$('#synapse_desc').bind('typeahead:selected', function (event, datum, dataset) {
|
||||
if (datum.id) { // if they clicked on an existing synapse get it
|
||||
$('#synapse_grabSynapse').val(datum.id);
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
});
|
||||
// bind keyboard handlers
|
||||
$('#synapse_desc').bind('keyup', function(e) {
|
||||
switch(e.which) {
|
||||
case 13:
|
||||
$('.new_synapse').submit();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
});
|
||||
|
||||
// when either form submits, don't leave the page
|
||||
$('.new_topic, .new_synapse').bind('submit', function(event, data){
|
||||
|
@ -442,7 +504,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
|
|||
// bind keyboard handlers
|
||||
$('body').bind('keyup', function(e) {
|
||||
switch(e.which) {
|
||||
case 13: enterKeyHandler(); break;
|
||||
case 13: enterKeyHandler(e); break;
|
||||
case 27: escKeyHandler(); break;
|
||||
default: break; //console.log(e.which);
|
||||
}
|
||||
|
|
|
@ -293,6 +293,36 @@ font-family: 'LatoLight';
|
|||
margin-left:90px;
|
||||
}
|
||||
|
||||
/* synapse autocomplete */
|
||||
|
||||
.new_topic #topic_name, .new_topic .tt-hint {
|
||||
width: 190px;
|
||||
background: rgba(0,0,0,0.8);
|
||||
height: 25px;
|
||||
margin: 0;
|
||||
padding: 5px 5px;
|
||||
border: 1px solid black;
|
||||
outline: none;
|
||||
font-size: 25px;
|
||||
line-height: 35px;
|
||||
color: rgba(255,255,255,0.7);
|
||||
font-family: 'LatoLight';
|
||||
}
|
||||
|
||||
.new_synapse #synapse_desc, .new_synapse .tt-hint {
|
||||
width: 200px;
|
||||
background: rgba(0,0,0,0.8);
|
||||
height: 18px;
|
||||
margin: 0;
|
||||
padding: 5px 5px;
|
||||
border: 1px solid black;
|
||||
outline: none;
|
||||
font-size: 18px;
|
||||
line-height: 20px;
|
||||
color: rgba(255,255,255,0.7);
|
||||
font-family: 'LatoLight';
|
||||
}
|
||||
|
||||
label, select, input, textarea {
|
||||
display:block;
|
||||
}
|
||||
|
@ -770,6 +800,9 @@ background: rgba(0,0,0,0.7) url('MMCCicon_realtime_junto.png') no-repeat -3px -1
|
|||
background-size: 40px 40px;
|
||||
cursor:pointer;
|
||||
}
|
||||
.sidebarCollaborateIcon.blue {
|
||||
background: rgba(0,0,0,0.7) url('MMCCicon_realtime_blue.png') no-repeat -3px -1px;
|
||||
}
|
||||
.sidebarCollaborateBox {
|
||||
position:absolute;
|
||||
display:none;
|
||||
|
@ -1243,6 +1276,89 @@ background:rgba(0,0,0,0.7);
|
|||
z-index:100;
|
||||
}
|
||||
|
||||
/* topic autocomplete */
|
||||
|
||||
#new_synapse .tt-dropdown-menu {
|
||||
width: 212px;
|
||||
background:rgba(0,0,0,0.7);
|
||||
}
|
||||
|
||||
#new_synapse .tt-dropdown-menu h3 {
|
||||
font-family: 'vinyl',helvetica,sans-serif;
|
||||
text-transform: uppercase;
|
||||
font-style: italic;
|
||||
font-size: 14pxpx;
|
||||
line-height: 16px;
|
||||
margin: 3px;
|
||||
}
|
||||
|
||||
#new_synapse .tt-suggestion.tt-is-under-cursor {
|
||||
background: black;
|
||||
}
|
||||
|
||||
#new_synapse .tt-suggestion {
|
||||
padding: 5px;
|
||||
font-family: 'LatoLight';
|
||||
}
|
||||
|
||||
#new_synapse .autocompleteSection {
|
||||
float:left;
|
||||
}
|
||||
|
||||
#new_synapse .synapseDesc {
|
||||
width:162px;
|
||||
line-height:22px;
|
||||
}
|
||||
#new_synapse .synapsePermission {
|
||||
width:20px;
|
||||
height:20px;
|
||||
background-repeat:no-repeat;
|
||||
background-position:center center;
|
||||
background-size:16px 16px;
|
||||
}
|
||||
#new_synapse .synapsePermission.commons {
|
||||
background-image:url(MMCCicon_commons.png);
|
||||
}
|
||||
#new_synapse .synapsePermission.public {
|
||||
background-image:url(MMCCicon_public.png);
|
||||
}
|
||||
#new_synapse .synapsePermission.private {
|
||||
background-image:url(MMCCicon_private.png);
|
||||
}
|
||||
#new_synapse .synapseOriginatorIcon {
|
||||
position:relative;
|
||||
width:20px;
|
||||
height:20px;
|
||||
background-repeat:no-repeat;
|
||||
background-position:center center;
|
||||
background-size:16px 16px;
|
||||
background-image:url(MMCCicon_mapper.png);
|
||||
}
|
||||
#new_synapse .synapseOriginatorIcon:hover .tip {
|
||||
display:block;
|
||||
}
|
||||
#new_synapse .tip {
|
||||
display:none;
|
||||
position: absolute;
|
||||
background: white;
|
||||
width: auto;
|
||||
top: 0;
|
||||
left: 23px;
|
||||
color: black;
|
||||
white-space: nowrap;
|
||||
border-radius: 4px;
|
||||
font-size:13px !important;
|
||||
font-family:'LatoLight';
|
||||
line-height:14px;
|
||||
padding: 2px 5px 2px;
|
||||
border: 1px solid black;
|
||||
z-index:100;
|
||||
}
|
||||
|
||||
#new_synapse .tt-suggestion .resultnoresult .synapsePermission, #new_synapse .tt-suggestion .resultnoresult .synapseOriginatorIcon {
|
||||
display:none;
|
||||
}
|
||||
|
||||
|
||||
/* map info box */
|
||||
|
||||
|
|
|
@ -34,15 +34,6 @@ color: #000;
|
|||
z-index: 30;
|
||||
}
|
||||
|
||||
.synapseDesc {
|
||||
position:absolute;
|
||||
top:22px;
|
||||
left:8px;
|
||||
height:30px;
|
||||
padding:125px 0 125px 35px;
|
||||
background: url('synapse2.png') no-repeat 0 0;
|
||||
}
|
||||
|
||||
.synapseTopic2 {
|
||||
position:absolute;
|
||||
bottom:0;
|
||||
|
|
|
@ -2,6 +2,7 @@ class MainController < ApplicationController
|
|||
include TopicsHelper
|
||||
include MapsHelper
|
||||
include UsersHelper
|
||||
include SynapsesHelper
|
||||
|
||||
before_filter :require_user, only: [:invite]
|
||||
|
||||
|
@ -43,6 +44,20 @@ class MainController < ApplicationController
|
|||
#remove "topic:" if appended at beginning
|
||||
term = term[6..-1] if term.downcase[0..5] == "topic:"
|
||||
|
||||
#if desc: search desc instead
|
||||
desc = false
|
||||
if term.downcase[0..4] == "desc:"
|
||||
term = term[5..-1]
|
||||
desc = true
|
||||
end
|
||||
|
||||
#if link: search link instead
|
||||
link = false
|
||||
if term.downcase[0..4] == "link:"
|
||||
term = term[5..-1]
|
||||
link = true
|
||||
end
|
||||
|
||||
#check whether there's a filter by metacode as part of the query
|
||||
filterByMetacode = false
|
||||
Metacode.all.each do |m|
|
||||
|
@ -59,35 +74,48 @@ class MainController < ApplicationController
|
|||
if term == ""
|
||||
@topics = []
|
||||
else
|
||||
search = '%' + term.downcase + '%'
|
||||
search = term.downcase + '%'
|
||||
|
||||
if !user
|
||||
@topics = Topic.where('LOWER("name") like ? OR LOWER("desc") like ? OR LOWER("link") like ?', search, search, search).where('metacode_id = ?', filterByMetacode.id).order('"name"')
|
||||
@topics = Topic.where('LOWER("name") like ?', search).where('metacode_id = ?', filterByMetacode.id).order('"name"')
|
||||
#read this next line as 'delete a topic if its private and you're either 1. logged out or 2. logged in but not the topic creator
|
||||
@topics.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && @current.id != t.user_id)) }
|
||||
elsif user
|
||||
@topics = Topic.where('LOWER("name") like ? OR LOWER("desc") like ? OR LOWER("link") like ?', search, search, search).where('metacode_id = ?', filterByMetacode.id).where('user_id = ?', user).order('"name"')
|
||||
@topics = Topic.where('LOWER("name") like ?', search).where('metacode_id = ? AND user_id = ?', filterByMetacode.id, user).order('"name"')
|
||||
#read this next line as 'delete a topic if its private and you're either 1. logged out or 2. logged in but not the topic creator
|
||||
@topics.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && @current.id != t.user_id)) }
|
||||
end
|
||||
end
|
||||
else
|
||||
elsif desc
|
||||
search = '%' + term.downcase + '%'
|
||||
if !user
|
||||
@topics = Topic.where('LOWER("name") like ? OR LOWER("desc") like ? OR LOWER("link") like ?', search, search, search).order('"name"')
|
||||
elsif
|
||||
@topics = Topic.where('LOWER("name") like ? OR LOWER("desc") like ? OR LOWER("link") like ?', search, search, search).where('user_id = ?', user).order('"name"')
|
||||
@topics = Topic.where('LOWER("desc") like ?', search).order('"name"')
|
||||
elsif user
|
||||
@topics = Topic.where('LOWER("desc") like ?', search).where('user_id = ?', user).order('"name"')
|
||||
end
|
||||
elsif link
|
||||
search = '%' + term.downcase + '%'
|
||||
if !user
|
||||
@topics = Topic.where('LOWER("link") like ?', search).order('"name"')
|
||||
elsif user
|
||||
@topics = Topic.where('LOWER("link") like ?', search).where('user_id = ?', user).order('"name"')
|
||||
end
|
||||
else #regular case, just search the name
|
||||
search = term.downcase + '%'
|
||||
if !user
|
||||
@topics = Topic.where('LOWER("name") like ?', search).order('"name"')
|
||||
elsif user
|
||||
@topics = Topic.where('LOWER("name") like ?', search).where('user_id = ?', user).order('"name"')
|
||||
end
|
||||
end
|
||||
else
|
||||
@topics = []
|
||||
end
|
||||
|
||||
#read this next line as 'delete a topic if its private and you're either 1. logged out or 2. logged in but not the topic creator
|
||||
@topics.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && @current.id != t.user_id)) }
|
||||
|
||||
render json: autocomplete_array_json(@topics)
|
||||
#if params[:topics_by_user_id] != ""
|
||||
# @user = User.find(params[:topics_by_user_id])
|
||||
# @topics = @topics | Topic.visibleToUser(@current, @user)
|
||||
#end
|
||||
#if params[:topics_by_map_id] != ""
|
||||
# @map = Map.find(params[:topics_by_map_id])
|
||||
# @topics = @topics | @map.topics.delete_if{|topic| not topic.authorize_to_view(@current)}
|
||||
#end
|
||||
#@topics.sort! { |a,b| a.name.downcase <=> b.name.downcase }
|
||||
end
|
||||
|
||||
# get /search/maps?term=SOMETERM
|
||||
|
@ -102,25 +130,28 @@ class MainController < ApplicationController
|
|||
#remove "map:" if appended at beginning
|
||||
term = term[4..-1] if term.downcase[0..3] == "map:"
|
||||
|
||||
search = '%' + term.downcase + '%'
|
||||
#if desc: search desc instead
|
||||
desc = false
|
||||
if term.downcase[0..4] == "desc:"
|
||||
term = term[5..-1]
|
||||
desc = true
|
||||
end
|
||||
|
||||
search = term.downcase + '%'
|
||||
query = desc ? 'LOWER("desc") like ?' : 'LOWER("name") like ?'
|
||||
if !user
|
||||
@maps = Map.where('LOWER("name") like ? OR LOWER("desc") like ?', search, search).order('"name"')
|
||||
@maps = Map.where(query, search).limit(5).order('"name"')
|
||||
elsif user
|
||||
@maps = Map.where('LOWER("name") like ? OR LOWER("desc") like ?', search, search).where('user_id = ?', user).order('"name"')
|
||||
@maps = Map.where(query, search).where('user_id = ?', user).limit(5).order('"name"')
|
||||
end
|
||||
else
|
||||
@maps = []
|
||||
end
|
||||
|
||||
#read this next line as 'delete a map if its private and you're either 1. logged out or 2. logged in but not the map creator
|
||||
@maps.delete_if {|m| m.permission == "private" && (!authenticated? || (authenticated? && @current.id != m.user_id)) }
|
||||
|
||||
render json: autocomplete_map_array_json(@maps)
|
||||
#if params[:topics_by_user_id] != ""
|
||||
# @user = User.find(params[:topics_by_user_id])
|
||||
# @topics = @topics | Topic.visibleToUser(@current, @user)
|
||||
#end
|
||||
#if params[:topics_by_map_id] != ""
|
||||
# @map = Map.find(params[:topics_by_map_id])
|
||||
# @topics = @topics | @map.topics.delete_if{|topic| not topic.authorize_to_view(@current)}
|
||||
#end
|
||||
#@topics.sort! { |a,b| a.name.downcase <=> b.name.downcase }
|
||||
end
|
||||
|
||||
# get /search/mappers?term=SOMETERM
|
||||
|
@ -133,21 +164,42 @@ class MainController < ApplicationController
|
|||
#remove "mapper:" if appended at beginning
|
||||
term = term[7..-1] if term.downcase[0..6] == "mapper:"
|
||||
|
||||
@mappers = User.where('LOWER("name") like ?', '%' + term.downcase + '%').
|
||||
limit(10).order('"name"')
|
||||
@mappers = User.where('LOWER("name") like ?', term.downcase + '%').limit(5).order('"name"')
|
||||
else
|
||||
@mappers = []
|
||||
end
|
||||
render json: autocomplete_user_array_json(@mappers)
|
||||
#if params[:topics_by_user_id] != ""
|
||||
# @user = User.find(params[:topics_by_user_id])
|
||||
# @topics = @topics | Topic.visibleToUser(@current, @user)
|
||||
#end
|
||||
#if params[:topics_by_map_id] != ""
|
||||
# @map = Map.find(params[:topics_by_map_id])
|
||||
# @topics = @topics | @map.topics.delete_if{|topic| not topic.authorize_to_view(@current)}
|
||||
#end
|
||||
#@topics.sort! { |a,b| a.name.downcase <=> b.name.downcase }
|
||||
end
|
||||
|
||||
# get /search/synapses?term=SOMETERM OR
|
||||
# get /search/synapses?topic1id=SOMEID&topic2id=SOMEID
|
||||
def searchsynapses
|
||||
@current = current_user
|
||||
|
||||
term = params[:term]
|
||||
topic1id = params[:topic1id]
|
||||
topic2id = params[:topic2id]
|
||||
|
||||
if term && !term.empty?
|
||||
@synapses = Synapse.select('DISTINCT "desc"').
|
||||
where('LOWER("desc") like ?', term.downcase + '%').limit(5).order('"desc"')
|
||||
|
||||
render json: autocomplete_synapse_generic_json(@synapses)
|
||||
|
||||
elsif topic1id && !topic1id.empty?
|
||||
@one = Synapse.where('node1_id = ? AND node2_id = ?', topic1id, topic2id)
|
||||
@two = Synapse.where('node2_id = ? AND node1_id = ?', topic1id, topic2id)
|
||||
@synapses = @one + @two
|
||||
@synapses.sort! {|s1,s2| s1.desc <=> s2.desc }
|
||||
|
||||
#read this next line as 'delete a synapse if its private and you're either 1. logged out or 2. logged in but not the synapse creator
|
||||
@synapses.delete_if {|s| s.permission == "private" && (!authenticated? || (authenticated? && @current.id != s.user_id)) }
|
||||
|
||||
render json: autocomplete_synapse_array_json(@synapses)
|
||||
else
|
||||
@synapses = []
|
||||
render json: autocomplete_synapse_array_json(@synapses)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -5,18 +5,6 @@ class SynapsesController < ApplicationController
|
|||
|
||||
respond_to :html, :js, :json
|
||||
|
||||
def autocomplete_synapse_desc
|
||||
term = params[:term]
|
||||
if term && !term.empty?
|
||||
items = Synapse.select('DISTINCT "desc"').
|
||||
where('LOWER("desc") like ?', term.downcase + '%').
|
||||
limit(10).order('"desc"')
|
||||
else
|
||||
items = {}
|
||||
end
|
||||
render :json => json_for_autocomplete(items, :desc)
|
||||
end
|
||||
|
||||
# GET synapses
|
||||
# or GET users/:user_id/synapses
|
||||
def index
|
||||
|
@ -81,15 +69,22 @@ class SynapsesController < ApplicationController
|
|||
# POST synapses
|
||||
def create
|
||||
@user = current_user
|
||||
@synapse = Synapse.new()
|
||||
@synapse.desc = params[:synapse][:desc]
|
||||
@synapse.topic1 = Topic.find(params[:synapse][:topic1id])
|
||||
@synapse.topic2 = Topic.find(params[:synapse][:topic2id])
|
||||
@synapse.permission = "commons"
|
||||
@synapse.category = "from-to"
|
||||
@synapse.weight = 5
|
||||
@synapse.user = @user
|
||||
@synapse.save
|
||||
|
||||
# if the topic exists grab it and return it
|
||||
if params[:synapse][:grabSynapse] != "null"
|
||||
@synapse = Synapse.find(params[:synapse][:grabSynapse])
|
||||
# if not selecting an existing synapse, create it
|
||||
else
|
||||
@synapse = Synapse.new()
|
||||
@synapse.desc = params[:synapse][:desc]
|
||||
@synapse.topic1 = Topic.find(params[:synapse][:topic1id])
|
||||
@synapse.topic2 = Topic.find(params[:synapse][:topic2id])
|
||||
@synapse.permission = "commons"
|
||||
@synapse.category = "from-to"
|
||||
@synapse.weight = 5
|
||||
@synapse.user = @user
|
||||
@synapse.save
|
||||
end
|
||||
|
||||
if params[:synapse][:map]
|
||||
@map = Map.find(params[:synapse][:map])
|
||||
|
|
|
@ -12,12 +12,14 @@ class TopicsController < ApplicationController
|
|||
@current = current_user
|
||||
term = params[:term]
|
||||
if term && !term.empty?
|
||||
t = Topic.where('LOWER("name") like ?', term.downcase + '%').
|
||||
limit(10).order('"name"').visibleToUser(@current,nil)
|
||||
@topics = Topic.where('LOWER("name") like ?', term + '%').order('"name"')
|
||||
|
||||
#read this next line as 'delete a topic if its private and you're either 1. logged out or 2. logged in but not the topic creator
|
||||
@topics.delete_if {|t| t.permission == "private" && (!authenticated? || (authenticated? && @current.id != t.user_id)) }
|
||||
else
|
||||
t = []
|
||||
@topics = []
|
||||
end
|
||||
render json: autocomplete_array_json(t)
|
||||
render json: autocomplete_array_json(@topics)
|
||||
end
|
||||
|
||||
# GET topics
|
||||
|
|
|
@ -7,7 +7,7 @@ module MapsHelper
|
|||
map = {}
|
||||
map['id'] = m.id
|
||||
map['label'] = m.name
|
||||
map['value'] = m.name
|
||||
map['value'] = m.id
|
||||
map['description'] = m.desc.truncate(30)
|
||||
map['permission'] = m.permission
|
||||
map['topicCount'] = m.topics.count
|
||||
|
|
|
@ -1,2 +1,35 @@
|
|||
module SynapsesHelper
|
||||
|
||||
|
||||
## this one is for building our custom JSON autocomplete format for typeahead
|
||||
def autocomplete_synapse_generic_json(unique)
|
||||
temp = []
|
||||
unique.each do |s|
|
||||
synapse = {}
|
||||
synapse['label'] = s.desc
|
||||
synapse['value'] = s.desc
|
||||
|
||||
temp.push synapse
|
||||
end
|
||||
return temp
|
||||
end
|
||||
|
||||
## this one is for building our custom JSON autocomplete format for typeahead
|
||||
def autocomplete_synapse_array_json(synapses)
|
||||
temp = []
|
||||
synapses.each do |s|
|
||||
synapse = {}
|
||||
synapse['id'] = s.id
|
||||
synapse['label'] = s.desc
|
||||
synapse['value'] = s.id
|
||||
synapse['permission'] = s.permission
|
||||
synapse['mapCount'] = s.maps.count
|
||||
synapse['originator'] = s.user.name
|
||||
synapse['rtype'] = "synapse"
|
||||
|
||||
temp.push synapse
|
||||
end
|
||||
return temp
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -7,7 +7,7 @@ module TopicsHelper
|
|||
topic = {}
|
||||
topic['id'] = t.id
|
||||
topic['label'] = t.name
|
||||
topic['value'] = t.name
|
||||
topic['value'] = t.id
|
||||
topic['description'] = t.desc.truncate(35) # make this return matched results
|
||||
topic['type'] = t.metacode.name
|
||||
topic['typeImageURL'] = '/assets/' + t.metacode.icon
|
||||
|
|
|
@ -7,7 +7,7 @@ module UsersHelper
|
|||
user = {}
|
||||
user['id'] = u.id
|
||||
user['label'] = u.name
|
||||
user['value'] = u.name
|
||||
user['value'] = u.id
|
||||
user['mapCount'] = u.maps.count
|
||||
user['rtype'] = "mapper"
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<span class="metacodeTip">{{type}}</span>
|
||||
</div>
|
||||
<div class="resultText">
|
||||
<p class="resultTitle">{{value}}</p>
|
||||
<p class="resultTitle">{{label}}</p>
|
||||
<p class="resultDesc">{{description}}</p>
|
||||
</div>
|
||||
<div class="autoOptions">
|
||||
|
@ -48,7 +48,7 @@
|
|||
<div class="result{{rtype}}">
|
||||
<img class="icon" src="/assets/map.png">
|
||||
<div class="resultText">
|
||||
<p class="resultTitle">{{value}}</p>
|
||||
<p class="resultTitle">{{label}}</p>
|
||||
<p class="resultDesc">{{description}}</p>
|
||||
</div>
|
||||
<div class="autoOptions">
|
||||
|
@ -79,7 +79,7 @@
|
|||
<div class="result{{rtype}}">
|
||||
<img class="icon" width="28" height="28" src="/assets/MMCCicon_mapper.png">
|
||||
<div class="resultText">
|
||||
<p class="resultTitle">{{value}}</p>
|
||||
<p class="resultTitle">{{label}}</p>
|
||||
</div>
|
||||
<div class="autoOptions">
|
||||
<a href="/maps/mappers/{{id}}" target="_blank" class="goTo hoverForTip">
|
||||
|
@ -94,4 +94,15 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="synapseTemplate">
|
||||
<div class="result{{rtype}}">
|
||||
<p class="autocompleteSection synapseDesc">{{label}}</p>
|
||||
<div class="autocompleteSection synapsePermission {{permission}}"></div>
|
||||
<div class="autocompleteSection synapseOriginatorIcon hoverForTip">
|
||||
<span class="tip synapseOriginator">{{originator}}</span>
|
||||
</div>
|
||||
<div class="clearfloat"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -8,6 +8,7 @@
|
|||
<%= form.text_field :desc, :placeholder => "describe the connection..." %>
|
||||
<%= form.hidden_field :topic1id, :value => 0 %>
|
||||
<%= form.hidden_field :topic2id, :value => 0 %>
|
||||
<%= form.hidden_field :grabSynapse, :value => "null" %>
|
||||
<% if (@map.permission == "commons" && authenticated?) || @map.user == user %>
|
||||
<%= form.hidden_field :map, :value => @map.id %>
|
||||
<% end %>
|
||||
|
|
|
@ -205,6 +205,11 @@
|
|||
bindFilterHover();
|
||||
bindInfoHover();
|
||||
|
||||
$(".sidebarCollaborateIcon").click(function(event) {
|
||||
goRealtime = !goRealtime;
|
||||
$(".sidebarCollaborateIcon").toggleClass("blue");
|
||||
});
|
||||
|
||||
// initialize best_in_place editing
|
||||
$('.authenticated div.permission.canEdit .best_in_place').best_in_place();
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
#%>
|
||||
<div class="anypage">
|
||||
<%= form_for Synapse.new, url: synapses_url, remote: true do |form| %>
|
||||
<%= form.autocomplete_field :desc, autocomplete_synapse_desc_synapses_path, :placeholder => "Describe the connection..." %>
|
||||
<%= form.text_field :desc, :placeholder => "describe the connection..." %>
|
||||
<%= form.hidden_field :topic1id, :value => 0 %>
|
||||
<%= form.hidden_field :topic2id, :value => 0 %>
|
||||
<%= form.hidden_field :grabSynapse, :value => "null" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
* Javascript called when you create a new synapse.
|
||||
*/
|
||||
$('#new_synapse').fadeOut('fast');
|
||||
$('#synapse_desc').attr('value','');
|
||||
$('#synapse_desc').typeahead('setQuery','');
|
||||
$('#synapse_topic1id').attr('value','0');
|
||||
$('#synapse_topic2id').attr('value','0');
|
||||
$('#synapse_grabSynapse').attr('value','null');
|
||||
// reset the draw synapse positions to false
|
||||
MetamapsModel.synapseStartCoord = false;
|
||||
MetamapsModel.synapseEndCoord = false;
|
||||
|
|
|
@ -9,6 +9,7 @@ ISSAD::Application.routes.draw do
|
|||
match '/search/topics', to: 'main#searchtopics', via: :get, as: :searchtopics
|
||||
match '/search/maps', to: 'main#searchmaps', via: :get, as: :searchmaps
|
||||
match '/search/mappers', to: 'main#searchmappers', via: :get, as: :searchmappers
|
||||
match '/search/synapses', to: 'main#searchsynapses', via: :get, as: :searchsynapses
|
||||
|
||||
match 'maps/:id/savelayout', to: 'maps#savelayout', via: :put, as: :savelayout
|
||||
match 'topics/:map_id/:topic_id/removefrommap', to: 'topics#removefrommap', via: :post, as: :removefrommap
|
||||
|
@ -19,14 +20,10 @@ ISSAD::Application.routes.draw do
|
|||
end
|
||||
match 'topics/:id/:format', to: 'topics#json', via: :get, as: :json
|
||||
|
||||
resources :synapses do
|
||||
get :autocomplete_synapse_desc, :on => :collection
|
||||
end
|
||||
resources :synapses
|
||||
match 'synapses/:id/:format', to: 'synapses#json', via: :get, as: :json
|
||||
|
||||
resources :maps do
|
||||
get :autocomplete_map_name, :on => :collection
|
||||
end
|
||||
resources :maps
|
||||
match 'maps/:id/embed', to: 'maps#embed', via: :get, as: :embed
|
||||
match 'maps/:id/:format', to: 'maps#json', via: :get, as: :json
|
||||
|
||||
|
@ -36,7 +33,6 @@ ISSAD::Application.routes.draw do
|
|||
end
|
||||
|
||||
resources :users, except: :show do
|
||||
get :autocomplete_user_name, :on => :collection
|
||||
resources :topics, :only => [:index]
|
||||
resources :synapses, :only => [:index]
|
||||
resources :maps, :only => [:index]
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
BIN
public/assets/MMCCicon_realtime_blue.png
Normal file
BIN
public/assets/MMCCicon_realtime_blue.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
BIN
public/assets/application-d12d67de32a0eaa3c4067fb74d7124b8.js.gz
Normal file
BIN
public/assets/application-d12d67de32a0eaa3c4067fb74d7124b8.js.gz
Normal file
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
BIN
public/assets/images/ui-icons_222222_256x240.png
Normal file
BIN
public/assets/images/ui-icons_222222_256x240.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
|
@ -47,6 +47,8 @@ MMCCicon_private.png: MMCCicon_private-9de86555fbdb4a6acafb0082678c07bd.png
|
|||
MMCCicon_private/index.png: MMCCicon_private-9de86555fbdb4a6acafb0082678c07bd.png
|
||||
MMCCicon_public.png: MMCCicon_public-1f8e2ccd3461f477899c0e0adb8fe501.png
|
||||
MMCCicon_public/index.png: MMCCicon_public-1f8e2ccd3461f477899c0e0adb8fe501.png
|
||||
MMCCicon_realtime_blue.png: MMCCicon_realtime_blue-7d74516f638c995156bffae310aeed7a.png
|
||||
MMCCicon_realtime_blue/index.png: MMCCicon_realtime_blue-7d74516f638c995156bffae310aeed7a.png
|
||||
MMCCicon_realtime_junto.png: MMCCicon_realtime_junto-9264f28a0d186ea4b0b66140bcd8ec15.png
|
||||
MMCCicon_realtime_junto/index.png: MMCCicon_realtime_junto-9264f28a0d186ea4b0b66140bcd8ec15.png
|
||||
MMCCicon_remove_from_map_black.png: MMCCicon_remove_from_map_black-b4afbba1fce0be2535c05de7a9efde1c.png
|
||||
|
@ -109,6 +111,8 @@ home_bg2.png: home_bg2-c881acea5e56343b4abf117d435a3c5a.png
|
|||
home_bg2/index.png: home_bg2-c881acea5e56343b4abf117d435a3c5a.png
|
||||
idea.png: idea-e06b6d614672688a3024b5f13feca166.png
|
||||
idea/index.png: idea-e06b6d614672688a3024b5f13feca166.png
|
||||
images/ui-icons_222222_256x240.png: images/ui-icons_222222_256x240-ccf2bc5085a133b936a47e17cd4fdb1c.png
|
||||
images/ui-icons_222222_256x240/index.png: images/ui-icons_222222_256x240-ccf2bc5085a133b936a47e17cd4fdb1c.png
|
||||
implication.png: implication-df9ae923c3614de364c781519d6c4afc.png
|
||||
implication/index.png: implication-df9ae923c3614de364c781519d6c4afc.png
|
||||
insight.png: insight-76f0ab9b04a6bd112f1899adb171520d.png
|
||||
|
@ -209,8 +213,8 @@ WebSocketMain.swf: WebSocketMain-0de980edb45e36785bf9d862baa032bb.swf
|
|||
WebSocketMain/index.swf: WebSocketMain-0de980edb45e36785bf9d862baa032bb.swf
|
||||
WebSocketMainInsecure.swf: WebSocketMainInsecure-c4377647e57e58cacc692c8a51afc9f8.swf
|
||||
WebSocketMainInsecure/index.swf: WebSocketMainInsecure-c4377647e57e58cacc692c8a51afc9f8.swf
|
||||
application.js: application-b6d9ec9c3fd91810dfe2579fa589529d.js
|
||||
application/index.js: application-b6d9ec9c3fd91810dfe2579fa589529d.js
|
||||
application.js: application-d12d67de32a0eaa3c4067fb74d7124b8.js
|
||||
application/index.js: application-d12d67de32a0eaa3c4067fb74d7124b8.js
|
||||
scroll/mCSB_buttons.png: scroll/mCSB_buttons-0642ce29bb568932e832d150141614e6.png
|
||||
scroll/mCSB_buttons/index.png: scroll/mCSB_buttons-0642ce29bb568932e832d150141614e6.png
|
||||
Fonts/Lato-Lig-webfont.eot: Fonts/Lato-Lig-webfont-1435188a694a7d5e29cf4a3288ff3e36.eot
|
||||
|
@ -221,5 +225,5 @@ Fonts/Lato-Lig-webfont.ttf: Fonts/Lato-Lig-webfont-4b8f0d5ac83e783eb84848ff32546
|
|||
Fonts/Lato-Lig-webfont/index.ttf: Fonts/Lato-Lig-webfont-4b8f0d5ac83e783eb84848ff3254685c.ttf
|
||||
Fonts/Lato-Lig-webfont.woff: Fonts/Lato-Lig-webfont-47c2912f319ae759c3b1cd558b080c33.woff
|
||||
Fonts/Lato-Lig-webfont/index.woff: Fonts/Lato-Lig-webfont-47c2912f319ae759c3b1cd558b080c33.woff
|
||||
application.css: application-bacb10a495325dbdf3ee878fb6fe5d21.css
|
||||
application/index.css: application-bacb10a495325dbdf3ee878fb6fe5d21.css
|
||||
application.css: application-7f69f55488ff4715d9e581c2678a4742.css
|
||||
application/index.css: application-7f69f55488ff4715d9e581c2678a4742.css
|
||||
|
|
Loading…
Reference in a new issue