Add new Accordion list template with expanded setting feature.
This commit is contained in:
parent
32855e3ff3
commit
2226d59446
|
@ -1,4 +1,8 @@
|
|||
class ArchivesController < ApplicationController
|
||||
def self.custom_widget_data
|
||||
ac = ActionController::Base.new
|
||||
ac.render_to_string("archives/custom_widget_data",:locals=>{:@custom_data_field=>@custom_data_field,:@field_name=>@field_name})
|
||||
end
|
||||
#avoid the categories to be not in the ArchiveCategory
|
||||
def serve_cmap
|
||||
serve_path=File.expand_path("../../assets/javascripts/archive/pdf/bcmaps/#{params[:file_name]}.#{params[:extension]}",__FILE__)
|
||||
|
@ -9,8 +13,17 @@ class ArchivesController < ApplicationController
|
|||
end
|
||||
end
|
||||
def index
|
||||
page = OrbitHelper.page rescue nil
|
||||
unless page
|
||||
page = Page.where(url:params['url']).first
|
||||
end
|
||||
params = OrbitHelper.params
|
||||
@@total_pages = 1
|
||||
in_class = ""
|
||||
custom_data_field = page.custom_data_field rescue nil
|
||||
if custom_data_field && custom_data_field["expanded"] == "yes"
|
||||
in_class = "in"
|
||||
end
|
||||
cats_last = []
|
||||
sort_order = (ArchiveSortOrder.first['sort_order'] rescue false) ? 1 : -1 #Order with ascending
|
||||
if !params['title'].nil?
|
||||
|
@ -313,7 +326,8 @@ class ArchivesController < ApplicationController
|
|||
"date-head" => I18n.t("archive.updated_at"),
|
||||
"title-head" => I18n.t(:name),
|
||||
"description-head"=>I18n.t("archive.description"),
|
||||
"file-head" =>I18n.t("archive.download_file")
|
||||
"file-head" =>I18n.t("archive.download_file"),
|
||||
"in_class" => in_class
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<% active_expanded = @custom_data_field[:expanded] rescue nil %>
|
||||
<div class="control-group input-content hide archive_expanded">
|
||||
<label class="control-label muted" for="custom_expanded"><%=t("archive.expanded")%> :</label>
|
||||
<div class="controls">
|
||||
<%= select_tag("#{@field_name}[custom_data_field][expanded]", options_for_select(["yes","no"].map{|opt| [t("archive.#{opt}"),opt]},active_expanded),{:id=>"custom_expanded"})%>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
if($("#page_layout").val() == "archive_index12"){
|
||||
$(".archive_expanded").addClass("show").removeClass("hide");
|
||||
}
|
||||
$("#page_layout").change(function(){
|
||||
var value = $(this).val();
|
||||
if(value == "archive_index12"){
|
||||
$(".archive_expanded").addClass("show").removeClass("hide");
|
||||
}else{
|
||||
$(".archive_expanded").removeClass("show").addClass("hide");
|
||||
}
|
||||
})
|
||||
</script>
|
|
@ -1,2 +1,8 @@
|
|||
<%= render_view %>
|
||||
<% data = action_data %>
|
||||
<% if data["categories"].length == 1 %>
|
||||
<script>
|
||||
$("#main-content .panel-collapse").addClass("in");
|
||||
</script>
|
||||
<% end %>
|
||||
<%= create_pagination(ArchivesController.get_total_pages).html_safe %>
|
219
archive.gemspec
219
archive.gemspec
|
@ -3,117 +3,128 @@ $:.push File.expand_path("../lib", __FILE__)
|
|||
# Maintain your gem's version:
|
||||
require "archive/version"
|
||||
require 'json'
|
||||
env_pwd = ENV['PWD']
|
||||
app_path = File.expand_path(__dir__)
|
||||
template_path = env_pwd + '/app/templates'
|
||||
all_template = Dir.glob(template_path+'/*/')
|
||||
all_template.each do |folder|
|
||||
if !folder.include?('mobile')
|
||||
begin
|
||||
next unless File.exist?("#{folder}modules/archive/info.json")
|
||||
info_json_file = "#{folder}modules/archive/info.json"
|
||||
info_json = JSON.parse(File.read(info_json_file))
|
||||
check_files = ["archive_index7.html.erb","archive_index8.html.erb","archive_index9.html.erb","archive_index10.html.erb","archive_index11.html.erb"]
|
||||
old_file_infos = [
|
||||
{
|
||||
"filename" => "archive_index7",
|
||||
"name" => {
|
||||
"zh_tw" => "7. 表格列表 ( 模組標題, 類別標題, 檔案名稱, 檔案簡介, 下載連結 )",
|
||||
"en" => "7. Table list (widget-title, category, filename, download link)"
|
||||
},
|
||||
"thumbnail" => "ar5.png"
|
||||
},
|
||||
{
|
||||
"filename" => "archive_index8",
|
||||
"name" => {
|
||||
"zh_tw" => "8. 表格列表 ( 模組標題, 檔案名稱, 檔案簡介, 下載連結 )",
|
||||
"en" => "8. Table list (widget-title, filename, download link)"
|
||||
},
|
||||
"thumbnail" => "ar5.png"
|
||||
}
|
||||
]
|
||||
new_file_infos = [
|
||||
{
|
||||
"filename" => "archive_index7",
|
||||
"name" => {
|
||||
"zh_tw" => "7. 表格列表 ( 模組標題, 類別標題, 上傳日期, 檔案名稱, 檔案簡介, 下載連結 )",
|
||||
"en" => "7. Table list (widget-title, category, Updated At, filename, download link)"
|
||||
},
|
||||
"thumbnail" => "ar5.png"
|
||||
},
|
||||
{
|
||||
"filename" => "archive_index8",
|
||||
"name" => {
|
||||
"zh_tw" => "8. 表格列表 ( 模組標題, 上傳日期, 檔案名稱, 檔案簡介, 下載連結 )",
|
||||
"en" => "8. Table list (widget-title, Updated At, filename, download link)"
|
||||
},
|
||||
"thumbnail" => "ar5.png"
|
||||
},
|
||||
{
|
||||
"filename" => "archive_index9",
|
||||
"name" => {
|
||||
"zh_tw" => "9. 表格列表 - 簡約 ( 模組標題, 檔案名稱, 下載連結 )",
|
||||
"en" => "9. Table list - Simple (widget-title, 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"
|
||||
}
|
||||
]
|
||||
flags = []
|
||||
all_frontend_names = info_json["frontend"].map{|h| h["name"]}
|
||||
check_files.each_with_index do |check_file,i|
|
||||
flag = (info_json["frontend"].select{|h| h["filename"] == check_file.split(".").first}.count == 0 rescue false)
|
||||
if flag
|
||||
info_json["frontend"].push(new_file_infos[i])
|
||||
end
|
||||
if !flag
|
||||
old_file_info = old_file_infos[i]
|
||||
if old_file_info
|
||||
idx = all_frontend_names.index(old_file_info["name"])
|
||||
if idx && idx != -1
|
||||
info_json["frontend"][idx] = new_file_infos[i]
|
||||
flag = true
|
||||
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
|
||||
if bundle_update_flag
|
||||
env_pwd = ENV['PWD']
|
||||
app_path = File.expand_path(__dir__)
|
||||
template_path = env_pwd + '/app/templates'
|
||||
all_template = Dir.glob(template_path+'/*/')
|
||||
all_template.each do |folder|
|
||||
if !folder.include?('mobile')
|
||||
begin
|
||||
next unless File.exist?("#{folder}modules/archive/info.json")
|
||||
info_json_file = "#{folder}modules/archive/info.json"
|
||||
info_json = JSON.parse(File.read(info_json_file))
|
||||
check_files = ["archive_index7.html.erb","archive_index8.html.erb","archive_index9.html.erb","archive_index10.html.erb","archive_index11.html.erb","archive_index12.html.erb"]
|
||||
old_file_infos = [
|
||||
{
|
||||
"filename" => "archive_index7",
|
||||
"name" => {
|
||||
"zh_tw" => "7. 表格列表 ( 模組標題, 類別標題, 檔案名稱, 檔案簡介, 下載連結 )",
|
||||
"en" => "7. Table list (widget-title, category, filename, download link)"
|
||||
},
|
||||
"thumbnail" => "ar5.png"
|
||||
},
|
||||
{
|
||||
"filename" => "archive_index8",
|
||||
"name" => {
|
||||
"zh_tw" => "8. 表格列表 ( 模組標題, 檔案名稱, 檔案簡介, 下載連結 )",
|
||||
"en" => "8. Table list (widget-title, filename, download link)"
|
||||
},
|
||||
"thumbnail" => "ar5.png"
|
||||
}
|
||||
]
|
||||
new_file_infos = [
|
||||
{
|
||||
"filename" => "archive_index7",
|
||||
"name" => {
|
||||
"zh_tw" => "7. 表格列表 ( 模組標題, 類別標題, 上傳日期, 檔案名稱, 檔案簡介, 下載連結 )",
|
||||
"en" => "7. Table list (widget-title, category, Updated At, filename, download link)"
|
||||
},
|
||||
"thumbnail" => "ar5.png"
|
||||
},
|
||||
{
|
||||
"filename" => "archive_index8",
|
||||
"name" => {
|
||||
"zh_tw" => "8. 表格列表 ( 模組標題, 上傳日期, 檔案名稱, 檔案簡介, 下載連結 )",
|
||||
"en" => "8. Table list (widget-title, Updated At, filename, download link)"
|
||||
},
|
||||
"thumbnail" => "ar5.png"
|
||||
},
|
||||
{
|
||||
"filename" => "archive_index9",
|
||||
"name" => {
|
||||
"zh_tw" => "9. 表格列表 - 簡約 ( 模組標題, 檔案名稱, 下載連結 )",
|
||||
"en" => "9. Table list - Simple (widget-title, 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"
|
||||
},
|
||||
{
|
||||
"filename" => "archive_index12",
|
||||
"name" => {
|
||||
"zh_tw" => "12. 手風琴式列表 - 有下拉 ( 模組標題, 類別標題, 檔案名稱, 下載連結 )",
|
||||
"en" => "12. Accordion list - with drop down (widget-title, category, filename, download link)"
|
||||
},
|
||||
"thumbnail" => "ar2.png"
|
||||
}
|
||||
]
|
||||
flags = []
|
||||
all_frontend_names = info_json["frontend"].map{|h| h["name"]}
|
||||
check_files.each_with_index do |check_file,i|
|
||||
flag = (info_json["frontend"].select{|h| h["filename"] == check_file.split(".").first}.count == 0 rescue false)
|
||||
if flag
|
||||
info_json["frontend"].push(new_file_infos[i])
|
||||
end
|
||||
if !flag
|
||||
old_file_info = old_file_infos[i]
|
||||
if old_file_info
|
||||
idx = all_frontend_names.index(old_file_info["name"])
|
||||
if idx && idx != -1
|
||||
info_json["frontend"][idx] = new_file_infos[i]
|
||||
flag = true
|
||||
end
|
||||
end
|
||||
end
|
||||
flags << flag
|
||||
end
|
||||
flags << flag
|
||||
end
|
||||
force_update_files = ["archive_index1.html.erb","archive_index3.html.erb"]
|
||||
puts "updating archive index page"
|
||||
if flags.select{|flag| flag }.count != 0
|
||||
flags.each_with_index do |flag,i|
|
||||
if flag
|
||||
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/archive/#{check_files[i]} #{folder}modules/archive/#{check_files[i]}]}
|
||||
force_update_files = ["archive_index1.html.erb","archive_index3.html.erb","archive_index12.html.erb"]
|
||||
puts "updating archive index page"
|
||||
if flags.select{|flag| flag }.count != 0
|
||||
flags.each_with_index do |flag,i|
|
||||
if flag
|
||||
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/archive/#{check_files[i]} #{folder}modules/archive/#{check_files[i]}]}
|
||||
end
|
||||
end
|
||||
begin
|
||||
info_json = JSON.pretty_generate(info_json).gsub(":[",":[\n").gsub(":{",":{\n")
|
||||
rescue
|
||||
info_json = info_json.to_s.gsub("=>",": \n")
|
||||
end
|
||||
File.open(info_json_file,"w+"){|f| f.write(info_json)}
|
||||
end
|
||||
begin
|
||||
info_json = JSON.pretty_generate(info_json).gsub(":[",":[\n").gsub(":{",":{\n")
|
||||
rescue
|
||||
info_json = info_json.to_s.gsub("=>",": \n")
|
||||
force_update_files.each do |update_file|
|
||||
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/archive/#{update_file} #{folder}modules/archive/#{update_file}]}
|
||||
end
|
||||
File.open(info_json_file,"w+"){|f| f.write(info_json)}
|
||||
Bundler.with_clean_env{%x[cp -rn #{app_path}/modules/archive/thumbs/* #{folder}modules/archive/thumbs/.]}
|
||||
rescue
|
||||
puts "There has some error when updating archive index page."
|
||||
end
|
||||
force_update_files.each do |update_file|
|
||||
Bundler.with_clean_env{%x[cp -f #{app_path}/modules/archive/#{update_file} #{folder}modules/archive/#{update_file}]}
|
||||
end
|
||||
Bundler.with_clean_env{%x[cp -rn #{app_path}/modules/archive/thumbs/* #{folder}modules/archive/thumbs/.]}
|
||||
rescue
|
||||
puts "There has some error when updating archive index page."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ en:
|
|||
restful_actions:
|
||||
categories_order: Categories Order
|
||||
archive:
|
||||
expanded: Expanded
|
||||
other: Other
|
||||
serial_number: "Serial Number"
|
||||
url_text: "URL Text"
|
||||
|
|
|
@ -2,6 +2,7 @@ zh_tw:
|
|||
restful_actions:
|
||||
categories_order: 類別排序
|
||||
archive:
|
||||
expanded: 展開的
|
||||
other: 其他
|
||||
serial_number: "編號"
|
||||
url_text: "連結文字"
|
||||
|
|
|
@ -16,7 +16,7 @@ module Archive
|
|||
module_label "archive.archive"
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
widget_methods ["widget","group_by_category"]
|
||||
widget_settings [{"data_count"=>30}]
|
||||
widget_settings [{"data_count"=>30,"enable_custom_widget_data"=>true}]
|
||||
models_to_cache [:archive_file]
|
||||
taggable "ArchiveFile"
|
||||
categorizable
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<div class="i-archive index-archive-2">
|
||||
<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">
|
||||
<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;">
|
||||
{{category-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">
|
||||
<dl class="dl-horizontal i-archive-item-group" data-list="archives" data-level="1">
|
||||
<dt class="i-archive-item-list">
|
||||
<sapn class="i-archive-item-title">{{archive-title}}</span>
|
||||
<span data-list="statuses" data-level="2">
|
||||
<span class="label status {{status-class}}">{{status}}</span>
|
||||
</span>
|
||||
</dt>
|
||||
<dl class="i-archive-files-list" data-list="files" data-level="2">
|
||||
<dd>
|
||||
<a href="{{file-url}}" class="i-archive-files-item" target="_blank">{{file-name}}</a>
|
||||
<span class="label label-primary">{{file-type}}</span>
|
||||
</dd>
|
||||
</dl>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{link_to_edit}}
|
||||
</div>
|
||||
</div>
|
|
@ -87,6 +87,14 @@
|
|||
"en" : "11. Table list - Simple - Unfold Files (widget-title, category, Serial Number, filename, download link)"
|
||||
},
|
||||
"thumbnail" : "ar9.png"
|
||||
},
|
||||
{
|
||||
"filename" : "archive_index12",
|
||||
"name" : {
|
||||
"zh_tw" : "12. 手風琴式列表 - 有下拉 ( 模組標題, 類別標題, 檔案名稱, 下載連結 )",
|
||||
"en" : "12. Accordion list - with drop down (widget-title, category, filename, download link)"
|
||||
},
|
||||
"thumbnail" : "ar2.png"
|
||||
}
|
||||
],
|
||||
"widgets" : [
|
||||
|
|
Loading…
Reference in New Issue