added widget and changed engine settings

This commit is contained in:
Harry Bomrah 2014-05-23 14:00:49 +08:00
parent 995efe428b
commit 1c7a27bfe4
2 changed files with 37 additions and 3 deletions

View File

@ -4,7 +4,6 @@ class ArchivesController < ApplicationController
@categories = [] @categories = []
if categories.first == "all" if categories.first == "all"
module_app = OrbitHelper.this_module_app module_app = OrbitHelper.this_module_app
# debugger
@categories = module_app.categories.collect do |cat| @categories = module_app.categories.collect do |cat|
{ {
"title" => cat.title, "title" => cat.title,
@ -47,4 +46,38 @@ class ArchivesController < ApplicationController
"extras" => {"widget-title" => "Archives"} "extras" => {"widget-title" => "Archives"}
} }
end end
def widget
categories = OrbitHelper.widget_categories
@categories = []
if categories.first == "all"
module_app = OrbitHelper.widget_module_app
@categories = module_app.categories.collect do |cat|
{
"title" => cat.title,
"id" => cat.id.to_s
}
end
else
categories.each do |cat|
c = Category.find(cat)
@categories << {"title" => c.title, "id" => c.id.to_s}
end
end
cats = @categories.collect do |cat|
archives = ArchiveFile.where(:category_id => cat["id"]).collect do |archive|
{
"archive-title" => archive.title
}
end
{
"category-title" => cat["title"],
"archives" => archives
}
end
{
"categories" => cats,
"extras" => {"widget-title" => "Archives"}
}
end
end end

View File

@ -4,11 +4,12 @@ module Archive
OrbitApp.registration "Archive", :type => "ModuleApp" do OrbitApp.registration "Archive", :type => "ModuleApp" do
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"]
widget_settings [{"data_count"=>10}]
taggable "ArchiveFile" taggable "ArchiveFile"
categorizable categorizable
authorizable authorizable
frontend_enabled
side_bar do side_bar do
head_label_i18n 'archive.archive', icon_class: "icons-archive" head_label_i18n 'archive.archive', icon_class: "icons-archive"
available_for [:admin,:manager,:sub_manager] available_for [:admin,:manager,:sub_manager]