Module: MongoBureau::ClassMethods
- Defined in:
- lib/mongo_bureau.rb
Instance Attribute Summary collapse
-
#list_options ⇒ Object
Returns the value of attribute list_options.
Instance Method Summary collapse
- #list_view(r) ⇒ Object
- #minilist_view ⇒ Object
- #scene_selector ⇒ Object
- #sortable_on_that_page? ⇒ Boolean
Instance Attribute Details
#list_options ⇒ Object
Returns the value of attribute list_options.
83 84 85 |
# File 'lib/mongo_bureau.rb', line 83 def end |
Instance Method Details
#list_view(r) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/mongo_bureau.rb', line 85 def list_view(r) = {:request=>r, :destination=>r.fullpath, :path=>r.script_name, :filter=>r['filter'] } .store(:sortable,sortable_on_that_page?) out = list_view_header out << scene_selector unless bureau_config[:scene_selector_class].nil? out << many_to_many_picker unless bureau_config[:minilist_class].nil? out << "<ul class='nut-tree #{'sortable' if @list_options[:sortable]} #{bureau_config[:nut_tree_class]}' id='#{self.name}' rel='#{@list_options[:path]}/#{self.name}'>" self.find(typecast_filter([:filter]||{}), (self.respond_to?(:list_view_fields) ? {fields: self.list_view_fields} : {})).each do |m| out << m.to_nutshell end out << "</ul>" end |
#minilist_view ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/mongo_bureau.rb', line 103 def minilist_view o = "<ul class='minilist'>\n" self.find.each do |m| thumb = m.respond_to?(:to_bureau_thumb) ? m.to_bureau_thumb('stash_thumb_gif') : m.placeholder_thumb('stash_thumb_gif') o << "<li title='#{m.to_label}' id='mini-#{m.id}'>#{thumb}<div>#{m.to_label}</div></li>\n" end o << "</ul>\n" end |
#scene_selector ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/mongo_bureau.rb', line 112 def scene_selector o = klass = bureau_config[:scene_selector_class].is_a?(Symbol) ? Kernel.const_get(bureau_config[:scene_selector_class]) : bureau_config[:scene_selector_class] obj = klass.get(o[:filter]["id_#{bureau_config[:scene_selector_class]}"]) unless obj.nil? out = "<p>Point and click in order to highlight a zone.</p>\n" out << obj.build_image_tag('image','original', :class=>'mapolygon-me') save_btn = command_plus.sub(/btn btn-plus/, 'save-mapolygon').sub(/></, '>Create this zone<').sub(/(href='[^']*)/, "\\1&model[coordinates]=") out << "<div class='scene-selector-toolbar'><button type='button' class='reset-mapolygon'>Reset</button> #{save_btn}</div>\n" end end |
#sortable_on_that_page? ⇒ Boolean
98 99 100 101 |
# File 'lib/mongo_bureau.rb', line 98 def sortable_on_that_page? o = o[:search].nil? && @schema.key?('position') && (@schema['position'][:scope].nil? || (o[:filter]||{}).key?(@schema['position'][:scope])) end |