Module: Bureau::Adapter::InstanceMethods

Included in:
MongoBureau, Sequel::Plugins::BureauAdapter::InstanceMethods
Defined in:
lib/bureau/adapter.rb

Instance Method Summary collapse

Instance Method Details

#cloning_backend_columnsObject

Override the clone column list from RackBackendAPI



103
104
105
# File 'lib/bureau/adapter.rb', line 103

def cloning_backend_columns
  model.respond_to?(:stash) ? (default_backend_columns - model.stash_reflection.keys) : default_backend_columns
end

#in_nutshellObject



69
70
71
72
73
74
# File 'lib/bureau/adapter.rb', line 69

def in_nutshell
  o = model.list_options
        out = "<div class='in-nutshell'>\n"
        out << self.to_bureau_thumb('nutshell.jpg') if self.respond_to?(:to_bureau_thumb)
        out << "</div>\n"
end

#nutshell_backend_columnsObject

Default list of columns for nutshell



107
# File 'lib/bureau/adapter.rb', line 107

def nutshell_backend_columns; default_backend_columns; end

#nutshell_childrenObject



86
# File 'lib/bureau/adapter.rb', line 86

def nutshell_children; ''; end

#nutshell_headerObject



63
64
65
66
67
68
# File 'lib/bureau/adapter.rb', line 63

def nutshell_header
  o = model.list_options
  out = "<div class='nutshell-header'><div class='nutshell-title' title='#{self.to_label}'>#{self.to_label}</div>"
  out << "<div class='sortable-handle btn' title='Drag Me'></div>\n" if o[:sortable]
  out << "</div>\n"
end

#nutshell_toolbarObject



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/bureau/adapter.rb', line 75

def nutshell_toolbar
  o = model.list_options
  class_path = "#{o[:path]}/#{model.name}"
  path = "#{class_path}/#{self.id}"
  out = "<div class='nutshell-toolbar'>Tools:"
  out << "#{self.backend_delete_form(path, :destination=>o[:destination])}<div class='btn btn-delete' title='Delete'></div>\n" unless model.bureau_config[:no_delete]
  out << "#{self.backend_clone_form(class_path, :destination=>o[:destination])}<div class='btn btn-clone' title='Clone'></div>\n" unless (model.bureau_config[:no_plus]||model.bureau_config[:no_clone])
  out << "<a href='#{preview_on_frontend}#{preview_on_frontend.match(/\?/) ? '&' : '?'}_preview=true' class='btn btn-preview' target='_blank' title='Preview'></a>\n" unless preview_on_frontend.nil?
  out << "<a href='#{path}?_no_wrap=true&_destination=#{::Rack::Utils::escape(o[:destination])}' class='btn btn-edit push-stack' title='Edit'></a>\n" unless model.bureau_config[:no_edit]
  out << "</div>\n"
end

#placeholder_thumb(size) ⇒ Object



97
98
99
100
# File 'lib/bureau/adapter.rb', line 97

def placeholder_thumb(size)
  o = model.list_options
  "<img src='#{o[:path]}/_static/img/placeholder.#{size.gsub(/^(.*)_([a-zA-Z]+)$/, '\1.\2')}' />\n"
end

#preview_on_frontendObject

Meant to be ovveridden with a link to see the entry in the frontend if applicable



109
# File 'lib/bureau/adapter.rb', line 109

def preview_on_frontend; nil; end

#to_nutshellObject



88
89
90
91
92
93
94
95
# File 'lib/bureau/adapter.rb', line 88

def to_nutshell
  out = "<li class='nutshell nutshell-#{model.name}' id='#{model.name}-#{self.id}' data-scene-selector-coordinates='#{self.scene_selector_coordinates if self.respond_to?(:scene_selector_coordinates)}'>"
  out << nutshell_header
  out << in_nutshell
  out << nutshell_toolbar
  out << nutshell_children
  out << "</li>"
end