Module: Sequel::Plugins::BureauAdapter::InstanceMethods

Includes:
Bureau::Adapter::InstanceMethods
Defined in:
lib/sequel_bureau_adapter.rb

Instance Method Summary collapse

Methods included from Bureau::Adapter::InstanceMethods

#cloning_backend_columns, #nutshell_backend_columns, #nutshell_header, #nutshell_toolbar, #placeholder_thumb, #preview_on_frontend, #to_nutshell

Instance Method Details

#bureau_after_stash(attachment_name) ⇒ Object



177
178
179
180
181
182
183
184
# File 'lib/sequel_bureau_adapter.rb', line 177

def bureau_after_stash(attachment_name)
  current = self.__send__(attachment_name)
  if !current.nil? && current[:type][/^image\//]
    convert(attachment_name, "-resize '100x75^' -gravity center -extent 100x75", 'stash_thumb.gif')
    convert(attachment_name, "-resize '184x138^' -gravity center -extent 184x138", 'nutshell.jpg')
    yield if block_given? # Block is for images transformation so that verification are processed only once
  end
end

#generic_thumb(img, size = 'stash_thumb.gif', obj = self) ⇒ Object



168
169
170
171
172
173
174
175
# File 'lib/sequel_bureau_adapter.rb', line 168

def generic_thumb(img , size='stash_thumb.gif', obj=self)
  current = obj.__send__(img)
  if !current.nil? && current[:type][/^image\//]
    "<img src='#{obj.file_url(img, size)}?#{::Time.now.to_i.to_s}' />\n"
  else
    placeholder_thumb(size)
  end
end

#in_nutshellObject



138
139
140
141
142
143
144
145
146
147
# File 'lib/sequel_bureau_adapter.rb', line 138

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)
      nutshell_backend_columns.select{|col| [:boolean,:select].include?(model.crushyform_schema[col][:type]) }.each do |c|
 column_label = c.to_s.sub(/_id$/, '').tr('_', ' ').capitalize
 out << "<div class='quick-update'><form><span class='column-title'>#{column_label}:</span> #{self.crushyinput(c)}</form></div>\n"
end
      out << "</div>\n"
end

#nutshell_backend_associationsObject



161
162
163
164
165
166
# File 'lib/sequel_bureau_adapter.rb', line 161

def nutshell_backend_associations
@nutshell_backend_associations ||= model.associations.select do |ass|
  t = model.association_reflection(ass)[:type]
  t!=:many_to_one && t!=:many_to_many
 end
end

#nutshell_childrenObject



149
150
151
152
153
154
155
156
157
158
159
# File 'lib/sequel_bureau_adapter.rb', line 149

def nutshell_children
  o = model.list_options
  out = ""
  nutshell_backend_associations.each do |ass|
 ass_ref = model.association_reflection(ass)
 link = "#{o[:path]}/list/#{ass_ref[:class_name]}?filter[#{ass_ref[:key]}]=#{self.id}"
 text = ass_ref[:nutshell_link_text] || "#{ass.to_s.tr('_', ' ').split.map{|s|s.capitalize}.join(" ").sub(/s$/,'(s)')}"
 out << "<a href='#{link}' class='push-stack sublist-link nutshell-child'>#{text} #{self.__send__(ass.to_s+'_dataset').count}</a>\n"
end
out
end