added ability to hide topics from canvas, remove topics from map, and delete topics, all from the graph.

This commit is contained in:
Connor Turland 2013-01-04 21:39:16 -05:00
parent d8cd950ae8
commit e593bbc8b2
29 changed files with 270 additions and 127 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
app/assets/images/minus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View file

@ -532,7 +532,6 @@ function onCreateLabelHandler(domElement, node) {
var html = ' \ var html = ' \
<div class="CardOnGraph" \ <div class="CardOnGraph" \
id="topic_$_id_$"> \ id="topic_$_id_$"> \
<a href="#" class="close-link">close</a> \
<p class="type best_in_place best_in_place_metacode" \ <p class="type best_in_place best_in_place_metacode" \
data-url="/topics/$_id_$" \ data-url="/topics/$_id_$" \
data-object="topic" \ data-object="topic" \
@ -541,6 +540,7 @@ function onCreateLabelHandler(domElement, node) {
data-type="select">$_metacode_$</p> \ data-type="select">$_metacode_$</p> \
<img alt="$_metacode_$" \ <img alt="$_metacode_$" \
class="icon" \ class="icon" \
title="Click to hide card" \
height="50" \ height="50" \
width="50" \ width="50" \
src="$_imgsrc_$" /> \ src="$_imgsrc_$" /> \
@ -553,7 +553,7 @@ function onCreateLabelHandler(domElement, node) {
data-type="input">$_name_$</span> \ data-type="input">$_name_$</span> \
<a href="/topics/$_id_$" class="topic-go-arrow" target="_blank"> \ <a href="/topics/$_id_$" class="topic-go-arrow" target="_blank"> \
<img class="topic-go-arrow" \ <img class="topic-go-arrow" \
title="Go to the topic page" \ title="Explore Topic" \
src="/assets/go-arrow.png" /> \ src="/assets/go-arrow.png" /> \
</a> \ </a> \
<div class="clearfloat"></div> \ <div class="clearfloat"></div> \
@ -629,10 +629,10 @@ function onCreateLabelHandler(domElement, node) {
domElement.appendChild(showCard); domElement.appendChild(showCard);
// add some events to the label // add some events to the label
$(showCard).find('a.close-link').click(function(){ $(showCard).find('img.icon').click(function(){
delete node.selected; delete node.selected;
node.setData('dim', 25, 'current'); node.setData('dim', 25, 'current');
node.eachAdjacency(function (adj) { /*node.eachAdjacency(function (adj) {
adj.setDataset('end', { adj.setDataset('end', {
lineWidth: 2, lineWidth: 2,
color: '#222222' color: '#222222'
@ -642,7 +642,7 @@ function onCreateLabelHandler(domElement, node) {
Mconsole.fx.animate({ Mconsole.fx.animate({
modes: ['edge-property:lineWidth:color'], modes: ['edge-property:lineWidth:color'],
duration: 500 duration: 500
}); });*/
$('.showcard.topic_' + node.id).fadeOut('fast', function(){ $('.showcard.topic_' + node.id).fadeOut('fast', function(){
$('.name').css('display','block'); $('.name').css('display','block');
Mconsole.plot(); Mconsole.plot();
@ -655,16 +655,60 @@ function onCreateLabelHandler(domElement, node) {
var nameContainer = document.createElement('span'), var nameContainer = document.createElement('span'),
style = nameContainer.style; style = nameContainer.style;
nameContainer.className = 'name topic_' + node.id; nameContainer.className = 'name topic_' + node.id;
nameContainer.innerHTML = '<div class="label">' + node.name + '</div>'; var littleHTML = ' \
<div class="label">$_name_$</div> \
<div class="nodeOptions">';
if (mapid == null) {
littleHTML += ' \
<span class="removeFromCanvas" \
onclick="removeFromCanvas($_id_$)" \
title="Click to remove topic from canvas"> \
</span>';
}
else if (mapid != null && userid != null) {
littleHTML += ' \
<a href="/mappings/$_mapid_$/$_id_$/removefrommap" \
title="Click to remove topic from map" \
class="removeFromMap" \
data-method="get" \
data-remote="true" \
rel="nofollow"> \
</a>';
}
if (userid != null) {
littleHTML += ' \
<a href="/topics/$_id_$" \
title="Click to delete this topic" \
class="deleteTopic" \
data-confirm="Delete this topic and all synapses linking to it?" \
data-method="delete" \
data-remote="true" \
rel="nofollow"> \
</a>';
}
littleHTML += '</div>';
littleHTML = littleHTML.replace(/\$_id_\$/g, node.id);
littleHTML = littleHTML.replace(/\$_mapid_\$/g, mapid);
littleHTML = littleHTML.replace(/\$_name_\$/g, node.name);
nameContainer.innerHTML = littleHTML;
domElement.appendChild(nameContainer); domElement.appendChild(nameContainer);
style.fontSize = "0.9em"; style.fontSize = "0.9em";
style.color = "#222222"; style.color = "#222222";
// add some events to the label // add some events to the label
nameContainer.onclick = function(){ $(nameContainer).find('.label').click(function(){
selectNodeOnClickHandler(node) selectNodeOnClickHandler(node)
});
nameContainer.onmouseover = function(){
$('.name.topic_' + node.id + ' .nodeOptions').css('display','block');
} }
nameContainer.onmouseout = function(){
$('.name.topic_' + node.id + ' .nodeOptions').css('display','none');
}
//bind callbacks //bind callbacks
$(showCard).find('.type.best_in_place').bind("ajax:success", function() { $(showCard).find('.type.best_in_place').bind("ajax:success", function() {
var metacode = $(this).html(); var metacode = $(this).html();

View file

@ -21,7 +21,7 @@
// other options are 'graph' // other options are 'graph'
var viewMode = "list"; var viewMode = "list";
var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null, gType, tempNode = null, tempInit = false, tempNode2 = null, metacodeIMGinit = false, findOpen = false, analyzeOpen = false, organizeOpen = false, goRealtime = false; var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null, gType, tempNode = null, tempInit = false, tempNode2 = null, metacodeIMGinit = false, findOpen = false, analyzeOpen = false, organizeOpen = false, goRealtime = false, mapid = null;
$(document).ready(function() { $(document).ready(function() {
@ -54,7 +54,6 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
if (! sliding1) { if (! sliding1) {
sliding1 = true; sliding1 = true;
if (userid != null) { if (userid != null) {
$('.footer .menu').css('border','1px solid #000');
$('.footer .menu').animate({ $('.footer .menu').animate({
height: '252px' height: '252px'
}, 300, function() { }, 300, function() {
@ -78,7 +77,6 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
height: '0px' height: '0px'
}, 300, function() { }, 300, function() {
sliding1 = false; sliding1 = false;
$('.footer .menu').css('border','none');
}); });
} }
},800); },800);
@ -125,6 +123,23 @@ function saveToMap() {
$('#new_map').fadeIn('fast'); $('#new_map').fadeIn('fast');
} }
// this is for hiding one topic from your canvas
function removeFromCanvas(topic_id) {
var node = Mconsole.graph.getNode(topic_id);
node.setData('alpha', 0, 'end');
node.eachAdjacency(function(adj) {
adj.setData('alpha', 0, 'end');
});
Mconsole.fx.animate({
modes: ['node-property:alpha',
'edge-property:alpha'],
duration: 1000
});
Mconsole.graph.removeNode(topic_id);
Mconsole.labels.disposeLabel(topic_id);
}
function addMetacode() { function addMetacode() {
// code from http://www.professorcloud.com/mainsite/carousel-integration.htm // code from http://www.professorcloud.com/mainsite/carousel-integration.htm
//mouseWheel:true, //mouseWheel:true,

View file

@ -2,9 +2,48 @@
// They will automatically be included in application.css. // They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/ // You can use Sass (SCSS) here: http://sass-lang.com/
.nodeOptions {
display:none;
position: absolute;
top: -5px;
right: -17px;
}
.onCanvas .removeFromMap {
display:none !important;
}
.onMap .removeFromCanvas {
display:none !important;
}
.unauthenticated .deleteTopic {
display:none !important;
}
.removeFromCanvas {
display: block;
width: 17px;
height: 16px;
background: url('removeFromCanvas.png') no-repeat 2px 0;
}
.removeFromMap {
display: block;
width: 17px;
height: 16px;
background: url('removeFromMap.png') no-repeat 2px 0;
}
.deleteTopic {
display: block;
width: 17px;
height: 16px;
background: url('delete.png') no-repeat 2px 0;
}
.topic { display:block; float:left; position:relative; width:175px; height:300px; padding:10px 5px 10px 35px; background: url('bg.png'); border-radius:15px; margin:30px 0 30px 50px; color:#000; } .topic { display:block; float:left; position:relative; width:175px; height:300px; padding:10px 5px 10px 35px; background: url('bg.png'); border-radius:15px; margin:30px 0 30px 50px; color:#000; }
.close-link,
.topic .delete { .topic .delete {
position: absolute; position: absolute;
top: -14px; top: -14px;
@ -48,8 +87,8 @@ line-height: 24px;}
} }
.topic-go-arrow { .topic-go-arrow {
width: 1em; width: 25px;
height: 1em; height: 25px;
float: right; float: right;
} }

View file

@ -107,14 +107,6 @@ class MapsController < ApplicationController
@map.attributes = params[:map] @map.attributes = params[:map]
@map.save @map.save
if params[:outtopics]
@outtopics = params[:outtopics]
@outtopics.each do |topic|
@mapping = Mapping.where("map_id = ? AND topic_id = ?", @map.id, topic).first
@mapping.delete
end
end
respond_with(@user, location: map_path(@map)) do |format| respond_with(@user, location: map_path(@map)) do |format|
end end
end end

View file

@ -130,6 +130,31 @@ class TopicsController < ApplicationController
# end # end
end end
# GET mappings/:map_id/:topic_id/removefrommap
def removefrommap
@current = current_user
@mapping = Mapping.find_by_topic_id_and_map_id(params[:topic_id],params[:map_id])
@map = Map.find(params[:map_id])
@topic = Topic.find(params[:topic_id])
@mappings = @map.mappings.select{|m|
if m.category == "Synapse"
m.synapse.topic1 == @topic || m.synapse.topic2 == @topic
else
false
end
}
@mappings.each do |m|
m.delete
end
@mapping.delete
respond_to do |format|
format.js
end
end
# DELETE topics/:id # DELETE topics/:id
def destroy def destroy
@current = current_user @current = current_user

View file

@ -3,7 +3,7 @@
<button onclick='clearCanvas();'>Clear Canvas</button> <button onclick='clearCanvas();'>Clear Canvas</button>
</div> </div>
<div class="clearfloat"></div> <div class="clearfloat"></div>
<div class="maps" id="container"> <div class="maps onCanvas" id="container">
<div id="center-container"> <div id="center-container">
<div id="infovis"></div> <div id="infovis"></div>
</div> </div>

View file

@ -4,8 +4,6 @@
<%= form.text_field :name %> <%= form.text_field :name %>
<label for="map_desc">Description</label> <label for="map_desc">Description</label>
<%= form.text_area :desc, class: "description", :rows => 5 %> <%= form.text_area :desc, class: "description", :rows => 5 %>
<label for="outtopics">Remove Topics From Map</label>
<%= select_tag "outtopics", options_from_collection_for_select(@outtopics, "id", "name"), { :multiple => true } %>
<label for="map_perm">Permission</label> <label for="map_perm">Permission</label>
<%= form.select :permission, options_for_select(['commons', 'public', 'private'], @map.permission) %> <%= form.select :permission, options_for_select(['commons', 'public', 'private'], @map.permission) %>
<%= form.submit "Update", class: "update" %> <%= form.submit "Update", class: "update" %>

View file

@ -22,15 +22,31 @@
</div> </div>
<div class="clearfloat nodemargin"></div> <div class="clearfloat nodemargin"></div>
<div class="maps" id="container"> <div class="maps onMap" id="container">
<div id="center-container"> <div id="center-container">
<div id="infovis"></div> <div id="infovis"></div>
</div> </div>
<div id="showcard">
</div>
</div> </div>
<div class="clearfloat"></div> <div class="clearfloat"></div>
<% if authenticated? %>
<%= render :partial => 'newtopic' %>
<%= render :partial => 'newsynapse' %>
<% end %>
<%= form_for @map, :url => realtime_path(@map), :method => "GET", :html => { :id => "MapRealtime"}, remote: true do |form| %>
<%= form.hidden_field :time, :value => Time.now.to_i %>
<%= form.hidden_field :ids, :value => 0 %>
<% end %>
<script>
var dragged = 0;
mapid = <%= @map.id %>;
var int = setInterval(function(){
if (goRealtime) {
$('#MapRealtime').submit();
}
},4000);
</script>
<script> <script>
viewMode = "graph"; viewMode = "graph";
json = <%= @mapjson %>; json = <%= @mapjson %>;
@ -49,20 +65,3 @@
}); });
} }
</script> </script>
<% if authenticated? %>
<%= render :partial => 'newtopic' %>
<%= render :partial => 'newsynapse' %>
<% end %>
<%= form_for @map, :url => realtime_path(@map), :method => "GET", :html => { :id => "MapRealtime"}, remote: true do |form| %>
<%= form.hidden_field :time, :value => Time.now.to_i %>
<%= form.hidden_field :ids, :value => 0 %>
<% end %>
<script>
var dragged = 0;
var int = setInterval(function(){
if (goRealtime) {
$('#MapRealtime').submit();
}
},4000);
</script>

View file

@ -1 +1,17 @@
if (Mconsole != null) {
var node = Mconsole.graph.getNode(<%= @topic.id %>);
node.setData('alpha', 0, 'end');
node.eachAdjacency(function(adj) {
adj.setData('alpha', 0, 'end');
});
Mconsole.fx.animate({
modes: ['node-property:alpha',
'edge-property:alpha'],
duration: 1000
});
Mconsole.graph.removeNode(<%= @topic.id %>);
Mconsole.labels.disposeLabel(<%= @topic.id %>);
}
else {
$('#<%= dom_id(@topic) %>').fadeOut('slow'); $('#<%= dom_id(@topic) %>').fadeOut('slow');
}

View file

@ -0,0 +1,14 @@
if (Mconsole != null) {
var node = Mconsole.graph.getNode(<%= @mapping.topic_id %>);
node.setData('alpha', 0, 'end');
node.eachAdjacency(function(adj) {
adj.setData('alpha', 0, 'end');
});
Mconsole.fx.animate({
modes: ['node-property:alpha',
'edge-property:alpha'],
duration: 1000
});
Mconsole.graph.removeNode(<%= @mapping.topic_id %>);
Mconsole.labels.disposeLabel(<%= @mapping.topic_id %>);
}

View file

@ -10,6 +10,7 @@ ISSAD::Application.routes.draw do
match 'maps/:id/savelayout', to: 'maps#savelayout', via: :put, as: :savelayout match 'maps/:id/savelayout', to: 'maps#savelayout', via: :put, as: :savelayout
match 'maps/:id/realtime', to: 'maps#realtime', via: :get, as: :realtime match 'maps/:id/realtime', to: 'maps#realtime', via: :get, as: :realtime
match 'mappings/:map_id/:topic_id/removefrommap', to: 'topics#removefrommap', via: :get, as: :removefrommap
resource :session resource :session