Skip to content

Commit

Permalink
added content_type column
Browse files Browse the repository at this point in the history
  • Loading branch information
drobin03 committed Apr 27, 2015
1 parent 733b357 commit f83f543
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 2 additions & 5 deletions app/assets/javascripts/smithy/assets.js.coffee
Expand Up @@ -5,11 +5,8 @@ $('#assets').DataTable {
"ajax": $('#assets').attr('data-source'),
"order": [[1, 'asc']],
"columnDefs": [
{ "targets": [0,3], "searchable": false, "orderable": false },
{ "targets": [0], "className": "preview" },
{ "targets": [1], "className": "name" },
{ "targets": [2], "className": "size" },
{ "targets": [3], "className": "actions" }
{ "targets": [0,4], "searchable": false, "orderable": false },
{ "targets": [0], "className": "preview" }
]
}

Expand Down
5 changes: 3 additions & 2 deletions app/models/smithy/assets_datatable.rb
Expand Up @@ -23,6 +23,7 @@ def data
preview_link(asset),
asset.name,
number_to_human_size(asset.file_size),
asset.content_type,
"#{link_to "Edit", [:edit, asset], class: "btn btn-primary btn-xs"} #{link_to "Delete", asset, class: "btn btn-danger btn-xs", method: :delete, data: { confirm: "Are you sure?" }}"
]
end
Expand All @@ -37,7 +38,7 @@ def fetch_assets
assets = assets.page(page).per(per_page)
# TODO: need to check for regex flag
if params[:search][:value].present?
assets = assets.where("name like :search", search: "%#{params[:search][:value]}%")
assets = assets.where("name like :search or content_type like :search", search: "%#{params[:search][:value]}%")
end
assets
end
Expand All @@ -63,7 +64,7 @@ def per_page
end

def sort_column
columns = %w[preview name file_size actions]
columns = %w[preview name file_size content_type actions]
columns[params[:order][:"0"][:column].to_i]
end

Expand Down
1 change: 1 addition & 0 deletions app/views/smithy/assets/index.html.erb
Expand Up @@ -15,6 +15,7 @@
<th style="width:10%;">Preview</th>
<th>Name</th>
<th>Size</th>
<th>Type</th>
<th>Actions</th>
</tr>
</thead>
Expand Down

0 comments on commit f83f543

Please sign in to comment.