Skip to content

Commit

Permalink
feature(attachments): вынос в гем блока с прикрепленными файлами
Browse files Browse the repository at this point in the history
  • Loading branch information
kozyrk committed Apr 18, 2017
1 parent b5ac1f3 commit 70c2716
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/assets/stylesheets/amazon_assets/file_item.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import './icons';
@import './functions';

.file-item {
display: inline-block; color: #333; font-size: 12px;
&.fi-mod-with-icon:before { content: ''; display: inline-block; vertical-align: middle; width: 20px; height: 20px; margin: 0 10px 0 0; background-size: contain !important; }
.fi-content { display: inline-block; vertical-align: middle; }
.fi-title { display: inline-block; max-width: 205px; vertical-align: middle; margin: 0 10px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #333; text-decoration: underline; }
.fi-size { display: inline-block; vertical-align: middle; color: #999; margin: 2px 0 0; }
}
@each $icon in $icons {
$icon-name: nth($icon, 1);
.file-item.fi-mod-with-icon.#{$icon-name}:before { content: get-icon-url($icon-name); }
}
13 changes: 13 additions & 0 deletions app/views/apress/amazon_assets/_file_item.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
:ruby
class_name = []
class_name << "#{local_assigns[:className]} #{file_ext_name(attachment.file_name)}"
class_name << 'fi-mod-with-icon' if local_assigns[:with_icon]

%a.file-item{href: current_user.present? ? attachment.file.to_s : '#',
class: class_name,
download: true,
data: local_assigns[:data],
title: t('views.apress.amazon_assets.file_item.title')}
.fi-content>
.fi-title>= attachment.origin_file_name
.fi-size>= number_to_human_size(attachment.local_file_size).tr(' ', '')
2 changes: 2 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ ru:
required_field: 'Не может быть пустым'
titles:
detach: 'Удалить файл'
file_item:
title: 'Скачать файл'

0 comments on commit 70c2716

Please sign in to comment.