Module: MongoBureau::ClassMethods

Defined in:
lib/mongo_bureau.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#list_optionsObject

Returns the value of attribute list_options.



83
84
85
# File 'lib/mongo_bureau.rb', line 83

def list_options
  @list_options
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)
  @list_options = {:request=>r, :destination=>r.fullpath, :path=>r.script_name, :filter=>r['filter'] }
  @list_options.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(@list_options[:filter]||{}), (self.respond_to?(:list_view_fields) ? {fields: self.list_view_fields} : {})).each do |m| 
      out << m.to_nutshell
    end
  out << "</ul>"
end

#minilist_viewObject



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_selectorObject



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/mongo_bureau.rb', line 112

def scene_selector
  o = @list_options
  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

Returns:

  • (Boolean)


98
99
100
101
# File 'lib/mongo_bureau.rb', line 98

def sortable_on_that_page?
  o = @list_options
  o[:search].nil? && @schema.key?('position') && (@schema['position'][:scope].nil? || (o[:filter]||{}).key?(@schema['position'][:scope]))
end