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
|
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
|
#avoid the categories to be not in the ArchiveCategory
|
||||||
def serve_cmap
|
def serve_cmap
|
||||||
serve_path=File.expand_path("../../assets/javascripts/archive/pdf/bcmaps/#{params[:file_name]}.#{params[:extension]}",__FILE__)
|
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
|
||||||
end
|
end
|
||||||
def index
|
def index
|
||||||
|
page = OrbitHelper.page rescue nil
|
||||||
|
unless page
|
||||||
|
page = Page.where(url:params['url']).first
|
||||||
|
end
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
@@total_pages = 1
|
@@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 = []
|
cats_last = []
|
||||||
sort_order = (ArchiveSortOrder.first['sort_order'] rescue false) ? 1 : -1 #Order with ascending
|
sort_order = (ArchiveSortOrder.first['sort_order'] rescue false) ? 1 : -1 #Order with ascending
|
||||||
if !params['title'].nil?
|
if !params['title'].nil?
|
||||||
|
@ -313,7 +326,8 @@ class ArchivesController < ApplicationController
|
||||||
"date-head" => I18n.t("archive.updated_at"),
|
"date-head" => I18n.t("archive.updated_at"),
|
||||||
"title-head" => I18n.t(:name),
|
"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"),
|
||||||
|
"in_class" => in_class
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
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 %>
|
<%= 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 %>
|
<%= create_pagination(ArchivesController.get_total_pages).html_safe %>
|
|
@ -3,6 +3,8 @@ $:.push File.expand_path("../lib", __FILE__)
|
||||||
# Maintain your gem's version:
|
# Maintain your gem's version:
|
||||||
require "archive/version"
|
require "archive/version"
|
||||||
require 'json'
|
require 'json'
|
||||||
|
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
|
||||||
|
if bundle_update_flag
|
||||||
env_pwd = ENV['PWD']
|
env_pwd = ENV['PWD']
|
||||||
app_path = File.expand_path(__dir__)
|
app_path = File.expand_path(__dir__)
|
||||||
template_path = env_pwd + '/app/templates'
|
template_path = env_pwd + '/app/templates'
|
||||||
|
@ -13,7 +15,7 @@ all_template.each do |folder|
|
||||||
next unless File.exist?("#{folder}modules/archive/info.json")
|
next unless File.exist?("#{folder}modules/archive/info.json")
|
||||||
info_json_file = "#{folder}modules/archive/info.json"
|
info_json_file = "#{folder}modules/archive/info.json"
|
||||||
info_json = JSON.parse(File.read(info_json_file))
|
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"]
|
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 = [
|
old_file_infos = [
|
||||||
{
|
{
|
||||||
"filename" => "archive_index7",
|
"filename" => "archive_index7",
|
||||||
|
@ -72,6 +74,14 @@ all_template.each do |folder|
|
||||||
"en" => "11. Table list - Simple - Unfold Files (widget-title, category, Serial Number, filename, download link)"
|
"en" => "11. Table list - Simple - Unfold Files (widget-title, category, Serial Number, filename, download link)"
|
||||||
},
|
},
|
||||||
"thumbnail" => "ar9.png"
|
"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 = []
|
flags = []
|
||||||
|
@ -93,7 +103,7 @@ all_template.each do |folder|
|
||||||
end
|
end
|
||||||
flags << flag
|
flags << flag
|
||||||
end
|
end
|
||||||
force_update_files = ["archive_index1.html.erb","archive_index3.html.erb"]
|
force_update_files = ["archive_index1.html.erb","archive_index3.html.erb","archive_index12.html.erb"]
|
||||||
puts "updating archive index page"
|
puts "updating archive index page"
|
||||||
if flags.select{|flag| flag }.count != 0
|
if flags.select{|flag| flag }.count != 0
|
||||||
flags.each_with_index do |flag,i|
|
flags.each_with_index do |flag,i|
|
||||||
|
@ -117,6 +127,7 @@ all_template.each do |folder|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
# Describe your gem and declare its dependencies:
|
# Describe your gem and declare its dependencies:
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = "archive"
|
s.name = "archive"
|
||||||
|
|
|
@ -2,6 +2,7 @@ en:
|
||||||
restful_actions:
|
restful_actions:
|
||||||
categories_order: Categories Order
|
categories_order: Categories Order
|
||||||
archive:
|
archive:
|
||||||
|
expanded: Expanded
|
||||||
other: Other
|
other: Other
|
||||||
serial_number: "Serial Number"
|
serial_number: "Serial Number"
|
||||||
url_text: "URL Text"
|
url_text: "URL Text"
|
||||||
|
|
|
@ -2,6 +2,7 @@ zh_tw:
|
||||||
restful_actions:
|
restful_actions:
|
||||||
categories_order: 類別排序
|
categories_order: 類別排序
|
||||||
archive:
|
archive:
|
||||||
|
expanded: 展開的
|
||||||
other: 其他
|
other: 其他
|
||||||
serial_number: "編號"
|
serial_number: "編號"
|
||||||
url_text: "連結文字"
|
url_text: "連結文字"
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Archive
|
||||||
module_label "archive.archive"
|
module_label "archive.archive"
|
||||||
base_url File.expand_path File.dirname(__FILE__)
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
widget_methods ["widget","group_by_category"]
|
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]
|
models_to_cache [:archive_file]
|
||||||
taggable "ArchiveFile"
|
taggable "ArchiveFile"
|
||||||
categorizable
|
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)"
|
"en" : "11. Table list - Simple - Unfold Files (widget-title, category, Serial Number, filename, download link)"
|
||||||
},
|
},
|
||||||
"thumbnail" : "ar9.png"
|
"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" : [
|
"widgets" : [
|
||||||
|
|
Loading…
Reference in New Issue