5 def initialize symbol_conf
6 @symbol_conf = symbol_conf || {}
7 @link_conf = @symbol_conf['link'] || {'type' => 'action', 'name' => 'show'}
8 @type_conf = @symbol_conf['type'] || 'image'
9 @link_method_name = self.link_method_name
10 @tag_method_name = self.tag_method_name
14 case @link_conf['type']
16 case @link_conf['name']
44 def link_action_show view, item, operators
45 view.polymorphic_path(item)
48 def link_action_else view, item, operators
49 view.polymorphic_path(item, :action => @link_conf['name'])
52 def link_none view, item, operators
56 def link_url_column view, item, operators
57 item.__send__(@link_conf['name']).to_s
60 def link_else view, item, operators
64 def tag_image view, item, operators
65 view.tag(:img, :src => @symbol_conf['name'], :width => 64, :height => 64)
68 def tag_picture view, item, operators
69 view.tag(:img, item.__send__(@symbol_conf['name']))
72 def tag_template view, item, operators
73 view.render item.path_name + '/' + @symbol_conf['name'], :item => item
77 def tag_else view, item, operators
81 def render view, item, operators
82 link = self.__send__(@link_method_name, view, item, operators)
83 tag = self.__send__(@tag_method_name, view, item, operators)
85 link_to_unless link.blank?, tag, link
93 def initialize caption_conf
94 @caption_conf = caption_conf || {}
95 @link_conf = @caption_conf['link'] || {'type' => 'action', 'name' => 'show'}
96 @type_conf = @caption_conf['type'] || 'column'
97 @link_method_name = self.link_method_name
98 @tag_method_name = self.tag_method_name
102 case @link_conf['type']
104 case @link_conf['name']
120 tag = case @type_conf
130 def link_action_show view, item, operators
131 view.polymorphic_path(item)
134 def link_action_else view, item, operators
135 view.polymorphic_path(item, :action => @link_conf['name'])
138 def link_none view, item, operators
142 def link_url_column view, item, operators
143 item.__send__(@link_conf['name']).to_s
146 def link_else view, item, operators
150 def tag_column view, item, operators
151 item.attributes[caption['name']]
154 def tag_method view, item, operators
155 item.__send__(caption['name']).to_s
158 def tag_else view, item, operators
162 def render view, item, operators
163 unless caption_type == 'none'
164 link = self.__send__(@link_method_name, view, item, operators)
165 tag = self.__send__(@tag_method_name, view, item, operators)
166 tag = 'no caption' if tag.blank?
168 link_to_unless link.blank?, tag, link
176 def initialize summary_conf
177 @summary_conf = summary_conf || {}
178 @type_conf = @summary_conf['type'] || 'none'
179 @type_method = self.type_method
193 def type_none view, item, operators
197 def type_template view, item, operators
198 view.render item.path_name + '/' + @summary_conf['name'], :item => item
201 def render view, item, operators
202 self.__send__(@type_method, view, item)
208 def initialize icon_conf
209 @icon_conf = icon_conf || {}
212 def render view, item, operators
213 view.link_to view.icon_tag(item.class.to_s, :object => item, :size => 64),
214 view.polymorphic_path(item, :format => :prof)
220 def initialize date_conf
221 @date_conf = date_conf || {}
224 def render view, item, operators
225 view.distance_of_time_in_words_to_now item.updated_at
231 def initialize edit_conf
232 @edit_conf = edit_conf || {}
233 @type_conf = @edit_conf['type'] || 'default'
234 @type_method = self.type_method
252 def type_default view, item, operators
253 if item.own? operators
254 view.link_to tag(:img, :src => view.asset_path('edit.png'), :width => 32, :height => 32),
255 view.polymorphic_path(item, :action => :edit)
256 view.link_to tag(:img, :src => view.asset_path('remove.png'), :width => 32, :height => 32),
257 item, confirm: 'Are you sure?', :method => :delete
261 def type_account view, item, operators
262 if item.own? operators
263 view.link_to tag(:img, :src => view.asset_path('edit.png'), :width => 32, :height => 32),
268 def type_template view, item, operators
269 view.render item.path_name + '/' + @edit_conf['name'], :item => item
272 def type_none view, item, operators
276 def render view, item, operators
277 self.__send__(@type_method, view, item, operators)
284 attr :item, :operators
285 def initialize item, operators, symbol, caption, summary, icon, date, edit, manifest
288 @operators = operators
298 @symbol.render view, @item, @operators
302 @caption.render view, @item, @operators
306 @summary.render view, @item, @operators
310 @icon.render view, @item, @operators
314 @date.render view, @item, @operators
318 @edit.render view, @item, @operators
323 attr :items, :file_items, :operators
324 def initialize items, operators, symbol, caption, summary, icon, date, edit, manifest
327 @file_items = @items.map {|item|
328 FileItem.new item, operators, symbol, caption, summary, icon, date, edit, manifest
333 def initialize filer_manifest
334 @filer_manifest = filer_manifest
335 @item_name = @filer_manifest.item_name
336 @manifest = @filer_manifest.manifest
337 @filer_conf = @filer_manifest.conf
338 @symbol = Symbol.new @filer_manifest.symbol
339 @caption = Caption.new @filer_manifest.caption
340 @summary = Summary.new @filer_manifest.summary
341 @icon = Icon.new @filer_manifest.icon
342 @date = Date.new @filer_manifest.date
343 @edit = Edit.new @filer_manifest.edit
346 def open items, operators
347 Filer.new items, operators, @symbol, @caption, @summary, @icon, @date, @edit, @manifest