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
82 self.link_method_name != :link_none
85 def render view, item, operators
86 link = self.__send__(@link_method_name, view, item, operators)
87 tag = self.__send__(@tag_method_name, view, item, operators)
89 view.link_to_unless link.blank?, tag, link
97 def initialize caption_conf
98 @caption_conf = caption_conf || {}
99 @link_conf = @caption_conf['link'] || {'type' => 'action', 'name' => 'show'}
100 @type_conf = @caption_conf['type'] || 'column'
101 @link_method_name = self.link_method_name
102 @tag_method_name = self.tag_method_name
106 case @link_conf['type']
108 case @link_conf['name']
124 tag = case @type_conf
134 def link_action_show view, item, operators
135 view.polymorphic_path(item)
138 def link_action_else view, item, operators
139 view.polymorphic_path(item, :action => @link_conf['name'])
142 def link_none view, item, operators
146 def link_url_column view, item, operators
147 item.__send__(@link_conf['name']).to_s
150 def link_else view, item, operators
154 def tag_column view, item, operators
155 item.attributes[@caption_conf['name']]
158 def tag_method view, item, operators
159 item.__send__(@caption_conf['name']).to_s
162 def tag_else view, item, operators
167 self.link_method_name != :link_none
170 def render view, item, operators
171 link = self.__send__(@link_method_name, view, item, operators)
172 tag = self.__send__(@tag_method_name, view, item, operators)
173 tag = 'no caption' if tag.blank?
175 view.link_to_unless link.blank?, tag, link
182 def initialize summary_conf
183 @summary_conf = summary_conf || {}
184 @type_conf = @summary_conf['type'] || 'none'
185 @type_method = self.type_method
199 def type_none view, item, operators
203 def type_template view, item, operators
204 view.render item.path_name + '/' + @summary_conf['name'], :item => item
208 self.type_method != :type_none
211 def render view, item, operators
212 self.__send__(@type_method, view, item, operators)
218 def initialize icon_conf
219 @icon_conf = icon_conf || {}
226 def render view, item, operators
227 view.link_to view.icon_tag(item.class.to_s, :object => item, :size => 64),
228 view.polymorphic_path(item, :format => :prof)
234 def initialize date_conf
235 @date_conf = date_conf || {}
242 def render view, item, operators
243 view.distance_of_time_in_words_to_now item.updated_at
249 def initialize edit_conf
250 @edit_conf = edit_conf || {}
251 @type_conf = @edit_conf['type'] || 'default'
252 @type_method = self.type_method
270 def type_default view, item, operators
271 if item.own? operators
272 view.link_to view.tag(:img, :src => view.asset_path('edit.png'), :width => 32, :height => 32),
273 view.polymorphic_path(item, :action => :edit)
274 view.link_to view.tag(:img, :src => view.asset_path('remove.png'), :width => 32, :height => 32),
275 item, confirm: 'Are you sure?', :method => :delete
279 def type_account view, item, operators
280 if item.own? operators
281 view.link_to view.tag(:img, :src => view.asset_path('edit.png'), :width => 32, :height => 32),
286 def type_template view, item, operators
287 view.render item.path_name + '/' + @edit_conf['name'], :item => item
290 def type_none view, item, operators
295 self.type_method != :type_none
298 def render view, item, operators
299 self.__send__(@type_method, view, item, operators)
306 attr :item, :operators
307 def initialize item, operators, symbol, caption, summary, icon, date, edit, manifest
310 @operators = operators
320 @symbol.render view, @item, @operators
324 @caption.render view, @item, @operators
328 @summary.render view, @item, @operators
332 @icon.render view, @item, @operators
336 @date.render view, @item, @operators
340 @edit.render view, @item, @operators
345 attr :items, :file_items, :operators, :paginate, :symbol, :caption, :summary, :icon, :date, :edit
346 def initialize item_name, items, operators, paginate, symbol, caption, summary, icon, date, edit, manifest
347 @item_name = item_name
349 @operators = operators
359 @file_items = @items.map {|item|
360 FileItem.new item, operators, symbol, caption, summary, icon, date, edit, manifest
363 raise "List define err for #{@item_name} in #{@items}\n"
373 model_name.classify.constantize
378 attr :filer_manifest, :item_name, :manifest, :filer_conf,
379 :symbol, :caption, :summary, :icon, :date, :edit
380 def initialize filer_manifest
381 @filer_manifest = filer_manifest
382 @item_name = @filer_manifest.item_name
383 @manifest = @filer_manifest.manifest
384 @filer_conf = @filer_manifest.conf
385 @symbol = Symbol.new @filer_manifest.symbol
386 @caption = Caption.new @filer_manifest.caption
387 @summary = Summary.new @filer_manifest.summary
388 @icon = Icon.new @filer_manifest.icon
389 @date = Date.new @filer_manifest.date
390 @edit = Edit.new @filer_manifest.edit
393 def open item_name, items, operators, paginate
394 Filer.new item_name, items, operators, paginate, @symbol, @caption, @summary, @icon, @date, @edit, @manifest