Compare commits

...

2 Commits

Author SHA1 Message Date
BoHung Chiu e4888e1421 Adjust code. 2022-12-26 10:53:23 +08:00
BoHung Chiu 1eecd099f4 Adjust templates. 2022-12-26 10:53:06 +08:00
4 changed files with 71 additions and 6 deletions

View File

@ -41,7 +41,7 @@ class ArchivesController < ApplicationController
if !params['title'].nil? if !params['title'].nil?
files_by_category = ArchiveFile.can_display.sorted.group_by(&:category) files_by_category = ArchiveFile.can_display.sorted.group_by(&:category)
categories = files_by_category.keys categories = files_by_category.keys
categories_sort = get_sorted_cat_with_filter(categories,'orm') categories_sort = get_sorted_cat_with_filter(categories, :orm)
categories_sort.each_with_index do |category, cat_idx| categories_sort.each_with_index do |category, cat_idx|
url_to_edit = "" url_to_edit = ""
flag = false flag = false
@ -144,7 +144,7 @@ class ArchivesController < ApplicationController
files_by_category = ArchiveFile.can_display.filter_by_categories(categories).filter_by_tags(tags).sorted.group_by(&:category) files_by_category = ArchiveFile.can_display.filter_by_categories(categories).filter_by_tags(tags).sorted.group_by(&:category)
each_data_count = [] each_data_count = []
categories = files_by_category.keys categories = files_by_category.keys
categories_sort = get_sorted_cat_with_filter(categories,'orm') categories_sort = get_sorted_cat_with_filter(categories, :orm)
cats = categories_sort.collect.with_index do |category, cat_idx| cats = categories_sort.collect.with_index do |category, cat_idx|
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}" : ""
serial_number = 0 serial_number = 0
@ -332,7 +332,7 @@ class ArchivesController < ApplicationController
categorie_ids = [] categorie_ids = []
if categories.first == "all" if categories.first == "all"
categories = OrbitHelper.widget_module_app.categories categories = OrbitHelper.widget_module_app.categories
categories_sort = get_sorted_cat_with_filter(categories,'orm') categories_sort = get_sorted_cat_with_filter(categories, :orm)
@categories = categories_sort.collect do |cat| @categories = categories_sort.collect do |cat|
cat_id = cat.id.to_s cat_id = cat.id.to_s
categorie_ids << cat_id categorie_ids << cat_id
@ -342,7 +342,7 @@ class ArchivesController < ApplicationController
} }
end end
else else
categories_sort = get_sorted_cat_with_filter(categories,'id') categories_sort = get_sorted_cat_with_filter(categories, :id)
@categories = categories_sort.collect do |cat| @categories = categories_sort.collect do |cat|
cat_id = cat.id.to_s cat_id = cat.id.to_s
categorie_ids << cat_id categorie_ids << cat_id
@ -392,7 +392,7 @@ class ArchivesController < ApplicationController
all_categories_id = all_categories_no_nil.concat(all_categories_with_nil).collect do |cat| all_categories_id = all_categories_no_nil.concat(all_categories_with_nil).collect do |cat|
cat.category_id.to_s cat.category_id.to_s
end end
if cat_type=='id' if cat_type == :id
categories_temp = ModuleApp.where(:key => "archive").first.categories categories_temp = ModuleApp.where(:key => "archive").first.categories
categories = categories_temp.select{|cat| categories.include? cat.id.to_s} categories = categories_temp.select{|cat| categories.include? cat.id.to_s}
end end

View File

@ -48,5 +48,11 @@
$v.css('display', 'none'); $v.css('display', 'none');
} }
}) })
$(document).ready(function(){
var location_id = window.location.hash;
if(location_id && location_id != '' && location_id.length > 1){
$(location_id).addClass('in');
}
})
</script> </script>
</div> </div>

View File

@ -0,0 +1,50 @@
<div class="i-archive index-archive-2 index-archive-14">
<h3 class="i-archive-title">
<span>{{page-title}}</span>
</h3>
<div class="panel-group" id="index-archive-group" data-list="categories" data-level="0">
<div class="panel panel-default" data-list="archives" data-level="1">
<div class="panel-heading" style="padding: 0.625em 0.9375em;">
<h4 class="panel-title">
<i class="fa fa-file-text" aria-hidden="true"></i>
<a data-toggle="collapse" data-parent="#index-archive-group" href="#collapse" class="collapsed" style="padding: 0;display: inline-block;">
{{archive-title}}
<i class="fa fa-chevron-down" aria-hidden="true"></i>
</a>
</h4>
</div>
<div id="collapse" class="panel-collapse collapse {{in_class}}">
<div class="panel-body">
<ul class="i-archive-files-list" data-list="files" data-level="2">
<li>
<a href="{{file-url}}" class="i-archive-files-item" target="_blank" title="{{file-name}}">{{file-name}}</a>
<span class="label label-primary {{file-type}}">{{file-type}}</span>
</li>
</ul>
</div>
</div>
</div>
{{link_to_edit}}
</div>
<style>
.index-archive-12 dt.i-archive-item-list{
float: none;
width: auto;
}
</style>
<script>
$('.index-archive-12 .panel-heading').each(function(i, v){
var $v = $(v);
if($v.text().trim() == ''){
$v.css('display', 'none');
}
})
$(document).ready(function(){
var location_id = window.location.hash;
if(location_id && location_id != '' && location_id.length > 1){
$(location_id).addClass('in');
}
})
</script>
</div>

View File

@ -117,6 +117,15 @@
}, },
"force_cover": "true", "force_cover": "true",
"thumbnail": "ar-tab1.png" "thumbnail": "ar-tab1.png"
},
{
"filename" : "archive_index14",
"name" : {
"zh_tw" : "14. 手風琴式列表 - 有下拉 - 針對各筆資料 ( 模組標題, 標題, 檔案名稱, 下載連結 )",
"en" : "14. Accordion list - with drop down - For every data (widget-title, title, filename, download link)"
},
"force_cover": "true",
"thumbnail" : "ar2.png"
} }
], ],
"widgets" : [ "widgets" : [