parent
4cc1989932
commit
36ca5faf32
|
@ -12,6 +12,7 @@ class ArchivesController < ApplicationController
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
@@total_pages = 1
|
@@total_pages = 1
|
||||||
cats_last = []
|
cats_last = []
|
||||||
|
sort_order = (ArchiveSortOrder.first['sort_order'] rescue false) ? 1 : -1 #Order with ascending
|
||||||
if !params['title'].nil?
|
if !params['title'].nil?
|
||||||
files_by_category = ArchiveFile.where(is_hidden: false).order_by(:created_at => "desc").group_by(&:category)
|
files_by_category = ArchiveFile.where(is_hidden: false).order_by(:created_at => "desc").group_by(&:category)
|
||||||
categories = files_by_category.keys
|
categories = files_by_category.keys
|
||||||
|
@ -20,7 +21,8 @@ class ArchivesController < ApplicationController
|
||||||
url_to_edit = ""
|
url_to_edit = ""
|
||||||
flag = false
|
flag = false
|
||||||
archives = []
|
archives = []
|
||||||
files_by_category[category].each do |archive|
|
serial_number = 0
|
||||||
|
files_by_category[category].each_with_index do |archive,idx|
|
||||||
if archive.title == params['title']
|
if archive.title == params['title']
|
||||||
flag = true
|
flag = true
|
||||||
statuses = archive.statuses_with_classname.collect do |status|
|
statuses = archive.statuses_with_classname.collect do |status|
|
||||||
|
@ -34,19 +36,23 @@ class ArchivesController < ApplicationController
|
||||||
if file.choose_lang.include?(I18n.locale.to_s)
|
if file.choose_lang.include?(I18n.locale.to_s)
|
||||||
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
||||||
extension = file.file.file.extension.downcase rescue ""
|
extension = file.file.file.extension.downcase rescue ""
|
||||||
|
serial_number += 1
|
||||||
files << {
|
files << {
|
||||||
"file-name" => title,
|
"file-name" => title,
|
||||||
"file-type" => extension,
|
"file-type" => extension,
|
||||||
"file-url" => "/xhr/archive/download?file=#{file.id}"
|
"file-url" => "/xhr/archive/download?file=#{file.id}",
|
||||||
|
"serial_number" => serial_number
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if archive.urls.present?
|
if archive.urls.present?
|
||||||
archive.urls.each_with_index do |url,i|
|
archive.urls.each_with_index do |url,i|
|
||||||
|
serial_number += 1
|
||||||
files << {
|
files << {
|
||||||
"file-name" => archive.title,
|
"file-name" => archive.title,
|
||||||
"file-type" => archive.get_url_text(i),
|
"file-type" => archive.get_url_text(i),
|
||||||
"file-url" => url
|
"file-url" => url,
|
||||||
|
"serial_number" => serial_number
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -59,7 +65,8 @@ class ArchivesController < ApplicationController
|
||||||
"statuses" => statuses,
|
"statuses" => statuses,
|
||||||
"sort_number" => archive.sort_number,
|
"sort_number" => archive.sort_number,
|
||||||
"is_top" => (archive.is_top ? 1 : 0),
|
"is_top" => (archive.is_top ? 1 : 0),
|
||||||
"files" => files
|
"files" => files,
|
||||||
|
"idx" => (idx + 1)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -110,8 +117,9 @@ class ArchivesController < ApplicationController
|
||||||
url_to_edit = OrbitHelper.current_user ? "/admin/archive_files?filters[tags][]=#{tag_id}" : ""
|
url_to_edit = OrbitHelper.current_user ? "/admin/archive_files?filters[tags][]=#{tag_id}" : ""
|
||||||
taggings = Tagging.where(:tag_id=>tag_id).pluck(:taggable_id)
|
taggings = Tagging.where(:tag_id=>tag_id).pluck(:taggable_id)
|
||||||
archives = archive_files.where(:id.in=>taggings).to_a
|
archives = archive_files.where(:id.in=>taggings).to_a
|
||||||
|
serial_number = 0
|
||||||
if archives.count != 0
|
if archives.count != 0
|
||||||
archives = archives.map do |archive|
|
archives = archives.sort_by{|k| [(k["is_top"] ? 0 : 1) ,sort_order * (k["sort_number"].nil? ? Float::INFINITY : k["sort_number"].to_i),-k["created_at"].to_i]}.map.with_index do |archive,idx|
|
||||||
statuses = archive.statuses_with_classname.collect do |status|
|
statuses = archive.statuses_with_classname.collect do |status|
|
||||||
{
|
{
|
||||||
"status" => status["name"] || "",
|
"status" => status["name"] || "",
|
||||||
|
@ -123,19 +131,23 @@ class ArchivesController < ApplicationController
|
||||||
if file.choose_lang.include?(I18n.locale.to_s)
|
if file.choose_lang.include?(I18n.locale.to_s)
|
||||||
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
||||||
extension = file.file.file.extension.downcase rescue ""
|
extension = file.file.file.extension.downcase rescue ""
|
||||||
|
serial_number += 1
|
||||||
files << {
|
files << {
|
||||||
"file-name" => title,
|
"file-name" => title,
|
||||||
"file-type" => extension,
|
"file-type" => extension,
|
||||||
"file-url" => "/xhr/archive/download?file=#{file.id}"
|
"file-url" => "/xhr/archive/download?file=#{file.id}",
|
||||||
|
"serial_number" => serial_number
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if archive.urls.present?
|
if archive.urls.present?
|
||||||
archive.urls.each_with_index do |url,i|
|
archive.urls.each_with_index do |url,i|
|
||||||
|
serial_number += 1
|
||||||
files << {
|
files << {
|
||||||
"file-name" => archive.title,
|
"file-name" => archive.title,
|
||||||
"file-type" => archive.get_url_text(i),
|
"file-type" => archive.get_url_text(i),
|
||||||
"file-url" => url
|
"file-url" => url,
|
||||||
|
"serial_number" => serial_number
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -148,12 +160,12 @@ class ArchivesController < ApplicationController
|
||||||
"statuses" => statuses,
|
"statuses" => statuses,
|
||||||
"sort_number" => archive.sort_number,
|
"sort_number" => archive.sort_number,
|
||||||
"is_top" => (archive.is_top ? 1 : 0),
|
"is_top" => (archive.is_top ? 1 : 0),
|
||||||
"files" => files
|
"files" => files,
|
||||||
|
"idx" => (idx + 1)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
each_data_count.push(archives.length)
|
each_data_count.push(archives.length)
|
||||||
sorted = archives.sort_by{|k,v| -k["sort_number"].to_i}
|
sorted = archives
|
||||||
sorted = sorted.sort{|k,v| v["is_top"] <=> k["is_top"]}
|
|
||||||
cats << {
|
cats << {
|
||||||
"category-title" => Tag.find(tag_id).name,
|
"category-title" => Tag.find(tag_id).name,
|
||||||
"archives" => sorted,
|
"archives" => sorted,
|
||||||
|
@ -169,7 +181,8 @@ class ArchivesController < ApplicationController
|
||||||
categories_sort = get_sorted_cat_with_filter(categories,'orm')
|
categories_sort = get_sorted_cat_with_filter(categories,'orm')
|
||||||
cats = categories_sort.collect do |category|
|
cats = categories_sort.collect do |category|
|
||||||
url_to_edit = OrbitHelper.user_has_cateogry?(category) ? "/admin/archive_files?filters[category][]=#{category.id.to_s}" : ""
|
url_to_edit = OrbitHelper.user_has_cateogry?(category) ? "/admin/archive_files?filters[category][]=#{category.id.to_s}" : ""
|
||||||
archives = files_by_category[category].collect do |archive|
|
serial_number = 0
|
||||||
|
archives = files_by_category[category].sort_by{|k| [(k["is_top"] ? 0 : 1) ,sort_order * (k["sort_number"].nil? ? Float::INFINITY : k["sort_number"].to_i),-k["created_at"].to_i]}.collect.with_index do |archive,idx|
|
||||||
statuses = archive.statuses_with_classname.collect do |status|
|
statuses = archive.statuses_with_classname.collect do |status|
|
||||||
{
|
{
|
||||||
"status" => status["name"] || "",
|
"status" => status["name"] || "",
|
||||||
|
@ -179,21 +192,25 @@ class ArchivesController < ApplicationController
|
||||||
files = []
|
files = []
|
||||||
archive.archive_file_multiples.order_by(:sort_number=>'desc').each do |file|
|
archive.archive_file_multiples.order_by(:sort_number=>'desc').each do |file|
|
||||||
if file.choose_lang.include?(I18n.locale.to_s)
|
if file.choose_lang.include?(I18n.locale.to_s)
|
||||||
|
serial_number += 1
|
||||||
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
|
||||||
extension = file.file.file.extension.downcase rescue ""
|
extension = file.file.file.extension.downcase rescue ""
|
||||||
files << {
|
files << {
|
||||||
"file-name" => title,
|
"file-name" => title,
|
||||||
"file-type" => extension,
|
"file-type" => extension,
|
||||||
"file-url" => "/xhr/archive/download?file=#{file.id}"
|
"file-url" => "/xhr/archive/download?file=#{file.id}",
|
||||||
|
"serial_number" => serial_number
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if archive.urls.present?
|
if archive.urls.present?
|
||||||
archive.urls.each_with_index do |url,i|
|
archive.urls.each_with_index do |url,i|
|
||||||
|
serial_number += 1
|
||||||
files << {
|
files << {
|
||||||
"file-name" => archive.title,
|
"file-name" => archive.title,
|
||||||
"file-type" => archive.get_url_text(i),
|
"file-type" => archive.get_url_text(i),
|
||||||
"file-url" => url
|
"file-url" => url,
|
||||||
|
"serial_number" => serial_number
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -206,27 +223,18 @@ class ArchivesController < ApplicationController
|
||||||
"statuses" => statuses,
|
"statuses" => statuses,
|
||||||
"sort_number" => archive.sort_number,
|
"sort_number" => archive.sort_number,
|
||||||
"is_top" => (archive.is_top ? 1 : 0),
|
"is_top" => (archive.is_top ? 1 : 0),
|
||||||
"files" => files
|
"files" => files,
|
||||||
|
"idx" => (idx + 1)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
each_data_count.push(archives.length)
|
each_data_count.push(archives.length)
|
||||||
sorted = archives.sort_by{|k,v| -k["sort_number"].to_i}
|
sorted = archives
|
||||||
sorted = sorted.sort{|k,v| v["is_top"] <=> k["is_top"]}
|
|
||||||
{
|
{
|
||||||
"category-title" => category.title,
|
"category-title" => category.title,
|
||||||
"archives" => sorted,
|
"archives" => sorted,
|
||||||
"url_to_edit" => url_to_edit
|
"url_to_edit" => url_to_edit
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if ArchiveSortOrder.first['sort_order'] #Order with ascending
|
|
||||||
cats = cats.collect do |cat|
|
|
||||||
Hash[cat.map{|k,v| [k,k=='archives' ? (v.sort_by{|tp| [(tp['sort_number'].nil? ? Float::INFINITY : tp['sort_number'].to_i),-tp['created_at']]}) : v] }]
|
|
||||||
end
|
|
||||||
else
|
|
||||||
cats = cats.collect do |cat|
|
|
||||||
Hash[cat.map{|k,v| [k,k=='archives' ? (v.sort_by{|tp| [(tp['sort_number'].nil? ? Float::INFINITY : -tp['sort_number'].to_i),-tp['created_at']]}) : v] }]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if page_data_count != 0
|
if page_data_count != 0
|
||||||
all_data_count = 0
|
all_data_count = 0
|
||||||
data_start = -1
|
data_start = -1
|
||||||
|
@ -280,8 +288,9 @@ class ArchivesController < ApplicationController
|
||||||
{
|
{
|
||||||
"categories" => cats_last,
|
"categories" => cats_last,
|
||||||
"extras" =>{
|
"extras" =>{
|
||||||
|
"serial_number-head" => I18n.t("archive.serial_number"),
|
||||||
"date-head" => I18n.t("archive.updated_at"),
|
"date-head" => I18n.t("archive.updated_at"),
|
||||||
"title-head" => I18n.t("archive.Title"),
|
"title-head" => I18n.t(:name),
|
||||||
"description-head"=>I18n.t("archive.description"),
|
"description-head"=>I18n.t("archive.description"),
|
||||||
"file-head" =>I18n.t("archive.download_file")
|
"file-head" =>I18n.t("archive.download_file")
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,22 @@ all_template.each do |folder|
|
||||||
"en" => "9. Table list - Simple (widget-title, download link)"
|
"en" => "9. Table list - Simple (widget-title, download link)"
|
||||||
},
|
},
|
||||||
"thumbnail" => "ar9.png"
|
"thumbnail" => "ar9.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" => "archive_index10",
|
||||||
|
"name" => {
|
||||||
|
"zh_tw" => "10. 表格列表 ( 模組標題, 類別標題, 編號, 檔案名稱, 下載連結 )",
|
||||||
|
"en" => "10. Table list (widget-title, category, Serial Number, filename, download link)"
|
||||||
|
},
|
||||||
|
"thumbnail" => "ar5.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" => "archive_index11",
|
||||||
|
"name" => {
|
||||||
|
"zh_tw" => "11. 表格列表 - 簡約 - 展開檔案 ( 模組標題, 類別標題, 編號, 檔案名稱, 下載連結 )",
|
||||||
|
"en" => "11. Table list - Simple - Unfold Files (widget-title, category, Serial Number, filename, download link)"
|
||||||
|
},
|
||||||
|
"thumbnail" => "ar9.png"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
flags = []
|
flags = []
|
||||||
|
|
|
@ -2,6 +2,7 @@ en:
|
||||||
restful_actions:
|
restful_actions:
|
||||||
categories_order: Categories Order
|
categories_order: Categories Order
|
||||||
archive:
|
archive:
|
||||||
|
serial_number: "Serial Number"
|
||||||
url_text: "URL Text"
|
url_text: "URL Text"
|
||||||
url_text_hint: "URL Text, default: link"
|
url_text_hint: "URL Text, default: link"
|
||||||
updated_at: Updated At
|
updated_at: Updated At
|
||||||
|
|
|
@ -2,6 +2,7 @@ zh_tw:
|
||||||
restful_actions:
|
restful_actions:
|
||||||
categories_order: 類別排序
|
categories_order: 類別排序
|
||||||
archive:
|
archive:
|
||||||
|
serial_number: "編號"
|
||||||
url_text: "連結文字"
|
url_text: "連結文字"
|
||||||
url_text_hint: "連結文字,預設為link"
|
url_text_hint: "連結文字,預設為link"
|
||||||
updated_at: 上傳日期
|
updated_at: 上傳日期
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<div class="i-archive index-archive-5 index-archive-10">
|
||||||
|
<h3 class="i-archive-title">
|
||||||
|
<span>{{page-title}}</span>
|
||||||
|
</h3>
|
||||||
|
<div class="i-archive__list list-unstyled" id="index-archive-group" data-list="categories" data-level="0">
|
||||||
|
<h4 class="i-archive__category-title">{{category-title}}</h4>
|
||||||
|
<table class="i-items table-bordered">
|
||||||
|
<thead class="thead row">
|
||||||
|
<tr>
|
||||||
|
<th class="col-sm-2 date-thead">{{serial_number-head}}</th>
|
||||||
|
<th class="col-sm-7 title-thead">{{title-head}}</th>
|
||||||
|
<th class="col-sm-3 file-thead">{{file-head}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="tbody i-archive__category-list" data-list="archives" data-level="1">
|
||||||
|
<tr class="archive-items">
|
||||||
|
<td class="i-archive__serial_number col-sm-2">{{idx}}</td>
|
||||||
|
<td class="head col-sm-7">
|
||||||
|
{{archive-title}}
|
||||||
|
<span class="i-archive__status-wrap" data-list="statuses" data-level="2">
|
||||||
|
<span class="i-archive__status label status {{status-class}}">{{status}}</span>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="i-archive__file-list col-sm-3" data-list="files" data-level="2">
|
||||||
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary">{{file-type}}</span></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</div>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,34 @@
|
||||||
|
<div class="i-archive index-archive-9">
|
||||||
|
<h3 class="i-archive-title">
|
||||||
|
<span>{{page-title}}</span>
|
||||||
|
</h3>
|
||||||
|
<div class="i-archive__list list-unstyled" id="index-archive-group" data-list="categories" data-level="0">
|
||||||
|
<h4 class="i-archive__category-title">{{category-title}}</h4>
|
||||||
|
<table class="i-items table table-bordered">
|
||||||
|
<thead class="thead">
|
||||||
|
<tr>
|
||||||
|
<th class="col-sm-2 title-thead">{{serial_number-head}}</th>
|
||||||
|
<th class="col-sm-7 title-thead">{{title-head}}</th>
|
||||||
|
<th class="col-sm-3 file-thead">{{file-head}}</th>
|
||||||
|
</th>
|
||||||
|
</thead>
|
||||||
|
<tbody class="tbody" >
|
||||||
|
<span data-list="archives" data-level="1">
|
||||||
|
<span data-list="files" data-level="2">
|
||||||
|
<tr class="archive-items">
|
||||||
|
<td class="col-sm-2">
|
||||||
|
<span class="i-archive__serial_number">{{serial_number}}</span>
|
||||||
|
</td>
|
||||||
|
<td class="col-sm-7">
|
||||||
|
<a class="i-archive__file-name" href="{{file-url}}" target="_blank" title="{{file-name}}">{{file-name}}</a>
|
||||||
|
</td>
|
||||||
|
<td class="col-sm-3">
|
||||||
|
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" data-toggle="tooltip" data-placement="bottom" title="{{file-name}}"><span class="label label-primary">{{file-type}}</span></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -68,7 +68,23 @@
|
||||||
"filename" : "archive_index9",
|
"filename" : "archive_index9",
|
||||||
"name" : {
|
"name" : {
|
||||||
"zh_tw" : "9. 表格列表 - 簡約 ( 模組標題, 檔案名稱, 下載連結 )",
|
"zh_tw" : "9. 表格列表 - 簡約 ( 模組標題, 檔案名稱, 下載連結 )",
|
||||||
"en" : "9. Table list - Simple (widget-title, download link)"
|
"en" : "9. Table list - Simple (widget-title, filename, download link)"
|
||||||
|
},
|
||||||
|
"thumbnail" : "ar9.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "archive_index10",
|
||||||
|
"name" : {
|
||||||
|
"zh_tw" : "10. 表格列表 ( 模組標題, 類別標題, 編號, 檔案名稱, 下載連結 )",
|
||||||
|
"en" : "10. Table list (widget-title, category, Serial Number, filename, download link)"
|
||||||
|
},
|
||||||
|
"thumbnail" : "ar5.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "archive_index11",
|
||||||
|
"name" : {
|
||||||
|
"zh_tw" : "11. 表格列表 - 簡約 - 展開檔案 ( 模組標題, 類別標題, 編號, 檔案名稱, 下載連結 )",
|
||||||
|
"en" : "11. Table list - Simple - Unfold Files (widget-title, category, Serial Number, filename, download link)"
|
||||||
},
|
},
|
||||||
"thumbnail" : "ar9.png"
|
"thumbnail" : "ar9.png"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue