app/models/smithy/assets_datatable.rb in smithycms-0.6.1 vs app/models/smithy/assets_datatable.rb in smithycms-0.6.2
- old
+ new
@@ -1,11 +1,11 @@
module Smithy
class AssetsDatatable
include AssetsHelper
delegate :params, :link_to, :image_tag, :number_to_human_size, :attachment_url, :attachment_image_tag, :file_type_icon, :check_box_tag, :render, to: :@view
- def initialize(view, view_type)
+ def initialize(view, view_type='index_view')
@view = view
@view_type = view_type
end
def as_json(options = {})
@@ -36,19 +36,21 @@
[
"/smithy/assets/#{asset.id}",
asset_preview_link(asset),
asset.name,
number_to_human_size(asset.file_size),
- asset.file_content_type
+ asset.file_content_type,
+ asset.updated_at.strftime('%b %e, %Y %H:%M:%S')
]
else
[
check_box_tag('ids[]', asset.id, false, class: "delete"),
asset_preview_link(asset),
asset.name,
number_to_human_size(asset.file_size),
asset.file_content_type,
+ asset.updated_at.strftime('%b %e, %Y %H:%M:%S'),
render(partial: '/smithy/assets/actions', formats: :html, locals: { asset: asset })
]
end
end
@@ -73,10 +75,14 @@
def per_page
params[:length].to_i > 0 ? params[:length].to_i : 10
end
def sort_column
- columns = %w[delete preview name file_size file_content_type actions]
+ if @view_type == 'selector_view'
+ columns = %w[url preview name file_size file_content_type updated_at]
+ else
+ columns = %w[delete preview name file_size file_content_type updated_at actions]
+ end
columns[params[:order][:"0"][:column].to_i]
end
def sort_direction
params[:order][:"0"][:dir] == "desc" ? "desc" : "asc"
\ No newline at end of file