metamaps--metamaps/app/views/shared/_filterBox.html.erb

126 lines
3.8 KiB
Plaintext
Raw Normal View History

2014-08-02 17:49:51 +00:00
<%#
# @file
# this code generates the list of icons in the filter box in the upper right menu area
2014-08-02 17:49:51 +00:00
#%>
<%
@mappers = []
@synapses = []
@metacodes = []
@metacodelist = ''
@mapperlist = ''
@synapselist = ''
# There are essentially three functions happening here one to fill data to
#@mappers with all people who have mapped on the selected map, which
#actually gets checked twice once for topics or within @metacodes and once
#for synapses on the map. @synapses get filled with all synapses on the map
#and metacodes is filled with all the metacodes that are being used on the map.
2014-08-10 17:06:58 +00:00
if @map
2014-11-11 07:23:39 +00:00
@alltopics.each_with_index do |topic, index|
2014-08-10 17:06:58 +00:00
if @metacodes.index(topic.metacode) == nil
@metacodes.push(topic.metacode)
end
end
2014-11-11 07:23:39 +00:00
@allsynapses.each_with_index do |synapse, index|
2014-08-10 17:06:58 +00:00
if @synapses.index{|s| s.desc == synapse.desc} == nil
@synapses.push(synapse)
end
end
2014-11-11 07:23:39 +00:00
@allmappings.each_with_index do |mapping, index|
if @mappers.index(mapping.user) == nil
@mappers.push(mapping.user)
2014-08-10 17:06:58 +00:00
end
end
2014-11-11 07:23:39 +00:00
elsif @topic
@alltopics.each_with_index do |topic, index|
if @metacodes.index(topic.metacode) == nil
@metacodes.push(topic.metacode)
end
if @mappers.index(topic.user) == nil
@mappers.push(topic.user)
end
end
@allsynapses.each_with_index do |synapse, index|
if @synapses.index{|s| s.desc == synapse.desc} == nil
@synapses.push(synapse)
end
if @mappers.index(synapse.user) == nil
@mappers.push(synapse.user)
end
end
end
2014-08-10 17:06:58 +00:00
2014-11-11 07:23:39 +00:00
if @map || @topic
@metacodes.sort! {|x,y|
n1 = x.name || ""
n2 = y.name || ""
n1 <=> n2
}
@synapses.sort! {|x,y|
d1 = x.desc || ""
d2 = y.desc || ""
d1 <=> d2
}
@mappers.sort! {|x,y|
n1 = x.name || ""
n2 = y.name || ""
n1 <=> n2
}
2014-08-10 17:06:58 +00:00
@metacodes.each_with_index do |metacode, index|
@metacodelist += '<li data-id="' + metacode.id.to_s + '">'
2015-10-25 08:50:07 +00:00
@metacodelist += '<img src="' + asset_path(metacode.icon) + '" data-id="' + metacode.id.to_s + '" alt="' + metacode.name + '" />'
2014-08-10 17:06:58 +00:00
@metacodelist += '<p>' + metacode.name.downcase + '</p></li>'
2014-08-02 17:49:51 +00:00
end
2014-08-10 17:06:58 +00:00
@synapses.each_with_index do |synapse, index|
d = synapse.desc || ""
@synapselist += '<li data-id="' + d + '">'
@synapselist += '<img src="' + asset_path('synapse16.png') + '" alt="synapse icon" /><p>' + d
2014-08-10 17:06:58 +00:00
@synapselist += '</p></li>'
2014-08-02 17:49:51 +00:00
end
2014-08-10 17:06:58 +00:00
@mappers.each_with_index do |mapper, index|
@mapperlist += '<li data-id="' + mapper.id.to_s + '">'
@mapperlist += '<img src="' + mapper.image.url(:sixtyfour) + '" data-id="' + mapper.id.to_s + '" alt="' + mapper.name + '" />'
2014-08-10 17:06:58 +00:00
@mapperlist += '<p>' + mapper.name + '</p></li>'
end
end
2014-08-02 17:49:51 +00:00
%>
<div class="filterBox">
2014-09-03 23:05:25 +00:00
<h2>FILTER BY</h2>
<div id="filter_by_mapper" class="filterBySection">
2014-11-11 07:23:39 +00:00
<h3><%= @map ? "MAPPERS" : @topic ? "CREATORS" : "" %></h3>
2014-09-03 23:05:25 +00:00
<span class="hideAll hideAllMappers">NONE</span>
<span class="active showAll showAllMappers">ALL</span>
2014-09-03 23:05:25 +00:00
<div class="clearfloat"></div>
2014-08-02 17:49:51 +00:00
<ul>
2014-09-03 23:05:25 +00:00
<%= @mapperlist.html_safe %>
</ul>
2014-08-02 17:49:51 +00:00
<div class="clearfloat"></div>
</div>
2014-09-03 23:05:25 +00:00
<div id="filter_by_metacode" class="filterBySection">
<h3>METACODES</h3>
<span class="hideAll hideAllMetacodes">NONE</span>
<span class="active showAll showAllMetacodes">ALL</span>
2014-09-03 23:05:25 +00:00
<div class="clearfloat"></div>
2014-08-02 17:49:51 +00:00
<ul>
2014-09-03 23:05:25 +00:00
<%= @metacodelist.html_safe %>
</ul>
2014-08-02 17:49:51 +00:00
<div class="clearfloat"></div>
</div>
2014-09-03 23:05:25 +00:00
<div id="filter_by_synapse" class="filterBySection">
<h3>SYNAPSES</h3>
<span class="hideAll hideAllSynapses">NONE</span>
<span class="active showAll showAllSynapses">ALL</span>
2014-09-03 23:05:25 +00:00
<div class="clearfloat"></div>
<ul>
2014-09-03 23:05:25 +00:00
<%= @synapselist.html_safe %>
</ul>
<div class="clearfloat"></div>
2014-08-02 17:49:51 +00:00
</div>
</div> <!-- end .filterBox -->