default widgets and sidebar.
This commit is contained in:
parent
f9bcb27efc
commit
4bc80f2bd3
|
@ -1,5 +1,5 @@
|
||||||
class Admin::ObjectAuthsController < ApplicationController
|
class Admin::ObjectAuthsController < ApplicationController
|
||||||
include OrbitCoreLib::PermissionUnility
|
include OrbitCoreLib::PermissionUtility
|
||||||
layout "new_admin"
|
layout "new_admin"
|
||||||
before_filter :force_order
|
before_filter :force_order
|
||||||
# before_filter :is_admin? ,:only => :index
|
# before_filter :is_admin? ,:only => :index
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||||
include OrbitCoreLib::PermissionUnility
|
include OrbitCoreLib::PermissionUtility
|
||||||
before_filter :force_order
|
before_filter :force_order
|
||||||
|
|
||||||
def set_module_app
|
def set_module_app
|
||||||
|
|
|
@ -28,27 +28,29 @@ class Admin::PagePartsController < ApplicationController
|
||||||
@module_app = @part.module_app ? @part.module_app : @module_apps[0]
|
@module_app = @part.module_app ? @part.module_app : @module_apps[0]
|
||||||
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
|
@r_tag = @part.public_r_tag.blank? ? LIST[:public_r_tags][0] : @part.public_r_tag
|
||||||
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
@tag_objects = @r_tag.classify.constantize.all rescue nil
|
||||||
|
|
||||||
@widget_path = @part.widget_path ? @part.widget_path : @module_app.widgets.keys[0]
|
@widget_path = @part.widget_path ? @part.widget_path : @module_app.widgets.keys[0]
|
||||||
|
@widget_style = @module_app.get_widget_style[@widget_path][:style] unless @widget_path.nil?
|
||||||
|
|
||||||
|
@categories = @module_app.get_registration.get_categories
|
||||||
|
@tags = @module_app.get_registration.get_tags
|
||||||
# if @module_app.widgets.any?{|b| b.class == Array}
|
# if @module_app.widgets.any?{|b| b.class == Array}
|
||||||
# @widget_style = @module_app.widgets[@widget_path] if !@widget_path.blank? && !@module_app.widgets.blank?
|
# @widget_style = @module_app.widgets[@widget_path] if !@widget_path.blank? && !@module_app.widgets.blank?
|
||||||
# end
|
# end
|
||||||
|
|
||||||
case @module_app.key
|
# case @module_app.key
|
||||||
when 'announcement'
|
# when 'announcement'
|
||||||
@categories = BulletinCategory.all
|
# @categories = BulletinCategory.all
|
||||||
@tags = AnnouncementTag.all
|
# @tags = AnnouncementTag.all
|
||||||
when 'news'
|
# when 'news'
|
||||||
@categories = NewsBulletinCategory.all
|
# @categories = NewsBulletinCategory.all
|
||||||
@tags = NewsTag.all
|
# @tags = NewsTag.all
|
||||||
when 'web_resource'
|
# when 'web_resource'
|
||||||
@categories = WebLinkCategory.all
|
# @categories = WebLinkCategory.all
|
||||||
@tags = WebResourceTag.all
|
# @tags = WebResourceTag.all
|
||||||
when 'archive'
|
# when 'archive'
|
||||||
@categories = ArchiveFileCategory.all
|
# @categories = ArchiveFileCategory.all
|
||||||
@tags = ArchiveTag.all
|
# @tags = ArchiveTag.all
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -95,7 +97,7 @@ class Admin::PagePartsController < ApplicationController
|
||||||
|
|
||||||
@widget_path = @module_app.widgets.keys[0] if ( @module_app.widgets[0].blank? )
|
@widget_path = @module_app.widgets.keys[0] if ( @module_app.widgets[0].blank? )
|
||||||
|
|
||||||
@widget_style = @module_app.widgets[@widget_path] if ( !@widget_path.blank? )
|
@widget_style = @module_app.get_widget_style[@widget_path][:style] unless @widget_path.nil?
|
||||||
|
|
||||||
case @module_app.key
|
case @module_app.key
|
||||||
when 'announcement'
|
when 'announcement'
|
||||||
|
@ -119,7 +121,8 @@ class Admin::PagePartsController < ApplicationController
|
||||||
|
|
||||||
def reload_widget_styles
|
def reload_widget_styles
|
||||||
@module_app = ModuleApp.find(params[:module_app_id])
|
@module_app = ModuleApp.find(params[:module_app_id])
|
||||||
@widget_style = @module_app.widgets[params[:id]]
|
style_ary = @module_app.get_widget_style[params[:id]]
|
||||||
|
@widget_style = style_ary[:style] unless style_ary.nil?
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js {}
|
format.js {}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
class DefaultWidgetController< OrbitWidgetController
|
||||||
|
|
||||||
|
def front_end_available(var)
|
||||||
|
@page_part = PagePart.find params[:part_id]
|
||||||
|
@page_part.module_app.enable_frontend?
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_widget
|
||||||
|
@tag_class = nil
|
||||||
|
|
||||||
|
@default_widget = @page_part.module_app.get_default_widget
|
||||||
|
@widget_image_field = @default_widget[:image]
|
||||||
|
data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
|
||||||
|
@data = eval(@default_widget[:query]).limit(data_limit).includes(@widget_image_field)
|
||||||
|
@fields = @page_part.widget_field
|
||||||
|
|
||||||
|
case params[:type]
|
||||||
|
when "typeA"
|
||||||
|
@tag_class = 'defulat_widget_typeA'
|
||||||
|
render "typeA"
|
||||||
|
when /typeB_/
|
||||||
|
@tag_class = "defulat_widget_#{params[:type]}"
|
||||||
|
render "typeB"
|
||||||
|
when "typeC"
|
||||||
|
@tag_class = 'defulat_widget_typeC'
|
||||||
|
render "typeC"
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# {"inner"=>"true",
|
||||||
|
# "category_id"=>"false",
|
||||||
|
# "tag_id"=>"",
|
||||||
|
# "page"=>"",
|
||||||
|
# "search_query"=>"",
|
||||||
|
# "part_title"=>"",
|
||||||
|
# "part_id"=>"50ac426f83e75219d20000a7",
|
||||||
|
# "controller"=>"default_widget",
|
||||||
|
# "action"=>"default_widget",
|
||||||
|
# "type"=>"typeA"}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,41 +1,11 @@
|
||||||
class OrbitBackendController < ApplicationController
|
class OrbitBackendController < ApplicationController
|
||||||
#before_filter :setup_vars
|
include OrbitCoreLib::AppBackendUtility
|
||||||
#before_filter :set_current_user
|
include OrbitCoreLib::PermissionUtility
|
||||||
|
|
||||||
# before_filter {|c| c.front_end_available(@app_title)}
|
|
||||||
# before_filter :check_user_can_use
|
|
||||||
include OrbitCoreLib::PermissionUnility
|
|
||||||
include AdminHelper
|
include AdminHelper
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
||||||
layout 'new_admin'
|
layout 'new_admin'
|
||||||
|
|
||||||
def setup_vars
|
|
||||||
@app_title ||= controller_path.split('/')[1].singularize
|
|
||||||
@module_app ||= ModuleApp.first(conditions: {:key => @app_title} )
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def force_order_for_visitor
|
|
||||||
setup_vars
|
|
||||||
set_current_user
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def force_order_for_user
|
|
||||||
setup_vars
|
|
||||||
set_current_user
|
|
||||||
authenticate_user!
|
|
||||||
check_user_can_use
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_user_can_use
|
|
||||||
unless check_permission
|
|
||||||
#redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])
|
|
||||||
redirect_to root_url
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_sorted_and_filtered(object_class, query=nil)
|
def get_sorted_and_filtered(object_class, query=nil)
|
||||||
objects = get_objects(object_class, query)
|
objects = get_objects(object_class, query)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
class OrbitFrontendController< OrbitFrontendComponentController
|
class OrbitFrontendController< OrbitFrontendComponentController
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
|
@ -1,3 +1,4 @@
|
||||||
class OrbitWidgetController< OrbitFrontendComponentController
|
class OrbitWidgetController< OrbitFrontendComponentController
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
|
@ -16,7 +16,7 @@ module AdminHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_admin?
|
def is_admin?
|
||||||
current_or_guest_user.admin?
|
current_or_guest_user.admin? rescue false
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_member?
|
def is_member?
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class ModuleApp
|
class ModuleApp
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include OrbitCoreLib::ObjectTokenUnility
|
include OrbitCoreLib::ObjectTokenUtility
|
||||||
|
|
||||||
field :key
|
field :key
|
||||||
field :title
|
field :title
|
||||||
|
@ -21,9 +21,17 @@ class ModuleApp
|
||||||
OrbitApp::Module::Registration.find_by_key(key)
|
OrbitApp::Module::Registration.find_by_key(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
# %w{label_i18n }.each do |field|
|
%w{widget_styles }.each do |field|
|
||||||
# define_method(field){|var| get_registration.send("get_#{m}") }
|
define_method(field){|var| get_registration.send("get_#{field}") }
|
||||||
# end
|
end
|
||||||
|
|
||||||
|
def get_default_widget
|
||||||
|
get_registration.get_default_widget
|
||||||
|
end
|
||||||
|
|
||||||
|
def enable_frontend?
|
||||||
|
get_registration.get_enable_frontend
|
||||||
|
end
|
||||||
|
|
||||||
def label_i18n
|
def label_i18n
|
||||||
reg = get_registration
|
reg = get_registration
|
||||||
|
@ -38,10 +46,20 @@ class ModuleApp
|
||||||
!get_registration.get_default_widget.blank?
|
!get_registration.get_default_widget.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_widget_style
|
||||||
|
widgets = get_registration.get_widgets
|
||||||
|
end
|
||||||
|
|
||||||
def get_widget_for_select
|
def get_widget_for_select
|
||||||
widgets = get_registration.get_widgets
|
widgets = get_registration.get_widgets
|
||||||
ary = widgets.collect{|k,v| [I18n.t(v["label"]),k]}
|
ary = widgets.collect do |k,v|
|
||||||
ary << [I18n.t('widget.default_widget'),'default_widget']if using_default_widget?
|
if k == 'default_widget'
|
||||||
|
[I18n.t('widget.default_widget'),'default_widget']
|
||||||
|
else
|
||||||
|
[I18n.t(v[:label]),k]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_manager?(user)
|
def is_manager?(user)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class ObjectAuth < PrototypeAuth
|
class ObjectAuth < PrototypeAuth
|
||||||
include OrbitCoreLib::ObjectTokenUnility
|
include OrbitCoreLib::ObjectTokenUtility
|
||||||
validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| }
|
validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| }
|
||||||
belongs_to :obj_authable, polymorphic: true
|
belongs_to :obj_authable, polymorphic: true
|
||||||
after_save :check_user_has_can_access_app
|
after_save :check_user_has_can_access_app
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
$('#widget_style_list select').html("<%= j options_for_select(@module_app.widgets[params[:id]]) %>")
|
<% if @widget_style.nil? %>
|
||||||
|
$('#widget_style_list select').html("")
|
||||||
|
<% else %>
|
||||||
|
$('#widget_style_list select').html("<%= j options_for_select(@widget_style) %>")
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<%= content_tag :div,:class=>@tag_class do%>
|
||||||
|
<div class="defulat_widget_type_A">
|
||||||
|
<table class="defulat_widget_tb" border="0" cellpadding="0" cellspacing="0" >
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<% @fields.each do |field|%>
|
||||||
|
<th><%= content_tag(:span,field[0],:class=>field[1])%></th>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<% @data.each do |row_data| %>
|
||||||
|
<tr>
|
||||||
|
<% @fields.each do |field|%>
|
||||||
|
<td><%= content_tag(:span,row_data.send(field[0]),:class=>field[1])%></td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<%= content_tag :div,:class=>@tag_class do%>
|
||||||
|
<ul class="defulat_widget_list">
|
||||||
|
|
||||||
|
<% @data.each do |row_data| %>
|
||||||
|
<%= content_tag(:li) do %>
|
||||||
|
<div class="img app-pic">
|
||||||
|
<%= image_tag row_data.send(@widget_image_field)%>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="wrap">
|
||||||
|
<% @fields.each do |field|%>
|
||||||
|
<%= content_tag(:span,row_data.send(field[0]),:class=>field[1])%>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
<div class="more">more</div>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<%= content_tag :div,:class=>@tag_class do%>
|
||||||
|
<div class="img app-pic">
|
||||||
|
<%= image_tag @data.first.send(@widget_image_field)%>
|
||||||
|
</div>
|
||||||
|
<ul class="defulat_widget_list">
|
||||||
|
<% @data.each do |row_data| %>
|
||||||
|
<%= content_tag(:li) do %>
|
||||||
|
<% @fields.each do |field|%>
|
||||||
|
<%= content_tag(:span,row_data.send(field[0]),:class=>field[1])%>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<div class="more">more</div>
|
||||||
|
<% end %>
|
|
@ -4,8 +4,7 @@
|
||||||
<% content_for :page_specific_javascript do %>
|
<% content_for :page_specific_javascript do %>
|
||||||
<%= javascript_include_tag "/static/kernel.js" %>
|
<%= javascript_include_tag "/static/kernel.js" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%=OrbitApp::Module::SideBarRegisition.all.first.render(request,params,current_user,@module_app) %>
|
||||||
<%=OrbitApp::Module::SideBarRegisition.all.first.render(request,params,current_user) %>
|
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<% flash.each do |key, msg| %>
|
<% flash.each do |key, msg| %>
|
||||||
|
|
|
@ -867,11 +867,11 @@ zh_tw:
|
||||||
widget:
|
widget:
|
||||||
default_widget: 系統預設Widget
|
default_widget: 系統預設Widget
|
||||||
_default_widget:
|
_default_widget:
|
||||||
style1: 表格列表
|
typeA: 表格列表
|
||||||
style2: 單行列佐圖(同邊)
|
typeB_style2: 單行列佐圖(同邊)
|
||||||
style3: 多行列佐圖(同邊)
|
typeB_style3: 多行列佐圖(同邊)
|
||||||
style4: 多行列佐圖(異邊)
|
typeB_style4: 多行列佐圖(異邊)
|
||||||
style5: 單行列佐單圖(同邊)
|
typeC: 單行列佐單圖(同邊)
|
||||||
# : <<<<<<< HEAD
|
# : <<<<<<< HEAD
|
||||||
mongoid:
|
mongoid:
|
||||||
models:
|
models:
|
||||||
|
|
|
@ -220,7 +220,7 @@ Orbit::Application.routes.draw do
|
||||||
# match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal'
|
# match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal'
|
||||||
|
|
||||||
|
|
||||||
|
match '/panel/orbit_app/widget/:type' => 'default_widget#default_widget'
|
||||||
|
|
||||||
match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request|
|
match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request|
|
||||||
!request.query_string.include?("inner=true")
|
!request.query_string.include?("inner=true")
|
||||||
|
|
|
@ -1,12 +1,32 @@
|
||||||
module ContextLinkRenderer
|
module ContextLinkRenderer
|
||||||
include Renderer
|
include Renderer
|
||||||
|
|
||||||
def render(request,params)
|
def render(request,params,module_app,user)
|
||||||
|
@module_app = module_app
|
||||||
@request = request
|
@request = request
|
||||||
@params = params
|
@params = params
|
||||||
|
@current_user = user
|
||||||
if display?
|
if display?
|
||||||
content_tag :li, link_to((I18n.t(@label_i18n) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, eval(@path)), :class => (active? ? 'active' : nil)
|
content_tag :li, link_to((I18n.t(@label_i18n) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, eval(@path)), :class => (active? ? 'active' : nil)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
def display?
|
||||||
|
@available_for.each do |available_for_in_sym|
|
||||||
|
result = case available_for_in_sym
|
||||||
|
when :all
|
||||||
|
true
|
||||||
|
when :manager
|
||||||
|
@module_app.is_manager? @current_user
|
||||||
|
when :sub_manager
|
||||||
|
@module_app.is_sub_manager? @current_user
|
||||||
|
else
|
||||||
|
(eval(available_for_in_sym).include? @current_user rescue false)
|
||||||
|
end # of case
|
||||||
|
return true if result || @current_user.admin?
|
||||||
|
end # of collect
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -8,10 +8,15 @@ module Renderer
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def active_for_app_auth?
|
def active_for_app_auth?
|
||||||
|
if @module_app.nil?
|
||||||
|
false
|
||||||
|
else
|
||||||
@module_app.id.to_s == @params[:module_app_id] ? true : false
|
@module_app.id.to_s == @params[:module_app_id] ? true : false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def active_for_ob_auths?
|
def active_for_ob_auths?
|
||||||
|
|
||||||
if @params.has_key? :object_auth_id
|
if @params.has_key? :object_auth_id
|
||||||
oa = ObjectAuth.find @params[:object_auth_id]
|
oa = ObjectAuth.find @params[:object_auth_id]
|
||||||
check_controller = @params[:controller] == 'admin/object_auths_new_interface'
|
check_controller = @params[:controller] == 'admin/object_auths_new_interface'
|
||||||
|
|
|
@ -2,7 +2,8 @@ module SideBarRenderer
|
||||||
include Renderer
|
include Renderer
|
||||||
include AdminHelper
|
include AdminHelper
|
||||||
|
|
||||||
def render(request,params,user)
|
def render(request,params,user,module_app)
|
||||||
|
@module_app = module_app
|
||||||
@request = request
|
@request = request
|
||||||
@params = params
|
@params = params
|
||||||
@current_user = user
|
@current_user = user
|
||||||
|
@ -11,7 +12,7 @@ module SideBarRenderer
|
||||||
buf = link_to( content_tag(:i, nil, :class => @icon_class ) + content_tag(:span, I18n.t( @head_label )), eval(@head_link))
|
buf = link_to( content_tag(:i, nil, :class => @icon_class ) + content_tag(:span, I18n.t( @head_label )), eval(@head_link))
|
||||||
buf << content_tag( :ul, :class => ("nav nav-list active") )do # visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals')||active_for_ob_auths_object("BulletinCategory"))
|
buf << content_tag( :ul, :class => ("nav nav-list active") )do # visible_for_controllers('bulletins', '/panel/announcement/back_end/tags', 'bulletin_categorys', 'approvals')||active_for_ob_auths_object("BulletinCategory"))
|
||||||
@context_links.sort_by! {| obj | obj.priority}.collect do |link|
|
@context_links.sort_by! {| obj | obj.priority}.collect do |link|
|
||||||
link.render(request,params)
|
link.render(request,params,@module_app,@current_user)
|
||||||
end.join.html_safe
|
end.join.html_safe
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,11 +78,11 @@ module OrbitApp
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_categories
|
def get_categories
|
||||||
eval(@widget_set.categories_query) rescue nil
|
@widget_set.get_categories
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_tags
|
def get_tags
|
||||||
eval(@widget_set.tags_query) rescue nil
|
@widget_set.get_tags
|
||||||
end
|
end
|
||||||
|
|
||||||
def front_end(&block)
|
def front_end(&block)
|
||||||
|
|
|
@ -46,9 +46,9 @@ module OrbitApp
|
||||||
@active_for_app_auth = []
|
@active_for_app_auth = []
|
||||||
@head_link = ""
|
@head_link = ""
|
||||||
@app_base_path = ''
|
@app_base_path = ''
|
||||||
|
@module_app_key = key
|
||||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||||
# setup_module_app(module_app_key)
|
# setup_module_app(module_app_key)
|
||||||
@module_app_key = key
|
|
||||||
finalize!
|
finalize!
|
||||||
SideBarRegisition.add(self)
|
SideBarRegisition.add(self)
|
||||||
end
|
end
|
||||||
|
@ -76,6 +76,7 @@ module OrbitApp
|
||||||
end
|
end
|
||||||
|
|
||||||
def context_link(*var)
|
def context_link(*var)
|
||||||
|
var[1].merge!(:module_app_key=>@module_app_key) unless @module_app_key.nil?
|
||||||
new_context_link = ContextLink.new(*var)
|
new_context_link = ContextLink.new(*var)
|
||||||
@context_links << new_context_link
|
@context_links << new_context_link
|
||||||
end
|
end
|
||||||
|
@ -124,10 +125,14 @@ module OrbitApp
|
||||||
@active_for_action = options[:active_for_action] || []
|
@active_for_action = options[:active_for_action] || []
|
||||||
@active_for_object_auth = options[:active_for_object_auth] || []
|
@active_for_object_auth = options[:active_for_object_auth] || []
|
||||||
@active_for_app_auth = options[:active_for_app_auth] || []
|
@active_for_app_auth = options[:active_for_app_auth] || []
|
||||||
|
@module_app_key = options[:module_app_key]
|
||||||
end
|
end
|
||||||
|
|
||||||
def active?
|
def active?
|
||||||
active_for_action? || active_for_app_auth? || active_for_ob_auths?
|
for_action = @active_for_action.blank? ? false : active_for_action?
|
||||||
|
for_app_auth = @active_for_app_auth.blank? ? false : active_for_app_auth?
|
||||||
|
for_ob_auth = @active_for_object_auth.blank? ? false : active_for_ob_auths?
|
||||||
|
for_action || for_app_auth || for_ob_auth
|
||||||
end
|
end
|
||||||
|
|
||||||
def active_for_action?
|
def active_for_action?
|
||||||
|
|
|
@ -35,11 +35,11 @@ module OrbitApp
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_categories
|
def get_categories
|
||||||
@categories_query
|
eval(@categories_query) rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_tags
|
def get_tags
|
||||||
@tags_query
|
eval(@tags_query) rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_widget(&block)
|
def default_widget(&block)
|
||||||
|
@ -53,6 +53,7 @@ module OrbitApp
|
||||||
def to_module_app_format
|
def to_module_app_format
|
||||||
hash = {}
|
hash = {}
|
||||||
@widgets.collect{|t| hash[t.name] = t.to_hash}
|
@widgets.collect{|t| hash[t.name] = t.to_hash}
|
||||||
|
hash["default_widget"]= DefaultWidget.get_interface_args unless @default_widget.blank?
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,12 +64,19 @@ module OrbitApp
|
||||||
end
|
end
|
||||||
|
|
||||||
class DefaultWidget
|
class DefaultWidget
|
||||||
|
STYLE = ["typeA","typeB_style2","typeB_style3","typeB_style4","typeC"]
|
||||||
|
|
||||||
def initialize(&block)
|
def initialize(&block)
|
||||||
@query = nil
|
@query = nil
|
||||||
@image = nil
|
@image = nil
|
||||||
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get_interface_args
|
||||||
|
#will need to work with design
|
||||||
|
{:name=>"default_widget",:field=>nil,:label=>'label',:style=>STYLE}
|
||||||
|
end
|
||||||
|
|
||||||
def to_module_app_format
|
def to_module_app_format
|
||||||
{:query=>@query,:image=>@image} rescue nil
|
{:query=>@query,:image=>@image} rescue nil
|
||||||
end
|
end
|
||||||
|
@ -90,10 +98,11 @@ module OrbitApp
|
||||||
@name = name
|
@name = name
|
||||||
@fields = options[:fields]
|
@fields = options[:fields]
|
||||||
@label = label
|
@label = label
|
||||||
|
@style= options[:style]
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_hash
|
def to_hash
|
||||||
{:name => @name,:fields=>@fields,:label=>@label}
|
{:name => @name,:fields=>@fields,:label=>@label,:style=>@style}
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
|
|
|
@ -81,7 +81,7 @@ module OrbitCoreLib
|
||||||
end
|
end
|
||||||
|
|
||||||
query1 = auth_object_space.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: user.id)
|
query1 = auth_object_space.any_in({sub_role_ids: sub_role_ids_ary}).excludes(blocked_user_ids: user.id)
|
||||||
query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id},{role_ids: user.role.id}).excludes(blocked_user_ids: user.id)
|
query2 = auth_object_space.any_of({all: true},{privilege_user_ids: user.id},{role_ids: user.role_ids}).excludes(blocked_user_ids: user.id)
|
||||||
result = (query1 + query2).uniq
|
result = (query1 + query2).uniq
|
||||||
result.collect{|t| t.obj_authable}.delete_if{|val| val==nil}
|
result.collect{|t| t.obj_authable}.delete_if{|val| val==nil}
|
||||||
end
|
end
|
||||||
|
@ -128,7 +128,7 @@ module OrbitCoreLib
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
module ObjectTokenUnility
|
module ObjectTokenUtility
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.instance_eval("field :s_token")
|
base.instance_eval("field :s_token")
|
||||||
base.instance_eval("after_create :generate_token")
|
base.instance_eval("after_create :generate_token")
|
||||||
|
@ -145,7 +145,7 @@ module OrbitCoreLib
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module PermissionUnility
|
module PermissionUtility
|
||||||
private
|
private
|
||||||
def check_permission(type = :use)
|
def check_permission(type = :use)
|
||||||
permission_grant = current_or_guest_user.admin?? true : false
|
permission_grant = current_or_guest_user.admin?? true : false
|
||||||
|
@ -168,4 +168,34 @@ module OrbitCoreLib
|
||||||
ModuleApp.first(conditions: {s_token: token})
|
ModuleApp.first(conditions: {s_token: token})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module AppBackendUtility
|
||||||
|
def setup_vars
|
||||||
|
@app_title ||= controller_path.split('/')[1].singularize
|
||||||
|
@module_app ||= ModuleApp.first(conditions: {:key => @app_title} )
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def force_order_for_visitor
|
||||||
|
setup_vars
|
||||||
|
set_current_user
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def force_order_for_user
|
||||||
|
setup_vars
|
||||||
|
set_current_user
|
||||||
|
authenticate_user!
|
||||||
|
check_user_can_use
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_user_can_use
|
||||||
|
unless check_permission
|
||||||
|
#redirect_to polymorphic_path(['panel',@app_title,'back_end','public'])
|
||||||
|
redirect_to root_url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -215,7 +215,13 @@ module ParserCommon
|
||||||
when 'text'
|
when 'text'
|
||||||
ret << part.content rescue ''
|
ret << part.content rescue ''
|
||||||
when 'module_widget'
|
when 'module_widget'
|
||||||
url = "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
url = case part.widget_path
|
||||||
|
when 'default_widget'
|
||||||
|
"/panel/orbit_app/widget/#{part.widget_style}?inner=true"
|
||||||
|
else
|
||||||
|
"/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
|
||||||
|
end
|
||||||
|
|
||||||
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}&part_id=#{part.id}"
|
options = "&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}&part_id=#{part.id}"
|
||||||
ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"
|
ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"
|
||||||
when 'public_r_tag'
|
when 'public_r_tag'
|
||||||
|
|
|
@ -3,6 +3,10 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
|
||||||
|
|
||||||
before_filter :for_app_manager,:except => [:index,:get_categorys_json,:get_bulletins_json]
|
before_filter :for_app_manager,:except => [:index,:get_categorys_json,:get_bulletins_json]
|
||||||
|
|
||||||
|
before_filter :force_order_for_visitor,:only=>[:index,:get_categorys_json,:get_bulletins_json]
|
||||||
|
before_filter :force_order_for_user,:except => [:index,:get_categorys_json,:get_bulletins_json]
|
||||||
|
before_filter :for_app_sub_manager,:except => [:index,:get_categorys_json,:get_bulletins_json]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@bulletin_categorys = get_categories_for_index("BulletinCategory")
|
@bulletin_categorys = get_categories_for_index("BulletinCategory")
|
||||||
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
|
#TODO 需要做 manager ,admin 才可以 all. 其他 available就好
|
||||||
|
|
|
@ -18,3 +18,9 @@ zh_tw:
|
||||||
widget:
|
widget:
|
||||||
index: 目錄Widget
|
index: 目錄Widget
|
||||||
bulletins_and_web_links: 公告與連結並排Widget
|
bulletins_and_web_links: 公告與連結並排Widget
|
||||||
|
#init don't merge
|
||||||
|
all_articles: 全部公告
|
||||||
|
add_new: 新增
|
||||||
|
categories: 分類
|
||||||
|
approval_setting: 審核權限
|
||||||
|
tags: 標籤
|
|
@ -25,7 +25,7 @@ module Announcement
|
||||||
categories_query 'BulletinCategory.all'
|
categories_query 'BulletinCategory.all'
|
||||||
tags_query 'AnnouncementTag.all'
|
tags_query 'AnnouncementTag.all'
|
||||||
|
|
||||||
customize_widget "index","announcement.widget.index",:fields=>["title","category","postdate"]
|
customize_widget "index","announcement.widget.index",:fields=>["title","category","postdate"],:style=>["cu_style_1","cu_style_2","cu_style_3","cu_style_4","cu_style_5"]
|
||||||
customize_widget "bulletins_and_web_links","announcement.widget.bulletins_and_web_links"
|
customize_widget "bulletins_and_web_links","announcement.widget.bulletins_and_web_links"
|
||||||
# item "index","announcement.widget.index",:default_template=>true,:fields=>["title","category","postdate"]
|
# item "index","announcement.widget.index",:default_template=>true,:fields=>["title","category","postdate"]
|
||||||
# item "bulletins_and_web_links","announcement.widget.bulletins_and_web_links"
|
# item "bulletins_and_web_links","announcement.widget.bulletins_and_web_links"
|
||||||
|
@ -42,13 +42,14 @@ module Announcement
|
||||||
context_link 'announcement.all_articles',
|
context_link 'announcement.all_articles',
|
||||||
:link_path=>"panel_announcement_back_end_bulletins_path" ,
|
:link_path=>"panel_announcement_back_end_bulletins_path" ,
|
||||||
:priority=>1,
|
:priority=>1,
|
||||||
:active_for_action=>{:bulletins=>:index}
|
:active_for_action=>{:bulletins=>:index},
|
||||||
|
:available_for => [:all]
|
||||||
|
|
||||||
context_link 'announcement.add_new',
|
context_link 'announcement.add_new',
|
||||||
:link_path=>"new_panel_announcement_back_end_bulletin_path" ,
|
:link_path=>"new_panel_announcement_back_end_bulletin_path" ,
|
||||||
:priority=>2,
|
:priority=>2,
|
||||||
:active_for_action=>{:bulletins=>:new},
|
:active_for_action=>{:bulletins=>:new},
|
||||||
:available_for => [:manager]
|
:available_for => [:sub_manager]
|
||||||
|
|
||||||
context_link 'announcement.categories',
|
context_link 'announcement.categories',
|
||||||
:link_path=>"panel_announcement_back_end_bulletin_categorys_path" ,
|
:link_path=>"panel_announcement_back_end_bulletin_categorys_path" ,
|
||||||
|
@ -59,12 +60,13 @@ module Announcement
|
||||||
context_link 'announcement.tags',
|
context_link 'announcement.tags',
|
||||||
:link_path=>"panel_announcement_back_end_tags_path" ,
|
:link_path=>"panel_announcement_back_end_tags_path" ,
|
||||||
:priority=>4,
|
:priority=>4,
|
||||||
:active_for_action=>{:bulletin_categorys=>:index},
|
# :active_for_action=>{:bulletin_categorys=>:index},
|
||||||
:available_for => [:manager]
|
:available_for => [:manager]
|
||||||
|
|
||||||
context_link 'announcement.approval_setting',
|
context_link 'announcement.approval_setting',
|
||||||
:link_path=>"panel_announcement_back_end_approval_setting_path" ,
|
:link_path=>"panel_announcement_back_end_approval_setting_path" ,
|
||||||
:priority=>5,
|
:priority=>5,
|
||||||
|
:active_for_action=>{:approvals=>:setting},
|
||||||
:active_for_object_auth => 'BulletinCategory',
|
:active_for_object_auth => 'BulletinCategory',
|
||||||
:available_for => [:manager]
|
:available_for => [:manager]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue