default widgets and sidebar.
This commit is contained in:
1 parent
f9bcb27efc
commit
4bc80f2bd3
28 files changed
+275
-92
No files matched your search
@@ -1,5 +1,5 @@
|
||||
class Admin::ObjectAuthsController < ApplicationController
|
||||
include OrbitCoreLib::PermissionUnility
|
||||
include OrbitCoreLib::PermissionUtility
|
||||
layout "new_admin"
|
||||
before_filter :force_order
|
||||
# before_filter :is_admin? ,:only => :index
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Admin::ObjectAuthsNewInterfaceController < OrbitBackendController
|
||||
include OrbitCoreLib::PermissionUnility
|
||||
include OrbitCoreLib::PermissionUtility
|
||||
before_filter :force_order
|
||||
|
||||
def set_module_app
|
||||
|
||||
@@ -28,27 +28,29 @@ class Admin::PagePartsController < ApplicationController
|
||||
@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
|
||||
@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}
|
||||
# @widget_style = @module_app.widgets[@widget_path] if !@widget_path.blank? && !@module_app.widgets.blank?
|
||||
# end
|
||||
|
||||
case @module_app.key
|
||||
when 'announcement'
|
||||
@categories = BulletinCategory.all
|
||||
@tags = AnnouncementTag.all
|
||||
when 'news'
|
||||
@categories = NewsBulletinCategory.all
|
||||
@tags = NewsTag.all
|
||||
when 'web_resource'
|
||||
@categories = WebLinkCategory.all
|
||||
@tags = WebResourceTag.all
|
||||
when 'archive'
|
||||
@categories = ArchiveFileCategory.all
|
||||
@tags = ArchiveTag.all
|
||||
end
|
||||
# case @module_app.key
|
||||
# when 'announcement'
|
||||
# @categories = BulletinCategory.all
|
||||
# @tags = AnnouncementTag.all
|
||||
# when 'news'
|
||||
# @categories = NewsBulletinCategory.all
|
||||
# @tags = NewsTag.all
|
||||
# when 'web_resource'
|
||||
# @categories = WebLinkCategory.all
|
||||
# @tags = WebResourceTag.all
|
||||
# when 'archive'
|
||||
# @categories = ArchiveFileCategory.all
|
||||
# @tags = ArchiveTag.all
|
||||
# end
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -60,7 +62,7 @@ class Admin::PagePartsController < ApplicationController
|
||||
|
||||
params[:page_part][:widget_field] = params[:page_part][:widget_field].zip( params[:page_part][:widget_field_type] ) if params[:page_part][:widget_field]
|
||||
params[:page_part][:widget_field_type] = nil
|
||||
|
||||
|
||||
if @part.update_attributes(params[:page_part])
|
||||
set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu')
|
||||
flash.now[:notice] = t('update.success.content')
|
||||
@@ -95,7 +97,7 @@ class Admin::PagePartsController < ApplicationController
|
||||
|
||||
@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
|
||||
when 'announcement'
|
||||
@@ -119,8 +121,9 @@ class Admin::PagePartsController < ApplicationController
|
||||
|
||||
def reload_widget_styles
|
||||
@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|
|
||||
format.js {}
|
||||
end
|
||||
|
||||
@@ -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
|
||||
#before_filter :setup_vars
|
||||
#before_filter :set_current_user
|
||||
|
||||
# before_filter {|c| c.front_end_available(@app_title)}
|
||||
# before_filter :check_user_can_use
|
||||
include OrbitCoreLib::PermissionUnility
|
||||
include OrbitCoreLib::AppBackendUtility
|
||||
include OrbitCoreLib::PermissionUtility
|
||||
include AdminHelper
|
||||
include ApplicationHelper
|
||||
|
||||
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)
|
||||
objects = get_objects(object_class, query)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
class OrbitFrontendController< OrbitFrontendComponentController
|
||||
|
||||
|
||||
end
|
||||
@@ -1,3 +1,4 @@
|
||||
class OrbitWidgetController< OrbitFrontendComponentController
|
||||
|
||||
|
||||
end
|
||||
@@ -16,7 +16,7 @@ module AdminHelper
|
||||
end
|
||||
|
||||
def is_admin?
|
||||
current_or_guest_user.admin?
|
||||
current_or_guest_user.admin? rescue false
|
||||
end
|
||||
|
||||
def is_member?
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class ModuleApp
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include OrbitCoreLib::ObjectTokenUnility
|
||||
include OrbitCoreLib::ObjectTokenUtility
|
||||
|
||||
field :key
|
||||
field :title
|
||||
@@ -21,9 +21,17 @@ class ModuleApp
|
||||
OrbitApp::Module::Registration.find_by_key(key)
|
||||
end
|
||||
|
||||
# %w{label_i18n }.each do |field|
|
||||
# define_method(field){|var| get_registration.send("get_#{m}") }
|
||||
# end
|
||||
%w{widget_styles }.each do |field|
|
||||
define_method(field){|var| get_registration.send("get_#{field}") }
|
||||
end
|
||||
|
||||
def get_default_widget
|
||||
get_registration.get_default_widget
|
||||
end
|
||||
|
||||
def enable_frontend?
|
||||
get_registration.get_enable_frontend
|
||||
end
|
||||
|
||||
def label_i18n
|
||||
reg = get_registration
|
||||
@@ -38,10 +46,20 @@ class ModuleApp
|
||||
!get_registration.get_default_widget.blank?
|
||||
end
|
||||
|
||||
def get_widget_style
|
||||
widgets = get_registration.get_widgets
|
||||
end
|
||||
|
||||
def get_widget_for_select
|
||||
widgets = get_registration.get_widgets
|
||||
ary = widgets.collect{|k,v| [I18n.t(v["label"]),k]}
|
||||
ary << [I18n.t('widget.default_widget'),'default_widget']if using_default_widget?
|
||||
ary = widgets.collect do |k,v|
|
||||
if k == 'default_widget'
|
||||
[I18n.t('widget.default_widget'),'default_widget']
|
||||
else
|
||||
[I18n.t(v[:label]),k]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def is_manager?(user)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ObjectAuth < PrototypeAuth
|
||||
include OrbitCoreLib::ObjectTokenUnility
|
||||
include OrbitCoreLib::ObjectTokenUtility
|
||||
validates_uniqueness_of :title ,:scope => [:obj_authable_type,:obj_authable_id] #{ |c| }
|
||||
belongs_to :obj_authable, polymorphic: true
|
||||
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 %>
|
||||
<%= javascript_include_tag "/static/kernel.js" %>
|
||||
<% end %>
|
||||
|
||||
<%=OrbitApp::Module::SideBarRegisition.all.first.render(request,params,current_user) %>
|
||||
<%=OrbitApp::Module::SideBarRegisition.all.first.render(request,params,current_user,@module_app) %>
|
||||
|
||||
<div class="content">
|
||||
<% flash.each do |key, msg| %>
|
||||
|
||||
Reference in new issue
Block a user