updated graph styling and json generate code. updated add synapses page to not have all three forms in the same place.
This commit is contained in:
parent
4d09fb6fc8
commit
606b59b644
7 changed files with 283 additions and 255 deletions
|
@ -48,17 +48,20 @@ function init(){
|
|||
// with dollar prefixed data-properties in the
|
||||
// JSON structure.
|
||||
Node: {
|
||||
overridable: true
|
||||
overridable: true,
|
||||
color: '#2D6A5D',
|
||||
type: 'circle',
|
||||
dim: 11
|
||||
},
|
||||
Edge: {
|
||||
overridable: true,
|
||||
color: '#23A4FF',
|
||||
lineWidth: 0.4
|
||||
lineWidth: 0.5
|
||||
},
|
||||
//Native canvas text styling
|
||||
Label: {
|
||||
type: labelType, //Native or HTML
|
||||
size: 10,
|
||||
size: 12,
|
||||
style: 'bold'
|
||||
},
|
||||
//Add Tips
|
||||
|
@ -117,7 +120,7 @@ function init(){
|
|||
onCreateLabel: function(domElement, node){
|
||||
domElement.innerHTML = node.name;
|
||||
var style = domElement.style;
|
||||
style.fontSize = "0.8em";
|
||||
style.fontSize = "0.9em";
|
||||
style.color = "#ddd";
|
||||
},
|
||||
// Change node styles when DOM labels are placed
|
||||
|
|
|
@ -69,3 +69,9 @@ input[type="submit"] { margin-top:5px; }
|
|||
|
||||
.divider { margin: 20px 50px 20px 50px; border-bottom:2px solid #FFF; }
|
||||
.empty { margin-left:50px; }
|
||||
|
||||
.selecttype { display:block; margin:100px auto 0; width:500px; }
|
||||
.selecttype button { display:inline-block; width:150px; height:50px; background: #2D6A5D; color: white; border-radius: 15px; cursor: pointer; }
|
||||
.selecttype button:hover { border-width:4px; border-color:#CCC; }
|
||||
.selecttype .middle { margin:0 20px; }
|
||||
.newsynapses form {display:none; }
|
|
@ -29,8 +29,6 @@ has_many :items, :through => :groupitems
|
|||
|
||||
def as_json
|
||||
Jbuilder.encode do |json|
|
||||
@data1 = {'$color'=> '#909291'}
|
||||
@data2 = {'$color'=> '#70A35E', '$type'=> 'triangle', '$dim'=> 11 }
|
||||
@single = Array.new
|
||||
@single.push(self)
|
||||
@groups = @single + self.relatives
|
||||
|
@ -39,10 +37,16 @@ has_many :items, :through => :groupitems
|
|||
json.adjacencies group.synapses2.delete_if{|synapse| not @groups.include?(Group.find_by_id(synapse.node1_id))} do |json, synapse|
|
||||
json.nodeTo synapse.node1_id
|
||||
json.nodeFrom synapse.node2_id
|
||||
json.data @data1
|
||||
|
||||
@synapsedata = Hash.new
|
||||
@synapsedata['desc'] = synapse.desc
|
||||
json.data @synapsedata
|
||||
end
|
||||
|
||||
json.data @data2
|
||||
@groupdata = Hash.new
|
||||
@groupdata['desc'] = group.desc
|
||||
@groupdata['link'] = group.link
|
||||
json.data @groupdata
|
||||
json.id group.id
|
||||
json.name group.name
|
||||
end
|
||||
|
|
|
@ -31,8 +31,6 @@ has_many :parent_items, :through => :itemitem_p, :source => :parent_item
|
|||
|
||||
def as_json
|
||||
Jbuilder.encode do |json|
|
||||
@data1 = {'$color'=> '#909291'}
|
||||
@data2 = {'$color'=> '#70A35E', '$type'=> 'triangle', '$dim'=> 11 }
|
||||
@single = Array.new
|
||||
@single.push(self)
|
||||
@items = @single + self.relatives
|
||||
|
@ -41,10 +39,16 @@ has_many :parent_items, :through => :itemitem_p, :source => :parent_item
|
|||
json.adjacencies item.synapses2.delete_if{|synapse| not @items.include?(Item.find_by_id(synapse.node1_id))} do |json, synapse|
|
||||
json.nodeTo synapse.node1_id
|
||||
json.nodeFrom synapse.node2_id
|
||||
json.data @data1
|
||||
|
||||
@synapsedata = Hash.new
|
||||
@synapsedata['desc'] = synapse.desc
|
||||
json.data @synapsedata
|
||||
end
|
||||
|
||||
json.data @data2
|
||||
@itemdata = Hash.new
|
||||
@itemdata['desc'] = item.desc
|
||||
@itemdata['link'] = item.link
|
||||
json.data @itemdata
|
||||
json.id item.id
|
||||
json.name item.name
|
||||
end
|
||||
|
|
|
@ -23,8 +23,6 @@ has_many :people2, :through => :synapses1, :source => :person2
|
|||
|
||||
def as_json
|
||||
Jbuilder.encode do |json|
|
||||
@data1 = {'$color'=> '#909291'}
|
||||
@data2 = {'$color'=> '#70A35E', '$type'=> 'triangle', '$dim'=> 11 }
|
||||
@single = Array.new
|
||||
@single.push(self)
|
||||
@people = @single + self.relatives
|
||||
|
@ -33,10 +31,16 @@ has_many :people2, :through => :synapses1, :source => :person2
|
|||
json.adjacencies person.synapses2.delete_if{|synapse| not @people.include?(Person.find_by_id(synapse.node1_id))} do |json, synapse|
|
||||
json.nodeTo synapse.node1_id
|
||||
json.nodeFrom synapse.node2_id
|
||||
json.data @data1
|
||||
|
||||
@synapsedata = Hash.new
|
||||
@synapsedata['desc'] = synapse.desc
|
||||
json.data @synapsedata
|
||||
end
|
||||
|
||||
json.data @data2
|
||||
@persondata = Hash.new
|
||||
@persondata['desc'] = person.desc
|
||||
@persondata['link'] = person.link
|
||||
json.data @persondata
|
||||
json.id person.id
|
||||
json.name person.name
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Metamap</title>
|
||||
<title>Metamaps</title>
|
||||
<%= stylesheet_link_tag "application", :media => "all" %>
|
||||
<%= javascript_include_tag "application" %>
|
||||
<%= csrf_meta_tags %>
|
||||
|
@ -10,7 +10,7 @@
|
|||
<%= content_tag :div, class: authenticated? ? "main authenticated" : "main unauthenticated" do %>
|
||||
|
||||
<div class="headertop">
|
||||
<h1 id="mainTitle"><%= link_to "metamap", root_path %></h1> beta
|
||||
<h1 id="mainTitle"><%= link_to "metamaps", root_path %></h1> beta
|
||||
<% unless authenticated? %>
|
||||
<ul>
|
||||
<li><%= link_to "Login", new_session_path, id: "Login" %></li>
|
||||
|
|
|
@ -1,45 +1,52 @@
|
|||
<%= form_for @synapse1, url: synapses_url do |form| %>
|
||||
<h3>Add Synapse Between Groups</h3>
|
||||
<%= hidden_field_tag(:category, "Group") %>
|
||||
<% if @allgroups.count > 0 %>
|
||||
<label for="node1_id">Choose First Group</label>
|
||||
<%= select_tag :node1_id, options_from_collection_for_select(@allgroups, "id", "name") %>
|
||||
<% end %>
|
||||
<label for="item_desc">Describe The Connection</label>
|
||||
<%= form.text_field :desc, class: "description" %>
|
||||
<% if @allgroups.count > 0 %>
|
||||
<label for="node2_id">Choose Second Group</label>
|
||||
<%= select_tag :node2_id, options_from_collection_for_select(@allgroups, "id", "name") %>
|
||||
<% end %>
|
||||
<%= form.submit "Add Synapse", class: "add" %>
|
||||
<% end %>
|
||||
<%= form_for @synapse2, url: synapses_url do |form| %>
|
||||
<h3>Add Synapse Between People</h3>
|
||||
<%= hidden_field_tag(:category, "Person") %>
|
||||
<% if @allpeople.count > 0 %>
|
||||
<label for="node1_id">Choose First Person</label>
|
||||
<%= select_tag :node1_id, options_from_collection_for_select(@allpeople, "id", "name") %>
|
||||
<% end %>
|
||||
<label for="item_desc">Describe The Connection</label>
|
||||
<%= form.text_field :desc, class: "description" %>
|
||||
<% if @allpeople.count > 0 %>
|
||||
<label for="node2_id">Choose Second Person</label>
|
||||
<%= select_tag :node2_id, options_from_collection_for_select(@allpeople, "id", "name") %>
|
||||
<% end %>
|
||||
<%= form.submit "Add Synapse", class: "add" %>
|
||||
<% end %>
|
||||
<%= form_for @synapse3, url: synapses_url do |form| %>
|
||||
<h3>Add Synapse Between Items</h3>
|
||||
<%= hidden_field_tag(:category, "Item") %>
|
||||
<% if @allitems.count > 0 %>
|
||||
<label for="node1_id">Choose First Item</label>
|
||||
<%= select_tag :node1_id, options_from_collection_for_select(@allitems, "id", "name") %>
|
||||
<% end %>
|
||||
<label for="item_desc">Describe The Connection</label>
|
||||
<%= form.text_field :desc, class: "description" %>
|
||||
<% if @allitems.count > 0 %>
|
||||
<label for="node2_id">Choose Second Item</label>
|
||||
<%= select_tag :node2_id, options_from_collection_for_select(@allitems, "id", "name") %>
|
||||
<% end %>
|
||||
<%= form.submit "Add Synapse", class: "add" %>
|
||||
<% end %>
|
||||
<div class="selecttype">
|
||||
<button onclick="$('.selecttype').fadeOut('fast', function(){$('.newsynapses form:eq(0)').fadeIn('fast')});">Group to Group</button>
|
||||
<button class="middle" onclick="$('.selecttype').fadeOut('fast', function(){$('.newsynapses form:eq(1)').fadeIn('fast')});">Person to Person</button>
|
||||
<button onclick="$('.selecttype').fadeOut('fast', function(){$('.newsynapses form:eq(2)').fadeIn('fast')});">Item to Item</button>
|
||||
</div>
|
||||
<div class="newsynapses">
|
||||
<%= form_for @synapse1, url: synapses_url do |form| %>
|
||||
<h3>Add Synapse Between Groups</h3>
|
||||
<%= hidden_field_tag(:category, "Group") %>
|
||||
<% if @allgroups.count > 0 %>
|
||||
<label for="node1_id">Choose First Group</label>
|
||||
<%= select_tag :node1_id, options_from_collection_for_select(@allgroups, "id", "name") %>
|
||||
<% end %>
|
||||
<label for="item_desc">Describe The Connection</label>
|
||||
<%= form.text_field :desc, class: "description" %>
|
||||
<% if @allgroups.count > 0 %>
|
||||
<label for="node2_id">Choose Second Group</label>
|
||||
<%= select_tag :node2_id, options_from_collection_for_select(@allgroups, "id", "name") %>
|
||||
<% end %>
|
||||
<%= form.submit "Add Synapse", class: "add" %>
|
||||
<% end %>
|
||||
<%= form_for @synapse2, url: synapses_url do |form| %>
|
||||
<h3>Add Synapse Between People</h3>
|
||||
<%= hidden_field_tag(:category, "Person") %>
|
||||
<% if @allpeople.count > 0 %>
|
||||
<label for="node1_id">Choose First Person</label>
|
||||
<%= select_tag :node1_id, options_from_collection_for_select(@allpeople, "id", "name") %>
|
||||
<% end %>
|
||||
<label for="item_desc">Describe The Connection</label>
|
||||
<%= form.text_field :desc, class: "description" %>
|
||||
<% if @allpeople.count > 0 %>
|
||||
<label for="node2_id">Choose Second Person</label>
|
||||
<%= select_tag :node2_id, options_from_collection_for_select(@allpeople, "id", "name") %>
|
||||
<% end %>
|
||||
<%= form.submit "Add Synapse", class: "add" %>
|
||||
<% end %>
|
||||
<%= form_for @synapse3, url: synapses_url do |form| %>
|
||||
<h3>Add Synapse Between Items</h3>
|
||||
<%= hidden_field_tag(:category, "Item") %>
|
||||
<% if @allitems.count > 0 %>
|
||||
<label for="node1_id">Choose First Item</label>
|
||||
<%= select_tag :node1_id, options_from_collection_for_select(@allitems, "id", "name") %>
|
||||
<% end %>
|
||||
<label for="item_desc">Describe The Connection</label>
|
||||
<%= form.text_field :desc, class: "description" %>
|
||||
<% if @allitems.count > 0 %>
|
||||
<label for="node2_id">Choose Second Item</label>
|
||||
<%= select_tag :node2_id, options_from_collection_for_select(@allitems, "id", "name") %>
|
||||
<% end %>
|
||||
<%= form.submit "Add Synapse", class: "add" %>
|
||||
<% end %>
|
||||
</div>
|
Loading…
Reference in a new issue