module Announcement
  OrbitApp.registration "Announcement",:type=> 'ModuleApp' do
    module_label 'announcement.announcement'
    base_url File.expand_path File.dirname(__FILE__)    

    # personal_plugin :enable => true,:path=>"panel/announcement/plugin/profile",:i18n=>'announcement.announcement'
    
    version "0.1"
    organization "Rulingcom"
    author "RD dep"
    intro "I am intro"
    update_info 'some update_info'

    front_end do
      app_page 'search_result' do
       frontend_i18n "announcement.frontend.search_result" 
      end

      app_page 'bulletins'  do 
        frontend_i18n "announcement.frontend.bulletins"
        style ["1","2","3"]
      end
    end

    # category ["BulletinCategory"]
    data_count 1..10

    authorizable
    approvable
    categorizable
    taggable

    widgets do
      default_widget do
        query 'Bulletin'
        enable ["typeA", "typeB_style3", "typeC"]
        image :image
        field :postdate
        link_field :title,{:method => 'panel_announcement_front_end_bulletin_path',:args=>:self}
        link_field :bulletin_category_with_title,{:method => 'panel_announcement_front_end_bulletins_path',:args=>{:category_id => [:category,:id]}}
        field :subtitle
        link_to_more 'panel_announcement_front_end_bulletins_path',:title_i18n=> 'more_plus'
      end

      categories_query 'Category.all'
      tags_query 'AnnouncementTag.all'

      customize_widget "index" do 
        widget_i18n "announcement.widget.index"
        style ["1","2"]
      end

      customize_widget "bulletins_search_block" do
        widget_i18n "announcement.widget.search"
      end

      customize_widget "bulletins_and_web_links" do
        widget_i18n "announcement.widget.bulletins_and_web_links"
        style ["bulletins_and_links","bulletins_only"]
      end

      # item "index","announcement.widget.index",:default_template=>true,:fields=>["title","category","postdate"]
      # item "bulletins_and_web_links","announcement.widget.bulletins_and_web_links"
    end
    
    side_bar do
      head_label_i18n  'announcement.announcement',:icon_class=>"icons-megaphone"
      available_for [:admin,:guest,:manager,:sub_manager]
      active_for_controllers ({:private=>['bulletins', 'bulletin_categorys', 'approvals','module_tags', 'categories']})
      active_for_object_auth ['BulletinCategory'] 

      head_link_path "panel_announcement_back_end_bulletins_path"

      context_link 'announcement.all_articles',
                            :link_path=>"panel_announcement_back_end_bulletins_path" ,
                            :priority=>1,
                            :active_for_action=>{:bulletins=>:index},
                            :available_for => [:all]
      context_link 'announcement.add_new', 
                            :link_path=>"new_panel_announcement_back_end_bulletin_path" ,
                            :priority=>2,
                            :active_for_action=>{:bulletins=>:new},
                            :available_for => [:sub_manager]
      context_link 'announcement.categories',
                            :link_path=>"admin_module_app_categories_path(get_module_app)" ,
                            :priority=>3,
                            :active_for_category => 'Announcement',
                            :available_for => [:manager]
      context_link 'tags',
                            :link_path=>"admin_module_tags_path(module_app_id: get_module_app)" ,
                            :priority=>4,
                            :active_for_tag => 'Announcement',
                            :available_for => [:manager]
    end
  end
end
