Commit a3f7b47957e500c98066380c32874320b96185c3

Authored by AntonioTerceiro
1 parent a5bb8fc7

ActionItem18: customizing comatose



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@383 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/application.rb
... ... @@ -2,7 +2,7 @@
2 2 # available in all controllers.
3 3 class ApplicationController < ActionController::Base
4 4  
5   -# helper :all
  5 + helper :document
6 6  
7 7 design :holder => 'virtual_community'
8 8  
... ...
app/helpers/document_helper.rb
1 1 module DocumentHelper
2 2  
  3 + # displays an icon corresponding to the document passed in +doc+.
  4 + #
  5 + # The class of the document can define its icon by providing an +icon+
  6 + # method (i.e. +doc.class.icon+ will be called)
3 7 def icon_for_document(doc)
4   - design_display_icon(doc.class.icon)
  8 + icon =
  9 + case doc
  10 + when Comatose::Page
  11 + 'text-x-generic'
  12 + else
  13 + if doc.class.respond_to?(:icon)
  14 + doc.class.icon
  15 + else
  16 + 'none'
  17 + end
  18 + end
  19 + design_display_icon(icon)
5 20 end
6 21  
7 22 end
... ...
app/views/comatose_admin/_page_list_item.rhtml
... ... @@ -23,24 +23,21 @@ collapse_children = (level &gt;= Comatose.config.default_tree_level)
23 23 <li id="page_<%= page.id %>">
24 24 <table cellpadding="0" cellspacing="0">
25 25 <tr>
26   - <td rowspan="2" valign="center">
  26 + <td valign="center">
27 27 <% if !page.children.empty? %>
28 28 <%= image_tag( ((collapse_children) ? 'comatose/collapsed.gif' : 'comatose/expanded.gif'), :title=>'Expand/Collapse', :onclick=>"ComatoseList.toggle_tree_nodes(this,#{page.id});", :class=>'tree-controller', :size=>'12x12', :id=>"page_controller_#{page.id}" ) %>
29 29 <% else %>
30 30 <%= image_tag 'comatose/no-children.gif', :size=>'12x12', :class=>'tree-controller' %>
31 31 <% end %>
32 32 </td>
33   - <td rowspan="2" valign="center">
34   - <%= image_tag 'comatose/page.gif', :size=>'25x31', :align=>"absmiddle" %>
  33 + <td valign="center">
  34 + <%= icon_for_document(page) %>
35 35 <span class="handle">DRAG</span>
36 36 </td>
37 37 <td>
38 38 <%= link_to page.title, {:action=>'edit', :id=>page}, :title=>"Path:#{page.full_path}", :class=>'page' %>
39 39 </td>
40   - </tr>
41   - <tr>
42 40 <td class="commands">
43   - Updated <span title="Created on <%= page.created_on %>"><%= time_ago_in_words page.updated_on, true %> ago</span><%= " by #{page.author}" unless page.author.nil? or page.author.empty? %>,
44 41 <%= links.join(', ') %>.
45 42 </td>
46 43 </tr>
... ...
config/environment.rb
... ... @@ -80,4 +80,4 @@ Comatose::AdminController.before_filter do |controller|
80 80 end
81 81 controller.instance_variable_set('@virtual_community', virtual_community)
82 82 end
83   -#require 'comatose_extensions'
  83 +
... ...
lib/comatose_extensions.rb
... ... @@ -1,7 +0,0 @@
1   -
2   -# FIXME: for some reason adding the following makes comatose migration to not
3   -# work
4   -
5   -#def (Comatose::Page).icon
6   -# 'text-x-generic'
7   -#end