X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=lib%2Fmanifest%2Ffiler.rb;h=177ef208ac5e01a8fd58750cbd8471cd46da10ee;hp=6417fea95f3d79fd67c6472de9ab73b699779669;hb=783369b9535f6f7e96d1242aec09e06995f364bc;hpb=eada248d033161ff9797c40bac0fd24ed7d1d962 diff --git a/lib/manifest/filer.rb b/lib/manifest/filer.rb index 6417fea9..177ef208 100644 --- a/lib/manifest/filer.rb +++ b/lib/manifest/filer.rb @@ -78,11 +78,15 @@ module Pettanr 'no.png' end + def visible? + self.link_method_name != :link_none + end + def render view, item, operators link = self.__send__(@link_method_name, view, item, operators) tag = self.__send__(@tag_method_name, view, item, operators) unless tag.blank? - link_to_unless link.blank?, tag, link + view.link_to_unless link.blank?, tag, link end end @@ -148,25 +152,27 @@ module Pettanr end def tag_column view, item, operators - item.attributes[caption['name']] + item.attributes[@caption_conf['name']] end def tag_method view, item, operators - item.__send__(caption['name']).to_s + item.__send__(@caption_conf['name']).to_s end def tag_else view, item, operators 'no caption' end + def visible? + self.link_method_name != :link_none + end + def render view, item, operators - unless caption_type == 'none' - link = self.__send__(@link_method_name, view, item, operators) - tag = self.__send__(@tag_method_name, view, item, operators) - tag = 'no caption' if tag.blank? - unless tag.blank? - link_to_unless link.blank?, tag, link - end + link = self.__send__(@link_method_name, view, item, operators) + tag = self.__send__(@tag_method_name, view, item, operators) + tag = 'no caption' if tag.blank? + unless tag.blank? + view.link_to_unless link.blank?, tag, link end end @@ -198,8 +204,12 @@ module Pettanr view.render item.path_name + '/' + @summary_conf['name'], :item => item end + def visible? + self.type_method != :type_none + end + def render view, item, operators - self.__send__(@type_method, view, item) + self.__send__(@type_method, view, item, operators) end end @@ -209,6 +219,10 @@ module Pettanr @icon_conf = icon_conf || {} end + def visible? + true + end + def render view, item, operators view.link_to view.icon_tag(item.class.to_s, :object => item, :size => 64), view.polymorphic_path(item, :format => :prof) @@ -221,6 +235,10 @@ module Pettanr @date_conf = date_conf || {} end + def visible? + true + end + def render view, item, operators view.distance_of_time_in_words_to_now item.updated_at end @@ -273,6 +291,10 @@ module Pettanr '' end + def visible? + self.type_method != :type_none + end + def render view, item, operators self.__send__(@type_method, view, item, operators) end @@ -320,16 +342,36 @@ module Pettanr end - attr :items, :file_items, :operators - def initialize items, operators, symbol, caption, summary, icon, date, edit, manifest + attr :items, :file_items, :operators, :paginate, :symbol, :caption, :summary, :icon, :date, :edit + def initialize item_name, items, operators, paginate, symbol, caption, summary, icon, date, edit, manifest + @item_name = item_name @items = items + @operators = operators + @paginate = paginate + @symbol = symbol + @caption = caption + @summary = summary + @icon = icon + @date = date + @edit = edit @manifest = manifest @file_items = @items.map {|item| FileItem.new item, operators, symbol, caption, summary, icon, date, edit, manifest } end + + def model_name + @item_name + end + + def model + model_name.classify.constantize + end + end + attr :filer_manifest, :item_name, :manifest, :filer_conf, + :symbol, :caption, :summary, :icon, :date, :edit def initialize filer_manifest @filer_manifest = filer_manifest @item_name = @filer_manifest.item_name @@ -343,8 +385,8 @@ module Pettanr @edit = Edit.new @filer_manifest.edit end - def open items, operators - Filer.new items, operators, @symbol, @caption, @summary, @icon, @date, @edit, @manifest + def open item_name, items, operators, paginate + Filer.new item_name, items, operators, paginate, @symbol, @caption, @summary, @icon, @date, @edit, @manifest end end