added ability to limit search results to just your own, and to minimize the different sections of search results

This commit is contained in:
Connor Turland 2014-02-02 14:56:07 -05:00
parent 9c3c7c5e01
commit 6538577387
35 changed files with 309 additions and 113 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

View file

@ -78,7 +78,7 @@ function escKeyHandler() {
* Make a node "in the commons" (with a green circle) lose its
* green circle so it stays on the console/map/...
*/
function keepFromCommons(id) {
function keepFromCommons(event, id) {
if (userid == null) {
return;
}
@ -88,6 +88,10 @@ function keepFromCommons(id) {
$('#topic_y').val(0);
$('#topic_grabTopic').val(id);
$('.new_topic').submit();
event.preventDefault();
event.stopPropagation();
return false;
}//doubleClickNodeHandler
/*

View file

@ -155,30 +155,151 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
name: 'topics',
template: $('.topicTemplate').html(),
remote: {
url: '/search/topics?term=%QUERY'
url: '/search/topics?term=%QUERY',
replace: function () {
var q = '/search/topics?term=' + $('.sidebarSearchField').val();
if ($("#limitTopicsToMe").is(':checked')) {
q += "&user=" + userid.toString();
}
return q;
},
filter: function(dataset) {
if (dataset.length == 0) {
dataset.push({
value: "No results",
typeImageURL: "/assets/wildcard.png",
rtype: "noresult"
});
}
return dataset;
}
},
engine: Hogan,
header: '<h3 class="search-header">Topics</h3>'
header: '<h3 class="search-header">Topics</h3><input type="checkbox" class="limitToMe" id="limitTopicsToMe"></input><label for="limitTopicsToMe" class="limitToMeLabel">added by me</label><div class="minimizeResults minimizeTopicResults"></div><div class="clearfloat"></div>'
},
{
name: 'maps',
template: $('.mapTemplate').html(),
remote: {
url: '/search/maps?term=%QUERY'
url: '/search/maps?term=%QUERY',
replace: function () {
var q = '/search/maps?term=' + $('.sidebarSearchField').val();
if ($("#limitMapsToMe").is(':checked')) {
q += "&user=" + userid.toString();
}
return q;
},
filter: function(dataset) {
if (dataset.length == 0) {
dataset.push({
value: "No results",
rtype: "noresult"
});
}
return dataset;
}
},
engine: Hogan,
header: '<h3 class="search-header">Maps</h3>'
header: '<h3 class="search-header">Maps</h3><input type="checkbox" class="limitToMe" id="limitMapsToMe"></input><label for="limitMapsToMe" class="limitToMeLabel">added by me</label><div class="minimizeResults minimizeMapResults"></div><div class="clearfloat"></div>'
},
{
name: 'mappers',
template: $('.mapperTemplate').html(),
remote: {
url: '/search/mappers?term=%QUERY'
url: '/search/mappers?term=%QUERY',
filter: function(dataset) {
if (dataset.length == 0) {
dataset.push({
value: "No results",
rtype: "noresult"
});
}
return dataset;
}
},
engine: Hogan,
header: '<h3 class="search-header">Mappers</h3>'
header: '<h3 class="search-header">Mappers</h3><div class="minimizeResults minimizeMapperResults"></div><div class="clearfloat"></div>'
}
]);
// tell the autocomplete to launch a new tab with the topic, map, or mapper you clicked on
$('.sidebarSearchField').bind('typeahead:selected', function (event, datum, dataset) {
console.log(event);
if (datum.rtype != "noresult") {
var win;
if (dataset == "topics") {
win=window.open('/topics/' + datum.id, '_blank');
}
else if (dataset == "maps") {
win=window.open('/maps/' + datum.id, '_blank');
}
else if (dataset == "mappers") {
win=window.open('/maps/mappers/' + datum.id, '_blank');
}
win.focus();
closeSearch(0);
}
});
var checkboxChangeInit = false, minimizeInit = false;
$('.sidebarSearchField').bind('keyup', function () {
// when the user selects 'added by me' resend the query with their userid attached
if (!checkboxChangeInit) {
$('.limitToMe').bind("change", function(e) {
// set the value of the search equal to itself to retrigger the autocomplete event
searchIsOpen = false;
$('.sidebarSearchField').typeahead('setQuery',$('.sidebarSearchField').val());
setTimeout(function() { searchIsOpen = true; }, 2000);
});
checkboxChangeInit = true;
}
// when the user clicks minimize section, hide the results for that section
if (!minimizeInit) {
$('.minimizeMapperResults').click(function(e) {
var s = $('.tt-dataset-mappers .tt-suggestions');
console.log(s.css('height'));
if (s.css('height') == '0px') {
$('.tt-dataset-mappers .tt-suggestions').css('height','auto');
$(this).removeClass('maximizeResults').addClass('minimizeResults');
} else {
$('.tt-dataset-mappers .tt-suggestions').css('height','0');
$(this).removeClass('minimizeResults').addClass('maximizeResults');
}
});
$('.minimizeTopicResults').click(function(e) {
var s = $('.tt-dataset-topics .tt-suggestions');
console.log(s.css('height'));
if (s.css('height') == '0px') {
s.css({'height':'auto','border-top':'none'});
$(this).removeClass('maximizeResults').addClass('minimizeResults');
} else {
s.css({'height':'0','border-top':'1px solid #222'});
$(this).removeClass('minimizeResults').addClass('maximizeResults');
}
});
$('.minimizeMapResults').click(function(e) {
var s = $('.tt-dataset-maps .tt-suggestions');
console.log(s.css('height'));
if (s.css('height') == '0px') {
s.css({'height':'auto','border-top':'none'});
$(this).removeClass('maximizeResults').addClass('minimizeResults');
} else {
s.css({'height':'0','border-top':'1px solid #222'});
$(this).removeClass('minimizeResults').addClass('maximizeResults');
}
});
minimizeInit = true;
}
});
//
$('.sidebarSearch button.addToMap').click(function(event){
event.stopPropagation();
});
} // end bindSearchHover
function bindAccountHover() {

View file

@ -835,12 +835,43 @@ border: 1px solid black;
font-size:20px;
line-height:20px;
margin: 10px 0 3px 10px;
float:left;
}
.sidebarSearch .tt-dropdown-menu .limitToMe {
float:left;
width: 15px;
height: 15px;
margin-top: 11px;
margin-left: 15px;
}
.sidebarSearch .tt-dropdown-menu .limitToMeLabel {
float:left;
margin-top: 11px;
}
.sidebarSearch .tt-dropdown-menu .minimizeResults {
float:right;
width:35px;
height:35px;
background: url('/assets/MMCCicon_minimize_arrow.png') no-repeat center center;
background-size: 25px 25px;
cursor:pointer;
}
.sidebarSearch .tt-dropdown-menu .maximizeResults {
float:right;
width:35px;
height:35px;
background: url('/assets/MMCCicon_maximize_arrow.png') no-repeat center center;
background-size: 25px 25px;
cursor:pointer;
}
.sidebarSearch .tt-suggestions {
font-family:'LatoLight', helvetica, sans-serif;
overflow:hidden;
}
.sidebarSearch .tt-suggestion {
background: rgba(0,0,0,0.5);
border: 1px solid black;
@ -850,6 +881,10 @@ border: 1px solid black;
background:black;
}
.sidebarSearch .tt-dataset-maps .tt-is-under-cursor .resultmap, .sidebarSearch .tt-dataset-topics .tt-is-under-cursor .resulttopic {
min-height: 57px;
}
.sidebarSearch .tt-suggestion .icon {
float:left;
width:36px;
@ -863,7 +898,7 @@ border: 1px solid black;
}
.sidebarSearch .resultText {
width: 280px;
width: 275px;
display: block;
float: left;
}
@ -888,7 +923,7 @@ border: 1px solid black;
}
.sidebarSearch div.autoOptions {
width: 117px;
width: 122px;
float: left;
position:relative;
display:none;
@ -896,6 +931,9 @@ border: 1px solid black;
.sidebarSearch .tt-is-under-cursor .autoOptions {
display:block;
}
.sidebarSearch .tt-suggestion .resultnoresult .autoOptions {
display:none;
}
.sidebarSearch .autoOptions button, .sidebarSearch .autoOptions a, .sidebarSearch .autoOptions div {
position: absolute;
@ -906,21 +944,22 @@ border: 1px solid black;
}
.sidebarSearch button.addToMap {
width: 20px;
height: 20px;
background: url(/assets/MMCCicon_add.png) no-repeat center center;
background-size: 15px 15px;
top: 10px;
left: 0px;
width: 20px;
height: 20px;
background: url(/assets/MMCCicon_add.png) no-repeat center center;
background-size: 18px 18px;
top: 30px;
left: 84px;
cursor: pointer;
}
.sidebarSearch a.goTo {
width: 20px;
height: 20px;
background: url(/assets/MMCCicon_pop-out.png) no-repeat center center;
background-size: 15px 15px;
top: 11px;
left: 22px;
background-size: 18px 18px;
top: 7px;
left: 84px;
}
.sidebarSearch div.mapCount {
@ -928,8 +967,8 @@ width: 20px;
height: 20px;
background: url(/assets/MMCCicon_map.png) no-repeat 0px center;
background-size: 14px 14px;
top: 0px;
left: 50px;
top: 7px;
left: 39px;
padding-left: 18px;
font-size: 12px;
line-height: 20px;
@ -940,8 +979,8 @@ width: 20px;
height: 20px;
background: url(/assets/MMCCicon_topic.png) no-repeat 0px center;
background-size: 14px 14px;
top: 0px;
left: 50px;
top: 7px;
left: 39px;
padding-left: 18px;
font-size: 12px;
line-height: 20px;
@ -951,10 +990,10 @@ line-height: 20px;
width: 20px;
height: 20px;
background: url(/assets/MMCCicon_synapse.png) no-repeat 0px center;
background-size: 14px 14px;
top: 0px;
left: 83px;
padding-left: 15px;
background-size: 15px 15px;
top: 30px;
left: 38px;
padding-left: 19px;
font-size: 12px;
line-height: 20px;
}
@ -963,29 +1002,29 @@ line-height: 20px;
width: 20px;
height: 20px;
background: url(/assets/MMCCicon_mapper.png) no-repeat center center;
background-size: 16px 16px;
top: 21px;
left: 52px;
background-size: 17px 17px;
top: 7px;
left: 13px;
}
.sidebarSearch div.mapContributorsIcon {
width: 20px;
height: 20px;
background: url(/assets/MMCCicon_mapper.png) no-repeat 0px center;
background-size: 16px 16px;
top: 21px;
left: 50px;
padding-left: 18px;
font-size: 12px;
line-height: 20px;
height: 20px;
background: url(/assets/MMCCicon_mapper.png) no-repeat 0px center;
background-size: 17px 17px;
top: 7px;
right: 85px;
padding-left: 19px;
font-size: 12px;
line-height: 20px;
padding-right: 5px;
}
.sidebarSearch div.topicPermission, .sidebarSearch div.mapPermission {
width: 20px;
height: 20px;
background-size: 20px 20px !important;
top: 20px;
left: 84px;
background-size: 19px 19px !important;
top: 30px;
left: 13px;
}
.sidebarSearch div.topicPermission.commons, .sidebarSearch div.mapPermission.commons {
background: url(/assets/MMCCicon_commons.png) no-repeat center center;

View file

@ -36,6 +36,7 @@ class MainController < ApplicationController
@current = current_user
term = params[:term]
user = params[:user] ? params[:user] : false
if term && !term.empty? && term.downcase[0..3] != "map:" && term.downcase[0..6] != "mapper:" && term.downcase != "topic:"
@ -59,13 +60,20 @@ class MainController < ApplicationController
@topics = []
else
search = '%' + term.downcase + '%'
@topics = Topic.where('LOWER("name") like ? OR LOWER("desc") like ? OR LOWER("link") like ?', search, search, search).
where('metacode_id = ?', filterByMetacode.id).limit(10).order('"name"').visibleToUser(@current,nil)
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"')
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"')
end
end
else
search = '%' + term.downcase + '%'
@topics = Topic.where('LOWER("name") like ? OR LOWER("desc") like ? OR LOWER("link") like ?', search, search, search).
limit(10).order('"name"').visibleToUser(@current,nil)
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"')
end
end
else
@topics = []
@ -87,14 +95,19 @@ class MainController < ApplicationController
@current = current_user
term = params[:term]
user = params[:user] ? params[:user] : nil
if term && !term.empty? && term.downcase[0..5] != "topic:" && term.downcase[0..6] != "mapper:" && term.downcase != "map:"
#remove "map:" if appended at beginning
term = term[4..-1] if term.downcase[0..3] == "map:"
search = '%' + term.downcase + '%'
@maps = Map.where('LOWER("name") like ? OR LOWER("desc") like ?', search, search).
limit(10).order('"name"').visibleToUser(@current,nil)
if !user
@maps = Map.where('LOWER("name") like ? OR LOWER("desc") like ?', search, search).order('"name"')
elsif user
@maps = Map.where('LOWER("name") like ? OR LOWER("desc") like ?', search, search).where('user_id = ?', user).order('"name"')
end
else
@maps = []
end

View file

@ -13,6 +13,7 @@ module MapsHelper
map['topicCount'] = m.topics.count
map['synapseCount'] = m.synapses.count
map['contributorCount'] = m.contributors.count
map['rtype'] = "map"
contributorList = ''
if m.contributors.count > 0

View file

@ -15,6 +15,7 @@ module TopicsHelper
topic['mapCount'] = t.maps.count
topic['synapseCount'] = t.synapses.count
topic['originator'] = t.user.name
topic['rtype'] = "topic"
temp.push topic
end

View file

@ -9,6 +9,7 @@ module UsersHelper
user['label'] = u.name
user['value'] = u.name
user['mapCount'] = u.maps.count
user['rtype'] = "mapper"
temp.push user
end

View file

@ -6,6 +6,7 @@
<div class="templates">
<div class="topicTemplate">
<div class="result{{rtype}}">
<img class="icon" src="{{typeImageURL}}">
<span class="tip metacodeTip">{{type}}</span>
<div class="resultText">
@ -15,7 +16,7 @@
<div class="autoOptions">
<% if controller_name == 'maps' && action_name == 'show' && authenticated? && @map.authorize_to_edit(@current) %>
<button class="addToMap" onclick="keepFromCommons({{id}})"></button>
<button class="addToMap" onclick="return keepFromCommons(event, {{id}})"></button>
<span class="tip">add to map</span>
<% end %>
<a href="/topics/{{id}}" target="_blank" class="goTo">
@ -38,8 +39,10 @@
</div>
<div class="clearfloat"></div>
</div>
</div>
<div class="mapTemplate">
<div class="result{{rtype}}">
<img class="icon" src="/assets/map.png">
<div class="resultText">
<p class="resultTitle">{{value}}</p>
@ -67,8 +70,10 @@
</div>
<div class="clearfloat"></div>
</div>
</div>
<div class="mapperTemplate">
<div class="result{{rtype}}">
<img class="icon" width="28" height="28" src="/assets/MMCCicon_mapper.png">
<div class="resultText">
<p class="resultTitle">{{value}}</p>
@ -84,5 +89,6 @@
</div>
<div class="clearfloat"></div>
</div>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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.

View file

@ -11,6 +11,8 @@ MMCCicon_delete_grey.png: MMCCicon_delete_grey-139563eb178ac12911430f31c487eff6.
MMCCicon_delete_grey/index.png: MMCCicon_delete_grey-139563eb178ac12911430f31c487eff6.png
MMCCicon_filter.png: MMCCicon_filter-8dd344476ca9fb88261938acb66d2c79.png
MMCCicon_filter/index.png: MMCCicon_filter-8dd344476ca9fb88261938acb66d2c79.png
MMCCicon_go.png: MMCCicon_go-aae580938b3ea29afbe3de759feee359.png
MMCCicon_go/index.png: MMCCicon_go-aae580938b3ea29afbe3de759feee359.png
MMCCicon_help.png: MMCCicon_help-dfde3a342abc809a6508695a75ea9b87.png
MMCCicon_help/index.png: MMCCicon_help-dfde3a342abc809a6508695a75ea9b87.png
MMCCicon_hide.png: MMCCicon_hide-e2fcfe3fcaeef87d07322aeea2b2af37.png
@ -19,6 +21,8 @@ MMCCicon_info.png: MMCCicon_info-76fbf35e20e1bb6facb3e14254543c9c.png
MMCCicon_info/index.png: MMCCicon_info-76fbf35e20e1bb6facb3e14254543c9c.png
MMCCicon_invite.png: MMCCicon_invite-33ce02d3a0500b602c15e9192c3c4f66.png
MMCCicon_invite/index.png: MMCCicon_invite-33ce02d3a0500b602c15e9192c3c4f66.png
MMCCicon_link.png: MMCCicon_link-32bc019e1ba44c73c8898de7ca0de1fa.png
MMCCicon_link/index.png: MMCCicon_link-32bc019e1ba44c73c8898de7ca0de1fa.png
MMCCicon_logout.png: MMCCicon_logout-2b7d4dfff8cdc4d38089c082ac0c6929.png
MMCCicon_logout/index.png: MMCCicon_logout-2b7d4dfff8cdc4d38089c082ac0c6929.png
MMCCicon_map.png: MMCCicon_map-77c3768601370ee04d15f7da448fee91.png
@ -29,6 +33,12 @@ MMCCicon_mapper.png: MMCCicon_mapper-3d7a6f42563271141b72483efa7701d2.png
MMCCicon_mapper/index.png: MMCCicon_mapper-3d7a6f42563271141b72483efa7701d2.png
MMCCicon_mapper_black.png: MMCCicon_mapper_black-8e5daace6edd134213588252f1426e10.png
MMCCicon_mapper_black/index.png: MMCCicon_mapper_black-8e5daace6edd134213588252f1426e10.png
MMCCicon_maximize_arrow.png: MMCCicon_maximize_arrow-d529ebb50a2254187a1d42e7ec496eaa.png
MMCCicon_maximize_arrow/index.png: MMCCicon_maximize_arrow-d529ebb50a2254187a1d42e7ec496eaa.png
MMCCicon_metacode_set.png: MMCCicon_metacode_set-f4e1e0a7c9e66f8d61ded339704f9ef6.png
MMCCicon_metacode_set/index.png: MMCCicon_metacode_set-f4e1e0a7c9e66f8d61ded339704f9ef6.png
MMCCicon_minimize_arrow.png: MMCCicon_minimize_arrow-8923745a55d45e84fcd5ce8c0b90d042.png
MMCCicon_minimize_arrow/index.png: MMCCicon_minimize_arrow-8923745a55d45e84fcd5ce8c0b90d042.png
MMCCicon_pop-out.png: MMCCicon_pop-out-f929f9f904f0dde84210a68980110e9b.png
MMCCicon_pop-out/index.png: MMCCicon_pop-out-f929f9f904f0dde84210a68980110e9b.png
MMCCicon_pop-out_black.png: MMCCicon_pop-out_black-a0fe60f38328f60a42e4e59472c669a2.png
@ -199,8 +209,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-32fff722d967b095a46a0f9aef58d2ac.js
application/index.js: application-32fff722d967b095a46a0f9aef58d2ac.js
application.js: application-bd7e83f7b33a139f170decf7e9714bc0.js
application/index.js: application-bd7e83f7b33a139f170decf7e9714bc0.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
@ -211,5 +221,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-7d15b1e4985733b33978307af5dce062.css
application/index.css: application-7d15b1e4985733b33978307af5dce062.css
application.css: application-ec07fd82dedb30e38622a81e0cfcfc95.css
application/index.css: application-ec07fd82dedb30e38622a81e0cfcfc95.css