Module: AdminAssistant::Column::IndexViewMethods

Instance Method Summary collapse

Instance Method Details

#header_css_classObject



119
120
121
# File 'lib/admin_assistant/column.rb', line 119

def header_css_class
  "sort #{sort_order}" if sort_order
end

#html(record) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/admin_assistant/column.rb', line 123

def html(record)
  html_for_index_method = "#{name}_html_for_index"
  html = if @action_view.respond_to?(html_for_index_method)
    @action_view.send html_for_index_method, record
  elsif @link_to_args
    @action_view.link_to(
      @action_view.send(:h, string(record)),
      @link_to_args.call(record)
    )
  else
    unconfigured_html(record)
  end
  html = ' ' if html.blank?
  html
end

#next_sort_paramsObject



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/admin_assistant/column.rb', line 139

def next_sort_params
  name_for_sort = name
  next_sort_order = 'asc'
  if sort_order
    if sort_order == 'asc'
      next_sort_order = 'desc'
    else
      name_for_sort = nil
      next_sort_order = nil
    end
  end
  @action_view.params.merge(
    :sort => name_for_sort, :sort_order => next_sort_order
  )
end

#set_instance_variables_from_options(admin_assistant, opts) ⇒ Object



155
156
157
158
159
160
161
162
163
# File 'lib/admin_assistant/column.rb', line 155

def set_instance_variables_from_options(admin_assistant, opts)
  index = opts[:index]
  setting = admin_assistant.index_settings[name.to_sym]
  @link_to_args = setting.link_to_args
  @sort_order = index.sort_order if name == index.sort
  @image_size = setting.image_size
  @ajax_toggle_allowed =
      admin_assistant.update? && setting.ajax_toggle != false
end

#td_css_classes(column, record) ⇒ Object



165
166
167
168
169
170
171
172
173
# File 'lib/admin_assistant/column.rb', line 165

def td_css_classes(column, record)
  css_classes = []
  css_classes << 'sort' if sort_order
  td_css_class_for_index_method = "#{name}_css_class_for_index_td"
  if @action_view.respond_to?(td_css_class_for_index_method)
    css_classes << @action_view.send(td_css_class_for_index_method, record)
  end
  css_classes.reject{ |c| c.blank? }.join(' ')
end

#unconfigured_html(record) ⇒ Object



175
176
177
# File 'lib/admin_assistant/column.rb', line 175

def unconfigured_html(record)
  @action_view.send(:h, string(record))
end