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 if @tag_method_name == :tag_template
87 view.render item.path_name + '/' + @symbol_conf['name'], :item => item
89 link = self.__send__(@link_method_name, view, item, operators)
90 tag = self.__send__(@tag_method_name, view, item, operators)
92 view.link_to_unless link.blank?, tag, link
100 def initialize caption_conf
101 @caption_conf = caption_conf || {}
102 @link_conf = @caption_conf['link'] || {'type' => 'action', 'name' => 'show'}
103 @type_conf = @caption_conf['type'] || 'column'
104 @link_method_name = self.link_method_name
105 @tag_method_name = self.tag_method_name
109 case @link_conf['type']
111 case @link_conf['name']
127 tag = case @type_conf
139 def link_action_show view, item, operators
140 view.polymorphic_path(item)
143 def link_action_else view, item, operators
144 view.polymorphic_path(item, :action => @link_conf['name'])
147 def link_none view, item, operators
151 def link_url_column view, item, operators
152 item.__send__(@link_conf['name']).to_s
155 def link_else view, item, operators
159 def tag_column view, item, operators
160 item.attributes[@caption_conf['name']]
163 def tag_method view, item, operators
164 item.__send__(@caption_conf['name']).to_s
167 def tag_else view, item, operators
172 @tag_method_name != :tag_none
175 def render view, item, operators
176 link = self.__send__(@link_method_name, view, item, operators)
177 tag = self.__send__(@tag_method_name, view, item, operators)
178 tag = 'no caption' if tag.blank?
180 view.link_to_unless link.blank?, tag, link
187 def initialize summary_conf
188 @summary_conf = summary_conf || {}
189 @type_conf = @summary_conf['type'] || 'none'
190 @type_method = self.type_method
204 def type_none view, item, operators
208 def type_template view, item, operators
209 view.render item.path_name + '/' + @summary_conf['name'], :item => item
213 self.type_method != :type_none
216 def render view, item, operators
217 self.__send__(@type_method, view, item, operators)
223 def initialize icon_conf
224 @icon_conf = icon_conf || {}
231 def render view, item, operators
232 view.link_to view.icon_tag(item.class.to_s, :object => item, :size => 64),
233 view.polymorphic_path(item, :format => :prof)
239 def initialize date_conf
240 @date_conf = date_conf || {}
247 def render view, item, operators
248 view.distance_of_time_in_words_to_now item.updated_at
254 def initialize edit_conf
255 @edit_conf = edit_conf || {}
256 @type_conf = @edit_conf['type'] || 'default'
257 @type_method = self.type_method
275 def type_default view, item, operators
276 if item.own? operators
277 view.link_to view.tag(:img, :src => view.asset_path('edit.png'), :width => 32, :height => 32),
278 view.polymorphic_path(item, :action => :edit)
279 view.link_to view.tag(:img, :src => view.asset_path('remove.png'), :width => 32, :height => 32),
280 item, confirm: 'Are you sure?', :method => :delete
284 def type_account view, item, operators
285 if item.own? operators
286 view.link_to view.tag(:img, :src => view.asset_path('edit.png'), :width => 32, :height => 32),
291 def type_template view, item, operators
292 view.render item.path_name + '/' + @edit_conf['name'], :item => item
295 def type_none view, item, operators
300 self.type_method != :type_none
303 def render view, item, operators
304 self.__send__(@type_method, view, item, operators)
311 attr :item, :operators
312 def initialize item, operators, symbol, caption, summary, icon, date, edit, manifest
315 @operators = operators
325 @symbol.render view, @item, @operators
329 @caption.render view, @item, @operators
333 @summary.render view, @item, @operators
337 @icon.render view, @item, @operators
341 @date.render view, @item, @operators
345 @edit.render view, @item, @operators
350 attr :items, :file_items, :operators, :paginate, :symbol, :caption, :summary, :icon, :date, :edit
351 def initialize item_name, items, operators, paginate, symbol, caption, summary, icon, date, edit, manifest
352 @item_name = item_name
354 @operators = operators
364 @file_items = @items.map {|item|
365 FileItem.new item, operators, symbol, caption, summary, icon, date, edit, manifest
368 raise "List define err for #{@item_name} in #{@items}\n"
378 model_name.classify.constantize
383 attr :filer_manifest, :item_name, :manifest, :filer_conf,
384 :symbol, :caption, :summary, :icon, :date, :edit
385 def initialize filer_manifest
386 @filer_manifest = filer_manifest
387 @item_name = @filer_manifest.item_name
388 @manifest = @filer_manifest.manifest
389 @filer_conf = @filer_manifest.conf
390 @symbol = Symbol.new @filer_manifest.symbol
391 @caption = Caption.new @filer_manifest.caption
392 @summary = Summary.new @filer_manifest.summary
393 @icon = Icon.new @filer_manifest.icon
394 @date = Date.new @filer_manifest.date
395 @edit = Edit.new @filer_manifest.edit
398 def open item_name, items, operators, paginate
399 Filer.new item_name, items, operators, paginate, @symbol, @caption, @summary, @icon, @date, @edit, @manifest