Module: Bureau::Adapter::ClassMethods
- Included in:
- Sequel::Plugins::BureauAdapter::ClassMethods
- Defined in:
- lib/bureau/adapter.rb
Instance Attribute Summary collapse
-
#bureau_config ⇒ Object
Returns the value of attribute bureau_config.
-
#list_options ⇒ Object
Returns the value of attribute list_options.
Instance Method Summary collapse
- #command_plus ⇒ Object
- #command_reload ⇒ Object
- #command_search ⇒ Object
- #foreign_key_name(plural = false) ⇒ Object
- #human_name ⇒ Object
- #human_plural_name ⇒ Object
- #list_title ⇒ Object
- #list_view(r) ⇒ Object
- #list_view_header ⇒ Object
- #many_to_many_picker ⇒ Object
- #sortable_on_that_page? ⇒ Boolean
Instance Attribute Details
#bureau_config ⇒ Object
Returns the value of attribute bureau_config.
5 6 7 |
# File 'lib/bureau/adapter.rb', line 5 def bureau_config @bureau_config end |
#list_options ⇒ Object
Returns the value of attribute list_options.
5 6 7 |
# File 'lib/bureau/adapter.rb', line 5 def end |
Instance Method Details
#command_plus ⇒ Object
33 34 35 36 37 38 |
# File 'lib/bureau/adapter.rb', line 33 def command_plus o = path = "#{o[:path]}/#{self.name}?_no_wrap=true&_destination=#{::Rack::Utils::escape(o[:destination])}" o[:filter].each{|k,v|path<<"&model[#{k}]=#{::Rack::Utils::escape(v)}"} unless o[:filter].nil? "<a href='#{path}' class='btn btn-plus push-stack' title='Create'></a>\n" end |
#command_reload ⇒ Object
29 30 31 |
# File 'lib/bureau/adapter.rb', line 29 def command_reload "<a class='btn btn-reload' href='#' title='Reload'></a>\n" end |
#command_search ⇒ Object
40 41 42 43 |
# File 'lib/bureau/adapter.rb', line 40 def command_search o = "<form action='#{o[:destination]}' method='GET' class='search'>Search:<input type='search' name='q' value='#{o[:request]['q']}' /><input type='submit' value='Search' /></form>" end |
#foreign_key_name(plural = false) ⇒ Object
11 |
# File 'lib/bureau/adapter.rb', line 11 def foreign_key_name(plural=false); "id#{'s' if plural}_"+self.name; end |
#human_name ⇒ Object
12 |
# File 'lib/bureau/adapter.rb', line 12 def human_name; self.name.gsub(/([A-Z])/, ' \1')[1..-1]; end |
#human_plural_name ⇒ Object
13 |
# File 'lib/bureau/adapter.rb', line 13 def human_plural_name; human_name+'s'; end |
#list_title ⇒ Object
14 |
# File 'lib/bureau/adapter.rb', line 14 def list_title; human_plural_name; end |
#list_view(r) ⇒ Object
7 8 9 |
# File 'lib/bureau/adapter.rb', line 7 def list_view(r) "Override Me -- #{self.name}#list_view" end |
#list_view_header ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/bureau/adapter.rb', line 16 def list_view_header o = out = "<h2 class='list-title slide-title'><span>#{list_title}</span><div class='nut-tree-toolbar'>" out << command_plus unless bureau_config[:no_plus] out << command_reload out << command_search unless bureau_config[:no_search] out << "</div></h2>\n" end |
#many_to_many_picker ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bureau/adapter.rb', line 45 def many_to_many_picker opts = klass = bureau_config[:minilist_class].is_a?(Symbol) ? Kernel.const_get(bureau_config[:minilist_class]) : bureau_config[:minilist_class] klass. = params_sample = (opts[:filter]||{}).map{|k,v| "model[#{k}]=#{::Rack::Utils::escape(v)}" } params_sample << "model[#{klass.foreign_key_name}]=" o = "<div class='many-to-many-picker' rel='#{params_sample.join('&')}'>\n" o << "<div class='many-to-many-search'>Filter:<input type='search' class='minisearch' name='minisearch' /> Drag and Drop what you want to add</div>\n" o << "<div class='minilist-wrapper'>\n" o << klass.minilist_view o << "</div>\n" o << "</div>\n" end |
#sortable_on_that_page? ⇒ Boolean
25 26 27 |
# File 'lib/bureau/adapter.rb', line 25 def sortable_on_that_page? false end |