55 lines
1.8 KiB
Ruby
55 lines
1.8 KiB
Ruby
module FileManagersHelper
|
|
def fa_icon(icon_name, text="")
|
|
"<i class=\"fa fa-#{icon_name}\">#{text}</i>".html_safe
|
|
end
|
|
def generate_breadcrumb
|
|
breadcrumb_contents = ""
|
|
url_infos = [
|
|
{
|
|
type: "key",
|
|
key: "all",
|
|
trans: I18n.t(:all)
|
|
}
|
|
]
|
|
if @module_key != 'all'
|
|
url_infos << {
|
|
type: "key",
|
|
key: @module_key,
|
|
trans: @module_title
|
|
}
|
|
end
|
|
if @recycle_bin || (@upload_item && @upload_item.is_trash)
|
|
url_infos << {
|
|
type: "recycle",
|
|
key: (@upload_item ? @upload_item.module : nil),
|
|
trans: I18n.t("file_manager.recycle_bin")
|
|
}
|
|
end
|
|
if @file
|
|
filename = @upload_item.filename
|
|
version = @upload_item.version
|
|
if @upload_item.is_trash && @upload_item.file_manager_trash.record_only
|
|
filename += " (version #{version})"
|
|
end
|
|
url_infos << {
|
|
type: "file",
|
|
trans: filename
|
|
}
|
|
end
|
|
last_idx = url_infos.count - 1
|
|
url_infos.each_with_index do |info, i|
|
|
if i == last_idx
|
|
breadcrumb_contents += info[:trans]
|
|
else
|
|
if info[:type] == 'recycle'
|
|
breadcrumb_contents += "<a href=\"javascript:void(0)\" class=\"recycle_bin\" data-key=\"#{info[:key]}\">#{info[:trans]}</a>"
|
|
else
|
|
breadcrumb_contents += "<a href=\"javascript:void(0)\" data-key=\"#{info[:key]}\" class=\"module-key\">#{info[:trans]}</a>"
|
|
end
|
|
breadcrumb_contents += "<span class=\"separator\">/</span>"
|
|
end
|
|
end
|
|
breadcrumb_contents.html_safe
|
|
end
|
|
end
|