update xls/csv format to better serialize topics and synapses
This commit is contained in:
parent
b36722da78
commit
987d68198c
2 changed files with 51 additions and 7 deletions
|
@ -81,12 +81,17 @@ class Map < ActiveRecord::Base
|
||||||
|
|
||||||
def to_csv(options = {})
|
def to_csv(options = {})
|
||||||
CSV.generate(options) do |csv|
|
CSV.generate(options) do |csv|
|
||||||
csv << ["id", "name", "metacode", "desc", "link", "user.name", "permission", "synapses"]
|
csv << ["topics"]
|
||||||
self.topics.each do |topic|
|
csv << ["id", "name", "metacode", "x", "y", "desc", "link", "user.name", "permission"]
|
||||||
|
self.topicmappings.each do |mapping|
|
||||||
|
topic = mapping.mappable
|
||||||
|
next if topic.nil?
|
||||||
csv << [
|
csv << [
|
||||||
topic.id,
|
topic.id,
|
||||||
topic.name,
|
topic.name,
|
||||||
topic.metacode.name,
|
topic.metacode.name,
|
||||||
|
mapping.x,
|
||||||
|
mapping.y,
|
||||||
topic.desc,
|
topic.desc,
|
||||||
topic.link,
|
topic.link,
|
||||||
topic.user.name,
|
topic.user.name,
|
||||||
|
@ -94,6 +99,20 @@ class Map < ActiveRecord::Base
|
||||||
topic.synapses_csv("text")
|
topic.synapses_csv("text")
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
csv << []
|
||||||
|
csv << ["synapses"]
|
||||||
|
csv << ["id", "description", "category", "topic1", "topic2", "username", "permission"]
|
||||||
|
self.synapses.each do |synapse|
|
||||||
|
csv << [
|
||||||
|
synapse.id,
|
||||||
|
synapse.desc,
|
||||||
|
synapse.category,
|
||||||
|
synapse.node1_id,
|
||||||
|
synapse.node2_id,
|
||||||
|
synapse.user.name,
|
||||||
|
synapse.permission
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,51 @@
|
||||||
<table>
|
<table>
|
||||||
|
<tr><th>Topics</th></tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Metacode</th>
|
<th>Metacode</th>
|
||||||
|
<th>X</th>
|
||||||
|
<th>Y</th>
|
||||||
<th>Description</th>
|
<th>Description</th>
|
||||||
<th>Link</th>
|
<th>Link</th>
|
||||||
<th>Username</th>
|
<th>Username</th>
|
||||||
<th>Permission</th>
|
<th>Permission</th>
|
||||||
<th>Synapses</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% @map.topics.each do |topic| %>
|
<% @map.topicmappings.each do |mapping| %>
|
||||||
|
<% topic = mapping.mappable %>
|
||||||
|
<% next if topic.nil? %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= topic.id %></td>
|
<td><%= topic.id %></td>
|
||||||
<td><%= topic.name %></td>
|
<td><%= topic.name %></td>
|
||||||
<td><%= topic.metacode.name %></td>
|
<td><%= topic.metacode.name %></td>
|
||||||
|
<td><%= mapping.xloc %></td>
|
||||||
|
<td><%= mapping.yloc %></td>
|
||||||
<td><%= topic.desc %></td>
|
<td><%= topic.desc %></td>
|
||||||
<td><%= topic.link %></td>
|
<td><%= topic.link %></td>
|
||||||
<td><%= topic.user.name %></td>
|
<td><%= topic.user.name %></td>
|
||||||
<td><%= topic.permission %></td>
|
<td><%= topic.permission %></td>
|
||||||
<% topic.synapses_csv.each do |s_text| %>
|
</tr>
|
||||||
<td><%= s_text %></td>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<tr></tr>
|
||||||
|
<tr><th>Synapses</th></tr>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Category</th>
|
||||||
|
<th>Topic1</th>
|
||||||
|
<th>Topic2</th>
|
||||||
|
<th>Username</th>
|
||||||
|
<th>Permission</th>
|
||||||
|
</tr>
|
||||||
|
<% @map.synapses.each do |synapse| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= synapse.id %></td>
|
||||||
|
<td><%= synapse.desc %></td>
|
||||||
|
<td><%= synapse.category %></td>
|
||||||
|
<td><%= synapse.node1_id %></td>
|
||||||
|
<td><%= synapse.node2_id %></td>
|
||||||
|
<td><%= synapse.user.name %></td>
|
||||||
|
<td><%= synapse.permission %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in a new issue